Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2016 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef SkNWayCanvas_DEFINED | 9 #ifndef SkDeferredCanvas_DEFINED |
| 10 #define SkNWayCanvas_DEFINED | 10 #define SkDeferredCanvas_DEFINED |
| 11 | 11 |
| 12 #include "../private/SkTDArray.h" | 12 #include "../private/SkTDArray.h" |
| 13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
| 14 | 14 |
| 15 class SK_API SkNWayCanvas : public SkCanvas { | 15 class SK_API SkDeferredCanvas : public SkCanvas { |
| 16 public: | 16 public: |
| 17 SkNWayCanvas(int width, int height); | 17 SkDeferredCanvas(SkCanvas*); |
| 18 virtual ~SkNWayCanvas(); | 18 ~SkDeferredCanvas() override; |
| 19 | |
| 20 virtual void addCanvas(SkCanvas*); | |
| 21 virtual void removeCanvas(SkCanvas*); | |
| 22 virtual void removeAll(); | |
| 23 | |
| 24 /////////////////////////////////////////////////////////////////////////// | |
| 25 // These are forwarded to the N canvases we're referencing | |
| 26 | 19 |
| 27 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER | 20 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER |
| 28 SkDrawFilter* setDrawFilter(SkDrawFilter*) override; | 21 SkDrawFilter* setDrawFilter(SkDrawFilter*) override; |
| 29 #endif | 22 #endif |
| 30 | 23 |
| 31 protected: | 24 protected: |
| 32 SkTDArray<SkCanvas*> fList; | 25 sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) ove rride; |
| 26 SkISize getBaseLayerSize() const override; | |
| 27 bool getClipBounds(SkRect* bounds) const override; | |
| 28 bool getClipDeviceBounds(SkIRect* bounds) const override; | |
| 29 bool isClipEmpty() const override; | |
| 30 bool isClipRect() const override; | |
| 31 bool onPeekPixels(SkPixmap*) override; | |
| 32 bool onAccessTopLayerPixels(SkPixmap*) override; | |
| 33 SkImageInfo onImageInfo() const override; | |
| 34 bool onGetProps(SkSurfaceProps*) const override; | |
| 35 void onFlush() override; | |
| 36 // SkCanvas* canvasForDrawIter() override; | |
| 33 | 37 |
| 34 void willSave() override; | 38 void willSave() override; |
| 35 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; | 39 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; |
| 36 void willRestore() override; | 40 void willRestore() override; |
| 37 | 41 |
| 38 void didConcat(const SkMatrix&) override; | 42 void didConcat(const SkMatrix&) override; |
| 39 void didSetMatrix(const SkMatrix&) override; | 43 void didSetMatrix(const SkMatrix&) override; |
| 40 | 44 |
| 41 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; | 45 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; |
| 42 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkS calar y, | 46 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkS calar y, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 60 void onDrawRRect(const SkRRect&, const SkPaint&) override; | 64 void onDrawRRect(const SkRRect&, const SkPaint&) override; |
| 61 void onDrawPath(const SkPath&, const SkPaint&) override; | 65 void onDrawPath(const SkPath&, const SkPaint&) override; |
| 62 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPain t*) override; | 66 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPain t*) override; |
| 63 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, | 67 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, |
| 64 SrcRectConstraint) override; | 68 SrcRectConstraint) override; |
| 65 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint* ) override; | 69 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint* ) override; |
| 66 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, | 70 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, |
| 67 const SkPaint*, SrcRectConstraint) override; | 71 const SkPaint*, SrcRectConstraint) override; |
| 68 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, | 72 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, |
| 69 const SkPaint*) override; | 73 const SkPaint*) override; |
| 74 void onDrawImageNine(const SkImage* image, const SkIRect& center, | |
| 75 const SkRect& dst, const SkPaint*) override; | |
| 70 void onDrawVertices(VertexMode vmode, int vertexCount, | 76 void onDrawVertices(VertexMode vmode, int vertexCount, |
| 71 const SkPoint vertices[], const SkPoint texs[], | 77 const SkPoint vertices[], const SkPoint texs[], |
| 72 const SkColor colors[], SkXfermode* xmode, | 78 const SkColor colors[], SkXfermode* xmode, |
| 73 const uint16_t indices[], int indexCount, | 79 const uint16_t indices[], int indexCount, |
| 74 const SkPaint&) override; | 80 const SkPaint&) override; |
| 81 void onDrawAtlas(const SkImage* image, const SkRSXform xform[], | |
| 82 const SkRect rects[], const SkColor colors[], | |
| 83 int count, SkXfermode::Mode mode, | |
| 84 const SkRect* cull, const SkPaint* paint) override; | |
| 75 | 85 |
| 76 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; | 86 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; |
| 77 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; | 87 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; |
| 78 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; | 88 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; |
| 79 void onClipRegion(const SkRegion&, SkRegion::Op) override; | 89 void onClipRegion(const SkRegion&, SkRegion::Op) override; |
| 80 | 90 |
| 91 void onDrawDrawable(SkDrawable*, const SkMatrix*) override; | |
| 81 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri de; | 92 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri de; |
| 82 void onDrawAnnotation(const SkRect&, const char[], SkData*) override; | 93 void onDrawAnnotation(const SkRect&, const char[], SkData*) override; |
| 83 | 94 |
| 84 class Iter; | 95 class Iter; |
| 85 | 96 |
| 86 private: | 97 private: |
| 98 SkCanvas* fCanvas; | |
| 99 | |
| 100 enum Type { | |
| 101 kSave_Type, | |
| 102 kClipRect_Type, | |
| 103 kTrans_Type, | |
| 104 kScaleTrans_Type, | |
| 105 }; | |
| 106 struct Rec { | |
| 107 Type fType; | |
| 108 union { | |
| 109 int fSaveCount; | |
| 110 SkRect fBounds; | |
| 111 SkVector fTranslate; | |
| 112 struct { | |
| 113 SkVector fScale; | |
| 114 SkVector fTrans; // post translate | |
| 115 } fScaleTrans; | |
| 116 } fData; | |
| 117 | |
| 118 bool isConcat(SkMatrix*) const; | |
| 119 void getConcat(SkMatrix* mat) const { | |
| 120 SkDEBUGCODE(bool isconcat = ) this->isConcat(mat); | |
| 121 SkASSERT(isconcat); | |
|
f(malita)
2016/07/07 15:24:07
Nit: SkAssertResult?
| |
| 122 } | |
| 123 void setConcat(const SkMatrix&); | |
| 124 }; | |
| 125 SkTDArray<Rec> fRecs; | |
| 126 int fSaveCount; | |
| 127 | |
| 128 void push_save(); | |
| 129 void push_cliprect(const SkRect&); | |
| 130 bool push_concat(const SkMatrix&); | |
| 131 | |
| 132 void emit(const Rec& rec); | |
| 133 | |
| 134 void flush_all(); | |
| 135 void flush_before_saves(); | |
| 136 void flush_le(int index); | |
| 137 void flush_translate(SkScalar* x, SkScalar* y, const SkPaint&); | |
| 138 void flush_translate(SkScalar* x, SkScalar* y, const SkRect& bounds, const S kPaint* = nullptr); | |
| 139 void flush_check(SkRect* bounds, const SkPaint*, unsigned flags = 0); | |
| 140 | |
| 141 void internal_flush_translate(SkScalar* x, SkScalar* y, const SkRect* bounds OrNull); | |
| 142 | |
| 87 typedef SkCanvas INHERITED; | 143 typedef SkCanvas INHERITED; |
| 88 }; | 144 }; |
| 89 | 145 |
| 90 | 146 |
| 91 #endif | 147 #endif |
| OLD | NEW |