OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 SkBitmapDevice_DEFINED | 9 #ifndef SkBitmapDevice_DEFINED |
10 #define SkBitmapDevice_DEFINED | 10 #define SkBitmapDevice_DEFINED |
(...skipping 17 matching lines...) Expand all Loading... |
28 * valid for the bitmap to have no pixels associated with it. In that case, | 28 * valid for the bitmap to have no pixels associated with it. In that case, |
29 * any drawing to this device will have no effect. | 29 * any drawing to this device will have no effect. |
30 */ | 30 */ |
31 SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& devicePrope
rties); | 31 SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& devicePrope
rties); |
32 static SkBitmapDevice* Create(const SkImageInfo&, const SkDeviceProperties*)
; | 32 static SkBitmapDevice* Create(const SkImageInfo&, const SkDeviceProperties*)
; |
33 public: | 33 public: |
34 static SkBitmapDevice* Create(const SkImageInfo& info) { | 34 static SkBitmapDevice* Create(const SkImageInfo& info) { |
35 return Create(info, NULL); | 35 return Create(info, NULL); |
36 } | 36 } |
37 | 37 |
38 SkImageInfo imageInfo() const SK_OVERRIDE; | 38 SkImageInfo imageInfo() const override; |
39 | 39 |
40 protected: | 40 protected: |
41 bool onShouldDisableLCD(const SkPaint&) const SK_OVERRIDE; | 41 bool onShouldDisableLCD(const SkPaint&) const override; |
42 | 42 |
43 /** These are called inside the per-device-layer loop for each draw call. | 43 /** These are called inside the per-device-layer loop for each draw call. |
44 When these are called, we have already applied any saveLayer operations, | 44 When these are called, we have already applied any saveLayer operations, |
45 and are handling any looping from the paint, and any effects from the | 45 and are handling any looping from the paint, and any effects from the |
46 DrawFilter. | 46 DrawFilter. |
47 */ | 47 */ |
48 void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; | 48 void drawPaint(const SkDraw&, const SkPaint& paint) override; |
49 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, | 49 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, |
50 const SkPoint[], const SkPaint& paint) SK_OVERRIDE; | 50 const SkPoint[], const SkPaint& paint) override; |
51 virtual void drawRect(const SkDraw&, const SkRect& r, | 51 virtual void drawRect(const SkDraw&, const SkRect& r, |
52 const SkPaint& paint) SK_OVERRIDE; | 52 const SkPaint& paint) override; |
53 virtual void drawOval(const SkDraw&, const SkRect& oval, | 53 virtual void drawOval(const SkDraw&, const SkRect& oval, |
54 const SkPaint& paint) SK_OVERRIDE; | 54 const SkPaint& paint) override; |
55 virtual void drawRRect(const SkDraw&, const SkRRect& rr, | 55 virtual void drawRRect(const SkDraw&, const SkRRect& rr, |
56 const SkPaint& paint) SK_OVERRIDE; | 56 const SkPaint& paint) override; |
57 | 57 |
58 /** | 58 /** |
59 * If pathIsMutable, then the implementation is allowed to cast path to a | 59 * If pathIsMutable, then the implementation is allowed to cast path to a |
60 * non-const pointer and modify it in place (as an optimization). Canvas | 60 * non-const pointer and modify it in place (as an optimization). Canvas |
61 * may do this to implement helpers such as drawOval, by placing a temp | 61 * may do this to implement helpers such as drawOval, by placing a temp |
62 * path on the stack to hold the representation of the oval. | 62 * path on the stack to hold the representation of the oval. |
63 * | 63 * |
64 * If prePathMatrix is not null, it should logically be applied before any | 64 * If prePathMatrix is not null, it should logically be applied before any |
65 * stroking or other effects. If there are no effects on the paint that | 65 * stroking or other effects. If there are no effects on the paint that |
66 * affect the geometry/rasterization, then the pre matrix can just be | 66 * affect the geometry/rasterization, then the pre matrix can just be |
67 * pre-concated with the current matrix. | 67 * pre-concated with the current matrix. |
68 */ | 68 */ |
69 virtual void drawPath(const SkDraw&, const SkPath& path, | 69 virtual void drawPath(const SkDraw&, const SkPath& path, |
70 const SkPaint& paint, | 70 const SkPaint& paint, |
71 const SkMatrix* prePathMatrix = NULL, | 71 const SkMatrix* prePathMatrix = NULL, |
72 bool pathIsMutable = false) SK_OVERRIDE; | 72 bool pathIsMutable = false) override; |
73 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, | 73 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, |
74 const SkMatrix& matrix, const SkPaint& paint) SK_OVE
RRIDE; | 74 const SkMatrix& matrix, const SkPaint& paint) overri
de; |
75 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, | 75 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, |
76 int x, int y, const SkPaint& paint) SK_OVERRIDE; | 76 int x, int y, const SkPaint& paint) override; |
77 | 77 |
78 /** | 78 /** |
79 * The default impl. will create a bitmap-shader from the bitmap, | 79 * The default impl. will create a bitmap-shader from the bitmap, |
80 * and call drawRect with it. | 80 * and call drawRect with it. |
81 */ | 81 */ |
82 virtual void drawBitmapRect(const SkDraw&, const SkBitmap&, | 82 virtual void drawBitmapRect(const SkDraw&, const SkBitmap&, |
83 const SkRect* srcOrNull, const SkRect& dst, | 83 const SkRect* srcOrNull, const SkRect& dst, |
84 const SkPaint& paint, | 84 const SkPaint& paint, |
85 SkCanvas::DrawBitmapRectFlags flags) SK_OVERRIDE
; | 85 SkCanvas::DrawBitmapRectFlags flags) override; |
86 | 86 |
87 /** | 87 /** |
88 * Does not handle text decoration. | 88 * Does not handle text decoration. |
89 * Decorations (underline and stike-thru) will be handled by SkCanvas. | 89 * Decorations (underline and stike-thru) will be handled by SkCanvas. |
90 */ | 90 */ |
91 virtual void drawText(const SkDraw&, const void* text, size_t len, | 91 virtual void drawText(const SkDraw&, const void* text, size_t len, |
92 SkScalar x, SkScalar y, const SkPaint& paint) SK_OVERR
IDE; | 92 SkScalar x, SkScalar y, const SkPaint& paint) override
; |
93 virtual void drawPosText(const SkDraw&, const void* text, size_t len, | 93 virtual void drawPosText(const SkDraw&, const void* text, size_t len, |
94 const SkScalar pos[], int scalarsPerPos, | 94 const SkScalar pos[], int scalarsPerPos, |
95 const SkPoint& offset, const SkPaint& paint) SK_OVE
RRIDE; | 95 const SkPoint& offset, const SkPaint& paint) overri
de; |
96 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCou
nt, | 96 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCou
nt, |
97 const SkPoint verts[], const SkPoint texs[], | 97 const SkPoint verts[], const SkPoint texs[], |
98 const SkColor colors[], SkXfermode* xmode, | 98 const SkColor colors[], SkXfermode* xmode, |
99 const uint16_t indices[], int indexCount, | 99 const uint16_t indices[], int indexCount, |
100 const SkPaint& paint) SK_OVERRIDE; | 100 const SkPaint& paint) override; |
101 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, const Sk
Paint&) SK_OVERRIDE; | 101 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, const Sk
Paint&) override; |
102 | 102 |
103 /////////////////////////////////////////////////////////////////////////// | 103 /////////////////////////////////////////////////////////////////////////// |
104 | 104 |
105 /** Update as needed the pixel value in the bitmap, so that the caller can | 105 /** Update as needed the pixel value in the bitmap, so that the caller can |
106 access the pixels directly. Note: only the pixels field should be | 106 access the pixels directly. Note: only the pixels field should be |
107 altered. The config/width/height/rowbytes must remain unchanged. | 107 altered. The config/width/height/rowbytes must remain unchanged. |
108 @return the device contents as a bitmap | 108 @return the device contents as a bitmap |
109 */ | 109 */ |
110 const SkBitmap& onAccessBitmap() SK_OVERRIDE; | 110 const SkBitmap& onAccessBitmap() override; |
111 | 111 |
112 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } | 112 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } |
113 // just for subclasses, to assign a custom pixelref | 113 // just for subclasses, to assign a custom pixelref |
114 SkPixelRef* setPixelRef(SkPixelRef* pr) { | 114 SkPixelRef* setPixelRef(SkPixelRef* pr) { |
115 fBitmap.setPixelRef(pr); | 115 fBitmap.setPixelRef(pr); |
116 return pr; | 116 return pr; |
117 } | 117 } |
118 | 118 |
119 bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) SK_OVERRI
DE; | 119 bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) override; |
120 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) SK_OVE
RRIDE; | 120 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) overri
de; |
121 void* onAccessPixels(SkImageInfo* info, size_t* rowBytes) SK_OVERRIDE; | 121 void* onAccessPixels(SkImageInfo* info, size_t* rowBytes) override; |
122 | 122 |
123 /** Called when this device is installed into a Canvas. Balanced by a call | 123 /** Called when this device is installed into a Canvas. Balanced by a call |
124 to unlockPixels() when the device is removed from a Canvas. | 124 to unlockPixels() when the device is removed from a Canvas. |
125 */ | 125 */ |
126 void lockPixels() SK_OVERRIDE; | 126 void lockPixels() override; |
127 void unlockPixels() SK_OVERRIDE; | 127 void unlockPixels() override; |
128 | 128 |
129 private: | 129 private: |
130 friend class SkCanvas; | 130 friend class SkCanvas; |
131 friend struct DeviceCM; //for setMatrixClip | 131 friend struct DeviceCM; //for setMatrixClip |
132 friend class SkDraw; | 132 friend class SkDraw; |
133 friend class SkDrawIter; | 133 friend class SkDrawIter; |
134 friend class SkDeviceFilteredPaint; | 134 friend class SkDeviceFilteredPaint; |
135 friend class SkDeviceImageFilterProxy; | 135 friend class SkDeviceImageFilterProxy; |
136 | 136 |
137 friend class SkSurface_Raster; | 137 friend class SkSurface_Raster; |
138 | 138 |
139 // used to change the backend's pixels (and possibly config/rowbytes) | 139 // used to change the backend's pixels (and possibly config/rowbytes) |
140 // but cannot change the width/height, so there should be no change to | 140 // but cannot change the width/height, so there should be no change to |
141 // any clip information. | 141 // any clip information. |
142 void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRIDE; | 142 void replaceBitmapBackendForRasterSurface(const SkBitmap&) override; |
143 | 143 |
144 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) SK_OVERRIDE; | 144 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
145 | 145 |
146 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE
; | 146 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override; |
147 const void* peekPixels(SkImageInfo*, size_t* rowBytes) SK_OVERRIDE; | 147 const void* peekPixels(SkImageInfo*, size_t* rowBytes) override; |
148 | 148 |
149 SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE; | 149 SkImageFilter::Cache* getImageFilterCache() override; |
150 | 150 |
151 SkBitmap fBitmap; | 151 SkBitmap fBitmap; |
152 | 152 |
153 typedef SkBaseDevice INHERITED; | 153 typedef SkBaseDevice INHERITED; |
154 }; | 154 }; |
155 | 155 |
156 #endif // SkBitmapDevice_DEFINED | 156 #endif // SkBitmapDevice_DEFINED |
OLD | NEW |