aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dm/DMSrcSink.cpp27
-rw-r--r--gm/drawable.cpp35
-rw-r--r--src/core/SkRecorder.h1
3 files changed, 54 insertions, 9 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 51c79dac74..f83ba3b368 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -254,26 +254,26 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
case SkImageGenerator::kIncompleteInput:
break;
default:
- return SkStringPrintf("%s failed with error message %d",
+ return SkStringPrintf("%s failed with error message %d",
fPath.c_str(), (int) subsetResult);
}
const size_t bpp = decodeInfo.bytesPerPixel();
- /*
- * we copy all the lines at once becuase when calling getScanlines for
- * interlaced pngs the entire image must be read regardless of the number
+ /*
+ * we copy all the lines at once becuase when calling getScanlines for
+ * interlaced pngs the entire image must be read regardless of the number
* of lines requested. Reading an interlaced png in a loop, line-by-line, would
* decode the entire image height times, which is very slow
* it is aknowledged that copying each line as you read it in a loop
* may be faster for other types of images. Since this is a correctness test
* that's okay.
*/
- char* bufferRow = buffer;
+ char* bufferRow = buffer;
for (int subsetY = 0; subsetY < currentSubsetHeight; ++subsetY) {
- memcpy(subsetBm.getAddr(0, subsetY), bufferRow + x*bpp,
+ memcpy(subsetBm.getAddr(0, subsetY), bufferRow + x*bpp,
currentSubsetWidth*bpp);
bufferRow += rowBytes;
}
-
+
canvas->drawBitmap(subsetBm, SkIntToScalar(x), SkIntToScalar(y));
}
}
@@ -930,6 +930,7 @@ Error ViaTwice::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri
// This is an only-slightly-exaggerated simluation of Blink's Slimming Paint pictures.
struct DrawsAsSingletonPictures {
SkCanvas* fCanvas;
+ const SkDrawableList& fDrawables;
SK_CREATE_MEMBER_DETECTOR(paint);
@@ -938,7 +939,8 @@ struct DrawsAsSingletonPictures {
// We must pass SkMatrix::I() as our initial matrix.
// By default SkRecords::Draw() uses the canvas' matrix as its initial matrix,
// which would have the funky effect of applying transforms over and over.
- SkRecords::Draw(canvas, nullptr, nullptr, 0, &SkMatrix::I())(op);
+ SkRecords::Draw d(canvas, nullptr, fDrawables.begin(), fDrawables.count(), &SkMatrix::I());
+ d(op);
}
// Most things that have paints are Draw-type ops. Create sub-pictures for each.
@@ -975,7 +977,14 @@ Error ViaSingletonPictures::draw(
SkPictureRecorder macroRec;
SkCanvas* macroCanvas = macroRec.beginRecording(SkIntToScalar(size.width()),
SkIntToScalar(size.height()));
- DrawsAsSingletonPictures drawsAsSingletonPictures = { macroCanvas };
+
+ SkAutoTDelete<SkDrawableList> drawables(recorder.detachDrawableList());
+ const SkDrawableList empty;
+
+ DrawsAsSingletonPictures drawsAsSingletonPictures = {
+ macroCanvas,
+ drawables ? *drawables : empty,
+ };
for (unsigned i = 0; i < skr.count(); i++) {
skr.visit<void>(i, drawsAsSingletonPictures);
}
diff --git a/gm/drawable.cpp b/gm/drawable.cpp
new file mode 100644
index 0000000000..375ce73cbe
--- /dev/null
+++ b/gm/drawable.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "SkCanvas.h"
+#include "SkDrawable.h"
+
+struct MyDrawable : public SkDrawable {
+ SkRect onGetBounds() override {
+ return SkRect::MakeWH(640, 480);
+ }
+
+ void onDraw(SkCanvas* canvas) override {
+ SkPath path;
+ path.moveTo(10, 10);
+ path.conicTo(10, 90, 50, 90, 0.9f);
+
+ SkPaint paint;
+ paint.setColor(SK_ColorBLUE);
+ canvas->drawRect(path.getBounds(), paint);
+
+ paint.setAntiAlias(true);
+ paint.setColor(SK_ColorWHITE);
+ canvas->drawPath(path, paint);
+ }
+};
+
+DEF_SIMPLE_GM(Drawables, canvas, 640, 480) {
+ SkAutoTUnref<SkDrawable> d(new MyDrawable);
+ canvas->drawDrawable(d);
+}
diff --git a/src/core/SkRecorder.h b/src/core/SkRecorder.h
index 688069bd50..338fab4968 100644
--- a/src/core/SkRecorder.h
+++ b/src/core/SkRecorder.h
@@ -19,6 +19,7 @@ class SkBBHFactory;
class SkDrawableList : SkNoncopyable {
public:
+ SkDrawableList() {}
~SkDrawableList();
int count() const { return fArray.count(); }