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 #include "SkDeferredCanvas.h" | 9 #include "SkDeferredCanvas.h" |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 //----------------------------------------------------------------------------- | 59 //----------------------------------------------------------------------------- |
60 // DeferredPipeController | 60 // DeferredPipeController |
61 //----------------------------------------------------------------------------- | 61 //----------------------------------------------------------------------------- |
62 | 62 |
63 class DeferredPipeController : public SkGPipeController { | 63 class DeferredPipeController : public SkGPipeController { |
64 public: | 64 public: |
65 DeferredPipeController(); | 65 DeferredPipeController(); |
66 void setPlaybackCanvas(SkCanvas*); | 66 void setPlaybackCanvas(SkCanvas*); |
67 virtual ~DeferredPipeController(); | 67 virtual ~DeferredPipeController(); |
68 virtual void* requestBlock(size_t minRequest, size_t* actual) SK_OVERRIDE; | 68 void* requestBlock(size_t minRequest, size_t* actual) SK_OVERRIDE; |
69 virtual void notifyWritten(size_t bytes) SK_OVERRIDE; | 69 void notifyWritten(size_t bytes) SK_OVERRIDE; |
70 void playback(bool silent); | 70 void playback(bool silent); |
71 bool hasPendingCommands() const { return fAllocator.blockCount() != 0; } | 71 bool hasPendingCommands() const { return fAllocator.blockCount() != 0; } |
72 size_t storageAllocatedForRecording() const { return fAllocator.totalCapacit
y(); } | 72 size_t storageAllocatedForRecording() const { return fAllocator.totalCapacit
y(); } |
73 private: | 73 private: |
74 enum { | 74 enum { |
75 kMinBlockSize = 4096 | 75 kMinBlockSize = 4096 |
76 }; | 76 }; |
77 struct PipeBlock { | 77 struct PipeBlock { |
78 PipeBlock(void* block, size_t size) { fBlock = block, fSize = size; } | 78 PipeBlock(void* block, size_t size) { fBlock = block, fSize = size; } |
79 void* fBlock; | 79 void* fBlock; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 bool isFreshFrame(); | 151 bool isFreshFrame(); |
152 bool hasPendingCommands(); | 152 bool hasPendingCommands(); |
153 size_t storageAllocatedForRecording() const; | 153 size_t storageAllocatedForRecording() const; |
154 size_t freeMemoryIfPossible(size_t bytesToFree); | 154 size_t freeMemoryIfPossible(size_t bytesToFree); |
155 void flushPendingCommands(PlaybackMode); | 155 void flushPendingCommands(PlaybackMode); |
156 void skipPendingCommands(); | 156 void skipPendingCommands(); |
157 void setMaxRecordingStorage(size_t); | 157 void setMaxRecordingStorage(size_t); |
158 void recordedDrawCommand(); | 158 void recordedDrawCommand(); |
159 void setIsDrawingToLayer(bool value) {fIsDrawingToLayer = value;} | 159 void setIsDrawingToLayer(bool value) {fIsDrawingToLayer = value;} |
160 | 160 |
161 virtual SkImageInfo imageInfo() const SK_OVERRIDE; | 161 SkImageInfo imageInfo() const SK_OVERRIDE; |
162 | 162 |
163 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 163 GrRenderTarget* accessRenderTarget() SK_OVERRIDE; |
164 | 164 |
165 virtual SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRID
E; | 165 SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE; |
166 | 166 |
167 virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_
OVERRIDE; | 167 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE
; |
168 | 168 |
169 protected: | 169 protected: |
170 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; | 170 const SkBitmap& onAccessBitmap() SK_OVERRIDE; |
171 virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) S
K_OVERRIDE; | 171 bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) SK_OVERRI
DE; |
172 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, i
nt y) SK_OVERRIDE; | 172 bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, int y) SK
_OVERRIDE; |
173 | 173 |
174 // None of the following drawing methods should ever get called on the | 174 // None of the following drawing methods should ever get called on the |
175 // deferred device | 175 // deferred device |
176 virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE | 176 void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE |
177 {SkASSERT(0);} | 177 {SkASSERT(0);} |
178 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, | 178 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, |
179 size_t count, const SkPoint[], | 179 size_t count, const SkPoint[], |
180 const SkPaint& paint) SK_OVERRIDE | 180 const SkPaint& paint) SK_OVERRIDE |
181 {SkASSERT(0);} | 181 {SkASSERT(0);} |
182 virtual void drawRect(const SkDraw&, const SkRect& r, | 182 virtual void drawRect(const SkDraw&, const SkRect& r, |
183 const SkPaint& paint) SK_OVERRIDE | 183 const SkPaint& paint) SK_OVERRIDE |
184 {SkASSERT(0);} | 184 {SkASSERT(0);} |
185 virtual void drawOval(const SkDraw&, const SkRect&, const SkPaint&) SK_OVERR
IDE | 185 void drawOval(const SkDraw&, const SkRect&, const SkPaint&) SK_OVERRIDE |
186 {SkASSERT(0);} | 186 {SkASSERT(0);} |
187 virtual void drawRRect(const SkDraw&, const SkRRect& rr, | 187 virtual void drawRRect(const SkDraw&, const SkRRect& rr, |
188 const SkPaint& paint) SK_OVERRIDE | 188 const SkPaint& paint) SK_OVERRIDE |
189 {SkASSERT(0);} | 189 {SkASSERT(0);} |
190 virtual void drawPath(const SkDraw&, const SkPath& path, | 190 virtual void drawPath(const SkDraw&, const SkPath& path, |
191 const SkPaint& paint, | 191 const SkPaint& paint, |
192 const SkMatrix* prePathMatrix = NULL, | 192 const SkMatrix* prePathMatrix = NULL, |
193 bool pathIsMutable = false) SK_OVERRIDE | 193 bool pathIsMutable = false) SK_OVERRIDE |
194 {SkASSERT(0);} | 194 {SkASSERT(0);} |
195 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, | 195 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, |
(...skipping 25 matching lines...) Expand all Loading... |
221 int indexCount, const SkPaint& paint) SK_OVERRID
E | 221 int indexCount, const SkPaint& paint) SK_OVERRID
E |
222 {SkASSERT(0);} | 222 {SkASSERT(0);} |
223 virtual void drawPatch(const SkDraw&, const SkPoint cubics[12], const SkColo
r colors[4], | 223 virtual void drawPatch(const SkDraw&, const SkPoint cubics[12], const SkColo
r colors[4], |
224 const SkPoint texCoords[4], SkXfermode* xmode, | 224 const SkPoint texCoords[4], SkXfermode* xmode, |
225 const SkPaint& paint) SK_OVERRIDE | 225 const SkPaint& paint) SK_OVERRIDE |
226 {SkASSERT(0);} | 226 {SkASSERT(0);} |
227 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | 227 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
228 const SkPaint&) SK_OVERRIDE | 228 const SkPaint&) SK_OVERRIDE |
229 {SkASSERT(0);} | 229 {SkASSERT(0);} |
230 | 230 |
231 virtual void lockPixels() SK_OVERRIDE {} | 231 void lockPixels() SK_OVERRIDE {} |
232 virtual void unlockPixels() SK_OVERRIDE {} | 232 void unlockPixels() SK_OVERRIDE {} |
233 | 233 |
234 virtual bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE { | 234 bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE { |
235 return false; | 235 return false; |
236 } | 236 } |
237 virtual bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { | 237 bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { |
238 return false; | 238 return false; |
239 } | 239 } |
240 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, | 240 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, |
241 const SkImageFilter::Context&, SkBitmap*, SkIPoint*
) SK_OVERRIDE { | 241 const SkImageFilter::Context&, SkBitmap*, SkIPoint*
) SK_OVERRIDE { |
242 return false; | 242 return false; |
243 } | 243 } |
244 | 244 |
245 private: | 245 private: |
246 virtual void flush() SK_OVERRIDE; | 246 void flush() SK_OVERRIDE; |
247 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRI
DE {} | 247 void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRIDE {} |
248 | 248 |
249 void beginRecording(); | 249 void beginRecording(); |
250 void init(); | 250 void init(); |
251 void aboutToDraw(); | 251 void aboutToDraw(); |
252 void prepareForImmediatePixelWrite(); | 252 void prepareForImmediatePixelWrite(); |
253 | 253 |
254 DeferredPipeController fPipeController; | 254 DeferredPipeController fPipeController; |
255 SkGPipeWriter fPipeWriter; | 255 SkGPipeWriter fPipeWriter; |
256 SkCanvas* fImmediateCanvas; | 256 SkCanvas* fImmediateCanvas; |
257 SkCanvas* fRecordingCanvas; | 257 SkCanvas* fRecordingCanvas; |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 934 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
935 this->drawingCanvas()->setDrawFilter(filter); | 935 this->drawingCanvas()->setDrawFilter(filter); |
936 this->INHERITED::setDrawFilter(filter); | 936 this->INHERITED::setDrawFilter(filter); |
937 this->recordedDrawCommand(); | 937 this->recordedDrawCommand(); |
938 return filter; | 938 return filter; |
939 } | 939 } |
940 | 940 |
941 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 941 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
942 return this->drawingCanvas(); | 942 return this->drawingCanvas(); |
943 } | 943 } |
OLD | NEW |