| 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 #ifndef SkSurface_Base_DEFINED | 8 #ifndef SkSurface_Base_DEFINED |
| 9 #define SkSurface_Base_DEFINED | 9 #define SkSurface_Base_DEFINED |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 * being shared with the cachedImage. | 59 * being shared with the cachedImage. |
| 60 */ | 60 */ |
| 61 virtual void onCopyOnWrite(ContentChangeMode) = 0; | 61 virtual void onCopyOnWrite(ContentChangeMode) = 0; |
| 62 | 62 |
| 63 inline SkCanvas* getCachedCanvas(); | 63 inline SkCanvas* getCachedCanvas(); |
| 64 inline SkImage* getCachedImage(Budgeted); | 64 inline SkImage* getCachedImage(Budgeted); |
| 65 | 65 |
| 66 // called by SkSurface to compute a new genID | 66 // called by SkSurface to compute a new genID |
| 67 uint32_t newGenerationID(); | 67 uint32_t newGenerationID(); |
| 68 | 68 |
| 69 void aboutToDraw(ContentChangeMode mode); |
| 70 |
| 69 private: | 71 private: |
| 70 SkCanvas* fCachedCanvas; | 72 SkCanvas* fCachedCanvas; |
| 71 SkImage* fCachedImage; | 73 SkImage* fCachedImage; |
| 72 | 74 |
| 73 void aboutToDraw(ContentChangeMode mode); | |
| 74 friend class SkCanvas; | |
| 75 friend class SkSurface; | 75 friend class SkSurface; |
| 76 | |
| 77 typedef SkSurface INHERITED; | 76 typedef SkSurface INHERITED; |
| 78 }; | 77 }; |
| 79 | 78 |
| 80 SkCanvas* SkSurface_Base::getCachedCanvas() { | 79 SkCanvas* SkSurface_Base::getCachedCanvas() { |
| 81 if (NULL == fCachedCanvas) { | 80 if (NULL == fCachedCanvas) { |
| 82 fCachedCanvas = this->onNewCanvas(); | 81 fCachedCanvas = this->onNewCanvas(); |
| 83 if (fCachedCanvas) { | |
| 84 fCachedCanvas->setSurfaceBase(this); | |
| 85 } | |
| 86 } | 82 } |
| 87 return fCachedCanvas; | 83 return fCachedCanvas; |
| 88 } | 84 } |
| 89 | 85 |
| 90 SkImage* SkSurface_Base::getCachedImage(Budgeted budgeted) { | 86 SkImage* SkSurface_Base::getCachedImage(Budgeted budgeted) { |
| 91 if (NULL == fCachedImage) { | 87 if (NULL == fCachedImage) { |
| 92 fCachedImage = this->onNewImageSnapshot(budgeted); | 88 fCachedImage = this->onNewImageSnapshot(budgeted); |
| 93 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this); | |
| 94 } | 89 } |
| 95 return fCachedImage; | 90 return fCachedImage; |
| 96 } | 91 } |
| 97 | 92 |
| 98 #endif | 93 #endif |
| OLD | NEW |