Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2015 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #include "SkPaintFilterCanvas.h" | |
| 9 | |
| 10 #include "SkPaint.h" | |
| 11 #include "SkTLazy.h" | |
| 12 | |
| 13 class SkPaintFilterCanvas::AutoPaintFilter { | |
| 14 public: | |
| 15 AutoPaintFilter(const SkPaintFilterCanvas* canvas, Type type, const SkPaint* paint) { | |
| 16 if (paint) { | |
| 17 canvas->filterPaint(fLazyPaint.set(*paint), type); | |
| 18 } | |
| 19 } | |
| 20 | |
|
robertphillips
2015/03/25 15:07:06
"const SkPaint&" ?
f(malita)
2015/03/25 15:29:22
Done.
| |
| 21 AutoPaintFilter(const SkPaintFilterCanvas* canvas, Type type, const SkPaint paint) { | |
| 22 canvas->filterPaint(fLazyPaint.set(paint), type); | |
| 23 } | |
| 24 | |
| 25 const SkPaint* paint() const { return fLazyPaint.getMaybeNull(); } | |
| 26 | |
| 27 private: | |
| 28 SkTLazy<SkPaint> fLazyPaint; | |
| 29 }; | |
| 30 | |
| 31 SkPaintFilterCanvas::SkPaintFilterCanvas(int width, int height) | |
|
robertphillips
2015/03/25 15:07:06
one line ?
f(malita)
2015/03/25 15:29:22
Done.
| |
| 32 : INHERITED(width, height) { } | |
| 33 | |
| 34 void SkPaintFilterCanvas::onDrawPaint(const SkPaint& paint) { | |
| 35 AutoPaintFilter apf(this, kPaint_Type, paint); | |
| 36 this->INHERITED::onDrawPaint(*apf.paint()); | |
| 37 } | |
| 38 | |
| 39 void SkPaintFilterCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoi nt pts[], | |
| 40 const SkPaint& paint) { | |
| 41 AutoPaintFilter apf(this, kPoint_Type, paint); | |
| 42 this->INHERITED::onDrawPoints(mode, count, pts, *apf.paint()); | |
| 43 } | |
| 44 | |
| 45 void SkPaintFilterCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { | |
| 46 AutoPaintFilter apf(this, kRect_Type, paint); | |
| 47 this->INHERITED::onDrawRect(rect, *apf.paint()); | |
| 48 } | |
| 49 | |
| 50 void SkPaintFilterCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint ) { | |
| 51 AutoPaintFilter apf(this, kRRect_Type, paint); | |
| 52 this->INHERITED::onDrawRRect(rrect, *apf.paint()); | |
| 53 } | |
| 54 | |
| 55 void SkPaintFilterCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inne r, | |
| 56 const SkPaint& paint) { | |
|
robertphillips
2015/03/25 15:07:06
Add kDRRect_Type ?
f(malita)
2015/03/25 15:29:23
It's a bit unclear to me how useful these types ar
| |
| 57 AutoPaintFilter apf(this, kRRect_Type, paint); | |
| 58 this->INHERITED::onDrawDRRect(outer, inner, *apf.paint()); | |
| 59 } | |
| 60 | |
| 61 void SkPaintFilterCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) { | |
| 62 AutoPaintFilter apf(this, kOval_Type, paint); | |
| 63 this->INHERITED::onDrawOval(rect, *apf.paint()); | |
| 64 } | |
| 65 | |
| 66 void SkPaintFilterCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { | |
| 67 AutoPaintFilter apf(this, kPath_Type, paint); | |
| 68 this->INHERITED::onDrawPath(path, *apf.paint()); | |
| 69 } | |
| 70 | |
| 71 void SkPaintFilterCanvas::onDrawBitmap(const SkBitmap& bm, SkScalar left, SkScal ar top, | |
| 72 const SkPaint* paint) { | |
| 73 AutoPaintFilter apf(this, kBitmap_Type, paint); | |
| 74 this->INHERITED::onDrawBitmap(bm, left, top, apf.paint()); | |
| 75 } | |
| 76 | |
| 77 void SkPaintFilterCanvas::onDrawBitmapRect(const SkBitmap& bm, const SkRect* src , const SkRect& dst, | |
| 78 const SkPaint* paint, DrawBitmapRectF lags flags) { | |
| 79 AutoPaintFilter apf(this, kBitmap_Type, paint); | |
| 80 this->INHERITED::onDrawBitmapRect(bm, src, dst, apf.paint(), flags); | |
| 81 } | |
| 82 | |
| 83 void SkPaintFilterCanvas::onDrawImage(const SkImage* image, SkScalar left, SkSca lar top, | |
| 84 const SkPaint* paint) { | |
| 85 AutoPaintFilter apf(this, kBitmap_Type, paint); | |
| 86 this->INHERITED::onDrawImage(image, left, top, apf.paint()); | |
| 87 } | |
| 88 | |
| 89 void SkPaintFilterCanvas::onDrawImageRect(const SkImage* image, const SkRect* sr c, | |
| 90 const SkRect& dst, const SkPaint* pain t) { | |
| 91 AutoPaintFilter apf(this, kBitmap_Type, paint); | |
| 92 this->INHERITED::onDrawImageRect(image, src, dst, apf.paint()); | |
| 93 } | |
| 94 | |
| 95 void SkPaintFilterCanvas::onDrawBitmapNine(const SkBitmap& bm, const SkIRect& ce nter, | |
| 96 const SkRect& dst, const SkPaint* pai nt) { | |
| 97 AutoPaintFilter apf(this, kBitmap_Type, paint); | |
| 98 this->INHERITED::onDrawBitmapNine(bm, center, dst, apf.paint()); | |
| 99 } | |
| 100 | |
| 101 void SkPaintFilterCanvas::onDrawSprite(const SkBitmap& bm, int left, int top, | |
| 102 const SkPaint* paint) { | |
| 103 AutoPaintFilter apf(this, kBitmap_Type, paint); | |
| 104 this->INHERITED::onDrawSprite(bm, left, top, apf.paint()); | |
| 105 } | |
| 106 | |
| 107 void SkPaintFilterCanvas::onDrawVertices(VertexMode vmode, int vertexCount, | |
| 108 const SkPoint vertices[], const SkPoint texs[], | |
| 109 const SkColor colors[], SkXfermode* xmo de, | |
| 110 const uint16_t indices[], int indexCoun t, | |
| 111 const SkPaint& paint) { | |
|
robertphillips
2015/03/25 15:07:06
Add kVertices_Type ?
f(malita)
2015/03/25 15:29:23
Done.
| |
| 112 AutoPaintFilter apf(this, kPath_Type, paint); | |
| 113 this->INHERITED::onDrawVertices(vmode, vertexCount, vertices, texs, colors, xmode, indices, | |
| 114 indexCount, *apf.paint()); | |
| 115 } | |
| 116 | |
| 117 void SkPaintFilterCanvas::onDrawPatch(const SkPoint cubics[], const SkColor colo rs[], | |
| 118 const SkPoint texCoords[], SkXfermode* xmo de, | |
| 119 const SkPaint& paint) { | |
|
robertphillips
2015/03/25 15:07:06
Add kPatch_Type ?
f(malita)
2015/03/25 15:29:23
Done.
| |
| 120 AutoPaintFilter apf(this, kPath_Type, paint); | |
| 121 this->INHERITED::onDrawPatch(cubics, colors, texCoords, xmode, *apf.paint()) ; | |
| 122 } | |
| 123 | |
| 124 void SkPaintFilterCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix * m, | |
| 125 const SkPaint* paint) { | |
| 126 AutoPaintFilter apf(this, kPicture_Type, paint); | |
| 127 this->INHERITED::onDrawPicture(picture, m, apf.paint()); | |
| 128 } | |
| 129 | |
| 130 void SkPaintFilterCanvas::onDrawText(const void* text, size_t byteLength, SkScal ar x, SkScalar y, | |
| 131 const SkPaint& paint) { | |
| 132 AutoPaintFilter apf(this, kText_Type, paint); | |
| 133 this->INHERITED::onDrawText(text, byteLength, x, y, *apf.paint()); | |
| 134 } | |
| 135 | |
| 136 void SkPaintFilterCanvas::onDrawPosText(const void* text, size_t byteLength, con st SkPoint pos[], | |
| 137 const SkPaint& paint) { | |
| 138 AutoPaintFilter apf(this, kText_Type, paint); | |
| 139 this->INHERITED::onDrawPosText(text, byteLength, pos, *apf.paint()); | |
| 140 } | |
| 141 | |
| 142 void SkPaintFilterCanvas::onDrawPosTextH(const void* text, size_t byteLength, co nst SkScalar xpos[], | |
| 143 SkScalar constY, const SkPaint& paint) { | |
| 144 AutoPaintFilter apf(this, kText_Type, paint); | |
| 145 this->INHERITED::onDrawPosTextH(text, byteLength, xpos, constY, *apf.paint() ); | |
| 146 } | |
| 147 | |
| 148 void SkPaintFilterCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, | |
| 149 const SkMatrix* matrix, const SkPaint & paint) { | |
| 150 AutoPaintFilter apf(this, kText_Type, paint); | |
| 151 this->INHERITED::onDrawTextOnPath(text, byteLength, path, matrix, *apf.paint ()); | |
| 152 } | |
| 153 | |
| 154 void SkPaintFilterCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkS calar y, | |
| 155 const SkPaint& paint) { | |
| 156 AutoPaintFilter apf(this, kTextBlob_Type, paint); | |
| 157 this->INHERITED::onDrawTextBlob(blob, x, y, *apf.paint()); | |
| 158 } | |
| OLD | NEW |