| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 */ | 61 */ |
| 62 virtual void onDiscard() {} | 62 virtual void onDiscard() {} |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * If the surface is about to change, we call this so that our subclass | 65 * If the surface is about to change, we call this so that our subclass |
| 66 * can optionally fork their backend (copy-on-write) in case it was | 66 * can optionally fork their backend (copy-on-write) in case it was |
| 67 * being shared with the cachedImage. | 67 * being shared with the cachedImage. |
| 68 */ | 68 */ |
| 69 virtual void onCopyOnWrite(ContentChangeMode) = 0; | 69 virtual void onCopyOnWrite(ContentChangeMode) = 0; |
| 70 | 70 |
| 71 /** |
| 72 * Signal the surface to remind its backing store that it's mutable again. |
| 73 * Called only when we _didn't_ copy-on-write; we assume the copies start m
utable. |
| 74 */ |
| 75 virtual void onRestoreBackingMutability() {} |
| 76 |
| 71 inline SkCanvas* getCachedCanvas(); | 77 inline SkCanvas* getCachedCanvas(); |
| 72 inline SkImage* getCachedImage(Budgeted); | 78 inline SkImage* getCachedImage(Budgeted); |
| 73 | 79 |
| 80 bool hasCachedImage() const { return fCachedImage != NULL; } |
| 81 |
| 74 // called by SkSurface to compute a new genID | 82 // called by SkSurface to compute a new genID |
| 75 uint32_t newGenerationID(); | 83 uint32_t newGenerationID(); |
| 76 | 84 |
| 77 private: | 85 private: |
| 78 SkCanvas* fCachedCanvas; | 86 SkCanvas* fCachedCanvas; |
| 79 SkImage* fCachedImage; | 87 SkImage* fCachedImage; |
| 80 | 88 |
| 81 void aboutToDraw(ContentChangeMode mode); | 89 void aboutToDraw(ContentChangeMode mode); |
| 82 | 90 |
| 83 // Returns true if there is an outstanding image-snapshot, indicating that a
call to aboutToDraw | 91 // Returns true if there is an outstanding image-snapshot, indicating that a
call to aboutToDraw |
| (...skipping 18 matching lines...) Expand all Loading... |
| 102 | 110 |
| 103 SkImage* SkSurface_Base::getCachedImage(Budgeted budgeted) { | 111 SkImage* SkSurface_Base::getCachedImage(Budgeted budgeted) { |
| 104 if (NULL == fCachedImage) { | 112 if (NULL == fCachedImage) { |
| 105 fCachedImage = this->onNewImageSnapshot(budgeted); | 113 fCachedImage = this->onNewImageSnapshot(budgeted); |
| 106 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this); | 114 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this); |
| 107 } | 115 } |
| 108 return fCachedImage; | 116 return fCachedImage; |
| 109 } | 117 } |
| 110 | 118 |
| 111 #endif | 119 #endif |
| OLD | NEW |