Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: src/utils/SkPaintFilterCanvas.cpp

Issue 1302173002: [M45] SkPaintFilterCanvas should inherit the target canvas state (Closed) Base URL: https://chromium.googlesource.com/skia.git@m45
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/utils/SkPaintFilterCanvas.h ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPaintFilterCanvas.h" 8 #include "SkPaintFilterCanvas.h"
9 9
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 12 matching lines...) Expand all
23 } 23 }
24 24
25 const SkPaint* paint() const { return fLazyPaint.getMaybeNull(); } 25 const SkPaint* paint() const { return fLazyPaint.getMaybeNull(); }
26 26
27 private: 27 private:
28 SkTLazy<SkPaint> fLazyPaint; 28 SkTLazy<SkPaint> fLazyPaint;
29 }; 29 };
30 30
31 SkPaintFilterCanvas::SkPaintFilterCanvas(int width, int height) : INHERITED(widt h, height) { } 31 SkPaintFilterCanvas::SkPaintFilterCanvas(int width, int height) : INHERITED(widt h, height) { }
32 32
33 SkPaintFilterCanvas::SkPaintFilterCanvas(SkCanvas *canvas)
34 : INHERITED(canvas->imageInfo().width(), canvas->imageInfo().height()) {
35
36 // Transfer matrix & clip state before adding the target canvas.
37 SkIRect devClip;
38 canvas->getClipDeviceBounds(&devClip);
39 this->clipRect(SkRect::Make(devClip));
40 this->setMatrix(canvas->getTotalMatrix());
41
42 this->addCanvas(canvas);
43 }
44
33 void SkPaintFilterCanvas::onDrawPaint(const SkPaint& paint) { 45 void SkPaintFilterCanvas::onDrawPaint(const SkPaint& paint) {
34 AutoPaintFilter apf(this, kPaint_Type, paint); 46 AutoPaintFilter apf(this, kPaint_Type, paint);
35 this->INHERITED::onDrawPaint(*apf.paint()); 47 this->INHERITED::onDrawPaint(*apf.paint());
36 } 48 }
37 49
38 void SkPaintFilterCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoi nt pts[], 50 void SkPaintFilterCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoi nt pts[],
39 const SkPaint& paint) { 51 const SkPaint& paint) {
40 AutoPaintFilter apf(this, kPoint_Type, paint); 52 AutoPaintFilter apf(this, kPoint_Type, paint);
41 this->INHERITED::onDrawPoints(mode, count, pts, *apf.paint()); 53 this->INHERITED::onDrawPoints(mode, count, pts, *apf.paint());
42 } 54 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 const SkMatrix* matrix, const SkPaint & paint) { 160 const SkMatrix* matrix, const SkPaint & paint) {
149 AutoPaintFilter apf(this, kText_Type, paint); 161 AutoPaintFilter apf(this, kText_Type, paint);
150 this->INHERITED::onDrawTextOnPath(text, byteLength, path, matrix, *apf.paint ()); 162 this->INHERITED::onDrawTextOnPath(text, byteLength, path, matrix, *apf.paint ());
151 } 163 }
152 164
153 void SkPaintFilterCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkS calar y, 165 void SkPaintFilterCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkS calar y,
154 const SkPaint& paint) { 166 const SkPaint& paint) {
155 AutoPaintFilter apf(this, kTextBlob_Type, paint); 167 AutoPaintFilter apf(this, kTextBlob_Type, paint);
156 this->INHERITED::onDrawTextBlob(blob, x, y, *apf.paint()); 168 this->INHERITED::onDrawTextBlob(blob, x, y, *apf.paint());
157 } 169 }
OLDNEW
« no previous file with comments | « include/utils/SkPaintFilterCanvas.h ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698