OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvasPriv.h" | 8 #include "SkCanvasPriv.h" |
9 #include "SkClipStack.h" | 9 #include "SkClipStack.h" |
10 #include "SkDebugCanvas.h" | 10 #include "SkDebugCanvas.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #define SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL "auditTrail" | 26 #define SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL "auditTrail" |
27 | 27 |
28 class DebugPaintFilterCanvas : public SkPaintFilterCanvas { | 28 class DebugPaintFilterCanvas : public SkPaintFilterCanvas { |
29 public: | 29 public: |
30 DebugPaintFilterCanvas(int width, | 30 DebugPaintFilterCanvas(int width, |
31 int height, | 31 int height, |
32 bool overdrawViz, | 32 bool overdrawViz, |
33 bool overrideFilterQuality, | 33 bool overrideFilterQuality, |
34 SkFilterQuality quality) | 34 SkFilterQuality quality) |
35 : INHERITED(width, height) | 35 : INHERITED(width, height) |
36 , fOverdrawXfermode(overdrawViz ? SkOverdrawMode::Create() : nullptr) | 36 , fOverdrawXfermode(overdrawViz ? SkOverdrawMode::Make() : nullptr) |
37 , fOverrideFilterQuality(overrideFilterQuality) | 37 , fOverrideFilterQuality(overrideFilterQuality) |
38 , fFilterQuality(quality) {} | 38 , fFilterQuality(quality) {} |
39 | 39 |
40 protected: | 40 protected: |
41 bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type) const override { | 41 bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type) const override { |
42 if (*paint) { | 42 if (*paint) { |
43 if (nullptr != fOverdrawXfermode.get()) { | 43 if (nullptr != fOverdrawXfermode.get()) { |
44 paint->writable()->setAntiAlias(false); | 44 paint->writable()->setAntiAlias(false); |
45 paint->writable()->setXfermode(fOverdrawXfermode.get()); | 45 paint->writable()->setXfermode(fOverdrawXfermode); |
46 } | 46 } |
47 | 47 |
48 if (fOverrideFilterQuality) { | 48 if (fOverrideFilterQuality) { |
49 paint->writable()->setFilterQuality(fFilterQuality); | 49 paint->writable()->setFilterQuality(fFilterQuality); |
50 } | 50 } |
51 } | 51 } |
52 return true; | 52 return true; |
53 } | 53 } |
54 | 54 |
55 void onDrawPicture(const SkPicture* picture, | 55 void onDrawPicture(const SkPicture* picture, |
56 const SkMatrix* matrix, | 56 const SkMatrix* matrix, |
57 const SkPaint* paint) override { | 57 const SkPaint* paint) override { |
58 // We need to replay the picture onto this canvas in order to filter its
internal paints. | 58 // We need to replay the picture onto this canvas in order to filter its
internal paints. |
59 this->SkCanvas::onDrawPicture(picture, matrix, paint); | 59 this->SkCanvas::onDrawPicture(picture, matrix, paint); |
60 } | 60 } |
61 | 61 |
62 private: | 62 private: |
63 SkAutoTUnref<SkXfermode> fOverdrawXfermode; | 63 sk_sp<SkXfermode> fOverdrawXfermode; |
64 | 64 |
65 bool fOverrideFilterQuality; | 65 bool fOverrideFilterQuality; |
66 SkFilterQuality fFilterQuality; | 66 SkFilterQuality fFilterQuality; |
67 | 67 |
68 typedef SkPaintFilterCanvas INHERITED; | 68 typedef SkPaintFilterCanvas INHERITED; |
69 }; | 69 }; |
70 | 70 |
71 SkDebugCanvas::SkDebugCanvas(int width, int height) | 71 SkDebugCanvas::SkDebugCanvas(int width, int height) |
72 : INHERITED(width, height) | 72 : INHERITED(width, height) |
73 , fPicture(nullptr) | 73 , fPicture(nullptr) |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 } | 802 } |
803 | 803 |
804 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { | 804 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { |
805 if (fCalledAddStackData) { | 805 if (fCalledAddStackData) { |
806 fClipStackData.appendf("<br>"); | 806 fClipStackData.appendf("<br>"); |
807 addPathData(devPath, "pathOut"); | 807 addPathData(devPath, "pathOut"); |
808 return true; | 808 return true; |
809 } | 809 } |
810 return false; | 810 return false; |
811 } | 811 } |
OLD | NEW |