OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkCanvasDrawable.h" | 9 #include "SkCanvasDrawable.h" |
10 #include "SkThread.h" | 10 #include "SkThread.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 return genID; | 21 return genID; |
22 } | 22 } |
23 | 23 |
24 SkCanvasDrawable::SkCanvasDrawable() : fGenerationID(0) {} | 24 SkCanvasDrawable::SkCanvasDrawable() : fGenerationID(0) {} |
25 | 25 |
26 void SkCanvasDrawable::draw(SkCanvas* canvas) { | 26 void SkCanvasDrawable::draw(SkCanvas* canvas) { |
27 SkAutoCanvasRestore acr(canvas, true); | 27 SkAutoCanvasRestore acr(canvas, true); |
28 this->onDraw(canvas); | 28 this->onDraw(canvas); |
29 } | 29 } |
30 | 30 |
| 31 SkPicture* SkCanvasDrawable::newPictureSnapshot(SkBBHFactory* bbhFactory, uint32
_t recordFlags) { |
| 32 return this->onNewPictureSnapshot(bbhFactory, recordFlags); |
| 33 } |
| 34 |
31 uint32_t SkCanvasDrawable::getGenerationID() { | 35 uint32_t SkCanvasDrawable::getGenerationID() { |
32 if (0 == fGenerationID) { | 36 if (0 == fGenerationID) { |
33 fGenerationID = next_generation_id(); | 37 fGenerationID = next_generation_id(); |
34 } | 38 } |
35 return fGenerationID; | 39 return fGenerationID; |
36 } | 40 } |
37 | 41 |
38 bool SkCanvasDrawable::getBounds(SkRect* boundsPtr) { | 42 SkRect SkCanvasDrawable::getBounds() { |
39 SkRect bounds; | 43 return this->onGetBounds(); |
40 if (!boundsPtr) { | |
41 boundsPtr = &bounds; | |
42 } | |
43 return this->onGetBounds(boundsPtr); | |
44 } | 44 } |
45 | 45 |
46 void SkCanvasDrawable::notifyDrawingChanged() { | 46 void SkCanvasDrawable::notifyDrawingChanged() { |
47 fGenerationID = 0; | 47 fGenerationID = 0; |
48 } | 48 } |
49 | 49 |
| 50 ////////////////////////////////////////////////////////////////////////////////
///////// |
50 | 51 |
| 52 #include "SkPictureRecorder.h" |
| 53 |
| 54 SkPicture* SkCanvasDrawable::onNewPictureSnapshot(SkBBHFactory* bbhFactory, uint
32_t recordFlags) { |
| 55 const SkRect bounds = this->getBounds(); |
| 56 SkPictureRecorder recorder; |
| 57 this->draw(recorder.beginRecording(bounds.width(), bounds.height(), bbhFacto
ry, recordFlags)); |
| 58 return recorder.endRecording(); |
| 59 } |
OLD | NEW |