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 |
11 #include "SkBitmapDevice.h" | |
12 #include "SkChunkAlloc.h" | 11 #include "SkChunkAlloc.h" |
13 #include "SkColorFilter.h" | 12 #include "SkColorFilter.h" |
| 13 #include "SkDevice.h" |
14 #include "SkDrawFilter.h" | 14 #include "SkDrawFilter.h" |
15 #include "SkGPipe.h" | 15 #include "SkGPipe.h" |
16 #include "SkImage_Base.h" | 16 #include "SkImage_Base.h" |
17 #include "SkPaint.h" | 17 #include "SkPaint.h" |
18 #include "SkPaintPriv.h" | 18 #include "SkPaintPriv.h" |
19 #include "SkRRect.h" | 19 #include "SkRRect.h" |
20 #include "SkShader.h" | 20 #include "SkShader.h" |
21 #include "SkSurface.h" | 21 #include "SkSurface.h" |
22 | 22 |
23 enum { | 23 enum { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 SkGPipeWriter fPipeWriter; | 276 SkGPipeWriter fPipeWriter; |
277 SkCanvas* fImmediateCanvas; | 277 SkCanvas* fImmediateCanvas; |
278 SkCanvas* fRecordingCanvas; | 278 SkCanvas* fRecordingCanvas; |
279 SkSurface* fSurface; | 279 SkSurface* fSurface; |
280 SkDeferredCanvas::NotificationClient* fNotificationClient; | 280 SkDeferredCanvas::NotificationClient* fNotificationClient; |
281 bool fFreshFrame; | 281 bool fFreshFrame; |
282 bool fCanDiscardCanvasContents; | 282 bool fCanDiscardCanvasContents; |
283 bool fIsDrawingToLayer; | 283 bool fIsDrawingToLayer; |
284 size_t fMaxRecordingStorageBytes; | 284 size_t fMaxRecordingStorageBytes; |
285 size_t fPreviousStorageAllocated; | 285 size_t fPreviousStorageAllocated; |
| 286 |
| 287 typedef SkBaseDevice INHERITED; |
286 }; | 288 }; |
287 | 289 |
288 SkDeferredDevice::SkDeferredDevice(SkSurface* surface) { | 290 SkDeferredDevice::SkDeferredDevice(SkSurface* surface) |
| 291 : INHERITED(surface->props()) { |
289 fMaxRecordingStorageBytes = kDefaultMaxRecordingStorageBytes; | 292 fMaxRecordingStorageBytes = kDefaultMaxRecordingStorageBytes; |
290 fNotificationClient = NULL; | 293 fNotificationClient = NULL; |
291 fImmediateCanvas = NULL; | 294 fImmediateCanvas = NULL; |
292 fSurface = NULL; | 295 fSurface = NULL; |
293 this->setSurface(surface); | 296 this->setSurface(surface); |
294 this->init(); | 297 this->init(); |
295 } | 298 } |
296 | 299 |
297 void SkDeferredDevice::setSurface(SkSurface* surface) { | 300 void SkDeferredDevice::setSurface(SkSurface* surface) { |
298 SkRefCnt_SafeAssign(fImmediateCanvas, surface->getCanvas()); | 301 SkRefCnt_SafeAssign(fImmediateCanvas, surface->getCanvas()); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 fCanvas = &canvas; | 533 fCanvas = &canvas; |
531 } else { | 534 } else { |
532 fCanvas = NULL; | 535 fCanvas = NULL; |
533 } | 536 } |
534 } | 537 } |
535 | 538 |
536 SkDeferredCanvas* fCanvas; | 539 SkDeferredCanvas* fCanvas; |
537 }; | 540 }; |
538 | 541 |
539 SkDeferredCanvas* SkDeferredCanvas::Create(SkSurface* surface) { | 542 SkDeferredCanvas* SkDeferredCanvas::Create(SkSurface* surface) { |
| 543 if (!surface) { |
| 544 return NULL; |
| 545 } |
| 546 |
540 SkAutoTUnref<SkDeferredDevice> deferredDevice(SkNEW_ARGS(SkDeferredDevice, (
surface))); | 547 SkAutoTUnref<SkDeferredDevice> deferredDevice(SkNEW_ARGS(SkDeferredDevice, (
surface))); |
541 return SkNEW_ARGS(SkDeferredCanvas, (deferredDevice)); | 548 return SkNEW_ARGS(SkDeferredCanvas, (deferredDevice)); |
542 } | 549 } |
543 | 550 |
544 SkDeferredCanvas::SkDeferredCanvas(SkDeferredDevice* device) : SkCanvas (device)
{ | 551 SkDeferredCanvas::SkDeferredCanvas(SkDeferredDevice* device) : SkCanvas (device)
{ |
545 this->init(); | 552 this->init(); |
546 } | 553 } |
547 | 554 |
548 void SkDeferredCanvas::init() { | 555 void SkDeferredCanvas::init() { |
549 fBitmapSizeThreshold = kDeferredCanvasBitmapSizeThreshold; | 556 fBitmapSizeThreshold = kDeferredCanvasBitmapSizeThreshold; |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 992 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
986 this->drawingCanvas()->setDrawFilter(filter); | 993 this->drawingCanvas()->setDrawFilter(filter); |
987 this->INHERITED::setDrawFilter(filter); | 994 this->INHERITED::setDrawFilter(filter); |
988 this->recordedDrawCommand(); | 995 this->recordedDrawCommand(); |
989 return filter; | 996 return filter; |
990 } | 997 } |
991 | 998 |
992 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 999 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
993 return this->drawingCanvas(); | 1000 return this->drawingCanvas(); |
994 } | 1001 } |
OLD | NEW |