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 SkImage* image = this->newImageSnapshot(kYes_Budgeted); |
83 if (image) { | 83 if (image) { |
84 canvas->drawImage(image, x, y, paint); | 84 canvas->drawImage(image, x, y, paint); |
85 image->unref(); | 85 image->unref(); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 bool SkSurface_Base::outstandingImageSnapshot() const { | 89 bool SkSurface_Base::outstandingImageSnapshot() const { |
90 return fCachedImage && !fCachedImage->unique(); | 90 return fCachedImage && !fCachedImage->unique(); |
91 } | 91 } |
92 | 92 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 | 157 |
158 void SkSurface::notifyContentWillChange(ContentChangeMode mode) { | 158 void SkSurface::notifyContentWillChange(ContentChangeMode mode) { |
159 asSB(this)->aboutToDraw(mode); | 159 asSB(this)->aboutToDraw(mode); |
160 } | 160 } |
161 | 161 |
162 SkCanvas* SkSurface::getCanvas() { | 162 SkCanvas* SkSurface::getCanvas() { |
163 return asSB(this)->getCachedCanvas(); | 163 return asSB(this)->getCachedCanvas(); |
164 } | 164 } |
165 | 165 |
166 SkImage* SkSurface::newImageSnapshot(SkBudgeted budgeted) { | 166 SkImage* SkSurface::newImageSnapshot(Budgeted budgeted) { |
167 // the caller will call unref() to balance this | 167 // the caller will call unref() to balance this |
168 return asSB(this)->refCachedImage(budgeted, kNo_ForceUnique); | 168 return asSB(this)->refCachedImage(budgeted, kNo_ForceUnique); |
169 } | 169 } |
170 | 170 |
171 SkImage* SkSurface::newImageSnapshot(SkBudgeted budgeted, ForceUnique unique) { | 171 SkImage* SkSurface::newImageSnapshot(Budgeted budgeted, ForceUnique unique) { |
172 // the caller will call unref() to balance this | 172 // the caller will call unref() to balance this |
173 return asSB(this)->refCachedImage(budgeted, unique); | 173 return asSB(this)->refCachedImage(budgeted, unique); |
174 } | 174 } |
175 | 175 |
176 SkSurface* SkSurface::newSurface(const SkImageInfo& info) { | 176 SkSurface* SkSurface::newSurface(const SkImageInfo& info) { |
177 return asSB(this)->onNewSurface(info); | 177 return asSB(this)->onNewSurface(info); |
178 } | 178 } |
179 | 179 |
180 void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y, | 180 void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y, |
181 const SkPaint* paint) { | 181 const SkPaint* paint) { |
(...skipping 22 matching lines...) Expand all Loading... |
204 } | 204 } |
205 | 205 |
206 ////////////////////////////////////////////////////////////////////////////////
////// | 206 ////////////////////////////////////////////////////////////////////////////////
////// |
207 | 207 |
208 #if !SK_SUPPORT_GPU | 208 #if !SK_SUPPORT_GPU |
209 | 209 |
210 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProp
s*) { | 210 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProp
s*) { |
211 return nullptr; | 211 return nullptr; |
212 } | 212 } |
213 | 213 |
214 SkSurface* SkSurface::NewRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&
, int, | 214 SkSurface* SkSurface::NewRenderTarget(GrContext*, Budgeted, const SkImageInfo&,
int, |
215 const SkSurfaceProps*, GrTextureStorageAll
ocator) { | 215 const SkSurfaceProps*, GrTextureStorageAll
ocator) { |
216 return nullptr; | 216 return nullptr; |
217 } | 217 } |
218 | 218 |
219 SkSurface* SkSurface::NewFromBackendTexture(GrContext*, const GrBackendTextureDe
sc&, | 219 SkSurface* SkSurface::NewFromBackendTexture(GrContext*, const GrBackendTextureDe
sc&, |
220 const SkSurfaceProps*) { | 220 const SkSurfaceProps*) { |
221 return nullptr; | 221 return nullptr; |
222 } | 222 } |
223 | 223 |
224 SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext*, const GrBackendRend
erTargetDesc&, | 224 SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext*, const GrBackendRend
erTargetDesc&, |
225 const SkSurfaceProps*) { | 225 const SkSurfaceProps*) { |
226 return nullptr; | 226 return nullptr; |
227 } | 227 } |
228 | 228 |
229 SkSurface* NewFromBackendTextureAsRenderTarget(GrContext*, const GrBackendTextur
eDesc&, | 229 SkSurface* NewFromBackendTextureAsRenderTarget(GrContext*, const GrBackendTextur
eDesc&, |
230 const SkSurfaceProps*) { | 230 const SkSurfaceProps*) { |
231 return nullptr; | 231 return nullptr; |
232 } | 232 } |
233 | 233 |
234 #endif | 234 #endif |
OLD | NEW |