Chromium Code Reviews| Index: src/utils/SkDeferredCanvas.h |
| diff --git a/include/utils/SkNWayCanvas.h b/src/utils/SkDeferredCanvas.h |
| similarity index 57% |
| copy from include/utils/SkNWayCanvas.h |
| copy to src/utils/SkDeferredCanvas.h |
| index f2a99db8027db9232d896838b5a6552ae1f88460..7ca9616529b79e59b13be3e514c965b811d48642 100644 |
| --- a/include/utils/SkNWayCanvas.h |
| +++ b/src/utils/SkDeferredCanvas.h |
| @@ -1,35 +1,39 @@ |
| /* |
| - * Copyright 2011 Google Inc. |
| + * Copyright 2016 Google Inc. |
| * |
| * Use of this source code is governed by a BSD-style license that can be |
| * found in the LICENSE file. |
| */ |
| -#ifndef SkNWayCanvas_DEFINED |
| -#define SkNWayCanvas_DEFINED |
| +#ifndef SkDeferredCanvas_DEFINED |
| +#define SkDeferredCanvas_DEFINED |
| #include "../private/SkTDArray.h" |
| #include "SkCanvas.h" |
| -class SK_API SkNWayCanvas : public SkCanvas { |
| +class SK_API SkDeferredCanvas : public SkCanvas { |
| public: |
| - SkNWayCanvas(int width, int height); |
| - virtual ~SkNWayCanvas(); |
| - |
| - virtual void addCanvas(SkCanvas*); |
| - virtual void removeCanvas(SkCanvas*); |
| - virtual void removeAll(); |
| - |
| - /////////////////////////////////////////////////////////////////////////// |
| - // These are forwarded to the N canvases we're referencing |
| + SkDeferredCanvas(SkCanvas*); |
| + ~SkDeferredCanvas() override; |
| #ifdef SK_SUPPORT_LEGACY_DRAWFILTER |
| SkDrawFilter* setDrawFilter(SkDrawFilter*) override; |
| #endif |
| protected: |
| - SkTDArray<SkCanvas*> fList; |
| + sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override; |
| + SkISize getBaseLayerSize() const override; |
| + bool getClipBounds(SkRect* bounds) const override; |
| + bool getClipDeviceBounds(SkIRect* bounds) const override; |
| + bool isClipEmpty() const override; |
| + bool isClipRect() const override; |
| + bool onPeekPixels(SkPixmap*) override; |
| + bool onAccessTopLayerPixels(SkPixmap*) override; |
| + SkImageInfo onImageInfo() const override; |
| + bool onGetProps(SkSurfaceProps*) const override; |
| + void onFlush() override; |
| +// SkCanvas* canvasForDrawIter() override; |
| void willSave() override; |
| SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; |
| @@ -67,23 +71,75 @@ protected: |
| const SkPaint*, SrcRectConstraint) override; |
| void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, |
| const SkPaint*) override; |
| + void onDrawImageNine(const SkImage* image, const SkIRect& center, |
| + const SkRect& dst, const SkPaint*) override; |
| void onDrawVertices(VertexMode vmode, int vertexCount, |
| const SkPoint vertices[], const SkPoint texs[], |
| const SkColor colors[], SkXfermode* xmode, |
| const uint16_t indices[], int indexCount, |
| const SkPaint&) override; |
| + void onDrawAtlas(const SkImage* image, const SkRSXform xform[], |
| + const SkRect rects[], const SkColor colors[], |
| + int count, SkXfermode::Mode mode, |
| + const SkRect* cull, const SkPaint* paint) override; |
| void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; |
| void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; |
| void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; |
| void onClipRegion(const SkRegion&, SkRegion::Op) override; |
| + void onDrawDrawable(SkDrawable*, const SkMatrix*) override; |
| void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override; |
| void onDrawAnnotation(const SkRect&, const char[], SkData*) override; |
| class Iter; |
| private: |
| + SkCanvas* fCanvas; |
| + |
| + enum Type { |
| + kSave_Type, |
| + kClipRect_Type, |
| + kTrans_Type, |
| + kScaleTrans_Type, |
| + }; |
| + struct Rec { |
| + Type fType; |
| + union { |
| + int fSaveCount; |
| + SkRect fBounds; |
| + SkVector fTranslate; |
| + struct { |
| + SkVector fScale; |
| + SkVector fTrans; // post translate |
| + } fScaleTrans; |
| + } fData; |
| + |
| + bool isConcat(SkMatrix*) const; |
| + void getConcat(SkMatrix* mat) const { |
| + SkDEBUGCODE(bool isconcat = ) this->isConcat(mat); |
| + SkASSERT(isconcat); |
|
f(malita)
2016/07/07 15:24:07
Nit: SkAssertResult?
|
| + } |
| + void setConcat(const SkMatrix&); |
| + }; |
| + SkTDArray<Rec> fRecs; |
| + int fSaveCount; |
| + |
| + void push_save(); |
| + void push_cliprect(const SkRect&); |
| + bool push_concat(const SkMatrix&); |
| + |
| + void emit(const Rec& rec); |
| + |
| + void flush_all(); |
| + void flush_before_saves(); |
| + void flush_le(int index); |
| + void flush_translate(SkScalar* x, SkScalar* y, const SkPaint&); |
| + void flush_translate(SkScalar* x, SkScalar* y, const SkRect& bounds, const SkPaint* = nullptr); |
| + void flush_check(SkRect* bounds, const SkPaint*, unsigned flags = 0); |
| + |
| + void internal_flush_translate(SkScalar* x, SkScalar* y, const SkRect* boundsOrNull); |
| + |
| typedef SkCanvas INHERITED; |
| }; |