aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2016-10-06 14:33:43 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-06 18:52:32 +0000
commit1356978f15a4dc36928353a6fca4cbd6c40abce5 (patch)
tree0fdb9965b768d39ed8da917f918777d196d09bee /src/utils
parent8f1864386734cfa7650a5576ba453745a407ade2 (diff)
Fix SkDeferredCanvas for use on android.
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3030 Change-Id: Ie55023257736a12360a233d01096462ba2eb3e74 Reviewed-on: https://skia-review.googlesource.com/3030 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/SkDeferredCanvas.cpp30
-rw-r--r--src/utils/SkDeferredCanvas.h8
2 files changed, 27 insertions, 11 deletions
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 75cd5dbd49..d2d75fe915 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -31,7 +31,7 @@ bool SkDeferredCanvas::Rec::isConcat(SkMatrix* m) const {
void SkDeferredCanvas::Rec::setConcat(const SkMatrix& m) {
SkASSERT(m.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask));
-
+
if (m.getType() <= SkMatrix::kTranslate_Mask) {
fType = kTrans_Type;
fData.fTranslate.set(m.getTranslateX(), m.getTranslateY());
@@ -45,12 +45,24 @@ void SkDeferredCanvas::Rec::setConcat(const SkMatrix& m) {
///////////////////////////////////////////////////////////////////////////////////////////////////
SkDeferredCanvas::SkDeferredCanvas(SkCanvas* canvas)
- : INHERITED(canvas->getBaseLayerSize().width(), canvas->getBaseLayerSize().height())
- , fCanvas(canvas)
-{}
+ : SkCanvas({0,0,1,1}, SkCanvas::kConservativeRasterClip_InitFlag) {
+ this->reset(canvas);
+}
SkDeferredCanvas::~SkDeferredCanvas() {}
+void SkDeferredCanvas::reset(SkCanvas* canvas) {
+ if (fCanvas) {
+ this->flush();
+ fCanvas = nullptr;
+ }
+ fRecs.reset();
+ if (canvas) {
+ this->resetForNextPicture(SkIRect::MakeSize(canvas->getBaseLayerSize()));
+ fCanvas = canvas;
+ }
+}
+
void SkDeferredCanvas::push_save() {
Rec* r = fRecs.append();
r->fType = kSave_Type;
@@ -434,7 +446,7 @@ void SkDeferredCanvas::onDrawImageLattice(const SkImage* image, const Lattice& l
}
void SkDeferredCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
- const SkPaint& paint) {
+ const SkPaint& paint) {
this->flush_translate(&x, &y, paint);
fCanvas->drawText(text, byteLength, x, y, paint);
}
@@ -480,7 +492,7 @@ void SkDeferredCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScal
#include "SkCanvasPriv.h"
void SkDeferredCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
const SkPaint* paint) {
-#if 1
+#if 0
SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect());
picture->playback(this);
#else
@@ -491,7 +503,7 @@ void SkDeferredCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* m
void SkDeferredCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
// TODO: investigate culling and applying concat to the matrix
-#if 1
+#if 0
drawable->draw(this, matrix);
#else
this->flush_before_saves();
@@ -525,7 +537,9 @@ void SkDeferredCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor color
}
void SkDeferredCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* data) {
- fCanvas->drawAnnotation(rect, key, data);
+ SkRect modRect = rect;
+ this->flush_check(&modRect, nullptr, kNoClip_Flag);
+ fCanvas->drawAnnotation(modRect, key, data);
}
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
diff --git a/src/utils/SkDeferredCanvas.h b/src/utils/SkDeferredCanvas.h
index 312c22d26e..2ac594c903 100644
--- a/src/utils/SkDeferredCanvas.h
+++ b/src/utils/SkDeferredCanvas.h
@@ -14,9 +14,11 @@
class SK_API SkDeferredCanvas : public SkCanvas {
public:
- SkDeferredCanvas(SkCanvas*);
+ SkDeferredCanvas(SkCanvas* = nullptr);
~SkDeferredCanvas() override;
+ void reset(SkCanvas*);
+
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
SkDrawFilter* setDrawFilter(SkDrawFilter*) override;
#endif
@@ -106,7 +108,7 @@ protected:
class Iter;
private:
- SkCanvas* fCanvas;
+ SkCanvas* fCanvas{nullptr};
enum Type {
kSave_Type,
@@ -137,7 +139,7 @@ private:
void push_save();
void push_cliprect(const SkRect&);
bool push_concat(const SkMatrix&);
-
+
void emit(const Rec& rec);
void flush_all();