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 #include "SkSurface_Base.h" | 8 #include "SkSurface_Base.h" |
9 #include "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // in case the canvas outsurvives us, we null the callback | 72 // in case the canvas outsurvives us, we null the callback |
73 if (fCachedCanvas) { | 73 if (fCachedCanvas) { |
74 fCachedCanvas->setSurfaceBase(nullptr); | 74 fCachedCanvas->setSurfaceBase(nullptr); |
75 } | 75 } |
76 | 76 |
77 SkSafeUnref(fCachedImage); | 77 SkSafeUnref(fCachedImage); |
78 SkSafeUnref(fCachedCanvas); | 78 SkSafeUnref(fCachedCanvas); |
79 } | 79 } |
80 | 80 |
81 void SkSurface_Base::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa
int* paint) { | 81 void SkSurface_Base::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa
int* paint) { |
82 SkImage* image = this->newImageSnapshot(SkBudgeted::kYes); | 82 auto image = this->makeImageSnapshot(SkBudgeted::kYes); |
83 if (image) { | 83 if (image) { |
84 canvas->drawImage(image, x, y, paint); | 84 canvas->drawImage(image, x, y, paint); |
85 image->unref(); | |
86 } | 85 } |
87 } | 86 } |
88 | 87 |
89 bool SkSurface_Base::outstandingImageSnapshot() const { | 88 bool SkSurface_Base::outstandingImageSnapshot() const { |
90 return fCachedImage && !fCachedImage->unique(); | 89 return fCachedImage && !fCachedImage->unique(); |
91 } | 90 } |
92 | 91 |
93 void SkSurface_Base::aboutToDraw(ContentChangeMode mode) { | 92 void SkSurface_Base::aboutToDraw(ContentChangeMode mode) { |
94 this->dirtyGenerationID(); | 93 this->dirtyGenerationID(); |
95 | 94 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 155 } |
157 | 156 |
158 void SkSurface::notifyContentWillChange(ContentChangeMode mode) { | 157 void SkSurface::notifyContentWillChange(ContentChangeMode mode) { |
159 asSB(this)->aboutToDraw(mode); | 158 asSB(this)->aboutToDraw(mode); |
160 } | 159 } |
161 | 160 |
162 SkCanvas* SkSurface::getCanvas() { | 161 SkCanvas* SkSurface::getCanvas() { |
163 return asSB(this)->getCachedCanvas(); | 162 return asSB(this)->getCachedCanvas(); |
164 } | 163 } |
165 | 164 |
166 SkImage* SkSurface::newImageSnapshot(SkBudgeted budgeted) { | 165 sk_sp<SkImage> SkSurface::makeImageSnapshot(SkBudgeted budgeted) { |
167 // the caller will call unref() to balance this | 166 // the caller will call unref() to balance this |
168 return asSB(this)->refCachedImage(budgeted, kNo_ForceUnique); | 167 return asSB(this)->refCachedImage(budgeted, kNo_ForceUnique); |
169 } | 168 } |
170 | 169 |
171 SkImage* SkSurface::newImageSnapshot(SkBudgeted budgeted, ForceUnique unique) { | 170 sk_sp<SkImage> SkSurface::makeImageSnapshot(SkBudgeted budgeted, ForceUnique uni
que) { |
172 // the caller will call unref() to balance this | 171 // the caller will call unref() to balance this |
173 return asSB(this)->refCachedImage(budgeted, unique); | 172 return asSB(this)->refCachedImage(budgeted, unique); |
174 } | 173 } |
175 | 174 |
176 SkSurface* SkSurface::newSurface(const SkImageInfo& info) { | 175 SkSurface* SkSurface::newSurface(const SkImageInfo& info) { |
177 return asSB(this)->onNewSurface(info); | 176 return asSB(this)->onNewSurface(info); |
178 } | 177 } |
179 | 178 |
180 void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y, | 179 void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y, |
181 const SkPaint* paint) { | 180 const SkPaint* paint) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 const SkSurfaceProps*) { | 240 const SkSurfaceProps*) { |
242 return nullptr; | 241 return nullptr; |
243 } | 242 } |
244 | 243 |
245 SkSurface* NewFromBackendTextureAsRenderTarget(GrContext*, const GrBackendTextur
eDesc&, | 244 SkSurface* NewFromBackendTextureAsRenderTarget(GrContext*, const GrBackendTextur
eDesc&, |
246 const SkSurfaceProps*) { | 245 const SkSurfaceProps*) { |
247 return nullptr; | 246 return nullptr; |
248 } | 247 } |
249 | 248 |
250 #endif | 249 #endif |
OLD | NEW |