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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 SkSurfaceProps::SkSurfaceProps(const SkSurfaceProps& other) | 50 SkSurfaceProps::SkSurfaceProps(const SkSurfaceProps& other) |
51 : fFlags(other.fFlags) | 51 : fFlags(other.fFlags) |
52 , fPixelGeometry(other.fPixelGeometry) | 52 , fPixelGeometry(other.fPixelGeometry) |
53 {} | 53 {} |
54 | 54 |
55 /////////////////////////////////////////////////////////////////////////////// | 55 /////////////////////////////////////////////////////////////////////////////// |
56 | 56 |
57 SkSurface_Base::SkSurface_Base(int width, int height, const SkSurfaceProps* prop
s) | 57 SkSurface_Base::SkSurface_Base(int width, int height, const SkSurfaceProps* prop
s) |
58 : INHERITED(width, height, props) | 58 : INHERITED(width, height, props) |
59 { | 59 { |
60 fCachedCanvas = NULL; | 60 fCachedCanvas = nullptr; |
61 fCachedImage = NULL; | 61 fCachedImage = nullptr; |
62 } | 62 } |
63 | 63 |
64 SkSurface_Base::SkSurface_Base(const SkImageInfo& info, const SkSurfaceProps* pr
ops) | 64 SkSurface_Base::SkSurface_Base(const SkImageInfo& info, const SkSurfaceProps* pr
ops) |
65 : INHERITED(info, props) | 65 : INHERITED(info, props) |
66 { | 66 { |
67 fCachedCanvas = NULL; | 67 fCachedCanvas = nullptr; |
68 fCachedImage = NULL; | 68 fCachedImage = nullptr; |
69 } | 69 } |
70 | 70 |
71 SkSurface_Base::~SkSurface_Base() { | 71 SkSurface_Base::~SkSurface_Base() { |
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(NULL); | 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(kYes_Budgeted); | 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); |
(...skipping 15 matching lines...) Expand all Loading... |
100 // the cached image. Note: we only call if there is an outstanding owner | 100 // the cached image. Note: we only call if there is an outstanding owner |
101 // on the image (besides us). | 101 // on the image (besides us). |
102 bool unique = fCachedImage->unique(); | 102 bool unique = fCachedImage->unique(); |
103 if (!unique) { | 103 if (!unique) { |
104 this->onCopyOnWrite(mode); | 104 this->onCopyOnWrite(mode); |
105 } | 105 } |
106 | 106 |
107 // regardless of copy-on-write, we must drop our cached image now, so | 107 // regardless of copy-on-write, we must drop our cached image now, so |
108 // that the next request will get our new contents. | 108 // that the next request will get our new contents. |
109 fCachedImage->unref(); | 109 fCachedImage->unref(); |
110 fCachedImage = NULL; | 110 fCachedImage = nullptr; |
111 | 111 |
112 if (unique) { | 112 if (unique) { |
113 // Our content isn't held by any image now, so we can consider that
content mutable. | 113 // Our content isn't held by any image now, so we can consider that
content mutable. |
114 // Raster surfaces need to be told it's safe to consider its pixels
mutable again. | 114 // Raster surfaces need to be told it's safe to consider its pixels
mutable again. |
115 // We make this call after the ->unref() so the subclass can assert
there are no images. | 115 // We make this call after the ->unref() so the subclass can assert
there are no images. |
116 this->onRestoreBackingMutability(); | 116 this->onRestoreBackingMutability(); |
117 } | 117 } |
118 } else if (kDiscard_ContentChangeMode == mode) { | 118 } else if (kDiscard_ContentChangeMode == mode) { |
119 this->onDiscard(); | 119 this->onDiscard(); |
120 } | 120 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 bool SkSurface::getRenderTargetHandle(GrBackendObject* obj, BackendHandleAccess
access) { | 194 bool SkSurface::getRenderTargetHandle(GrBackendObject* obj, BackendHandleAccess
access) { |
195 return asSB(this)->onGetRenderTargetHandle(obj, access); | 195 return asSB(this)->onGetRenderTargetHandle(obj, access); |
196 } | 196 } |
197 | 197 |
198 ////////////////////////////////////////////////////////////////////////////////
////// | 198 ////////////////////////////////////////////////////////////////////////////////
////// |
199 | 199 |
200 #if !SK_SUPPORT_GPU | 200 #if !SK_SUPPORT_GPU |
201 | 201 |
202 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProp
s*) { | 202 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProp
s*) { |
203 return NULL; | 203 return nullptr; |
204 } | 204 } |
205 | 205 |
206 SkSurface* SkSurface::NewRenderTarget(GrContext*, Budgeted, const SkImageInfo&,
int, | 206 SkSurface* SkSurface::NewRenderTarget(GrContext*, Budgeted, const SkImageInfo&,
int, |
207 const SkSurfaceProps*) { | 207 const SkSurfaceProps*) { |
208 return NULL; | 208 return nullptr; |
209 } | 209 } |
210 | 210 |
211 SkSurface* SkSurface::NewFromBackendTexture(GrContext*, const GrBackendTextureDe
sc&, | 211 SkSurface* SkSurface::NewFromBackendTexture(GrContext*, const GrBackendTextureDe
sc&, |
212 const SkSurfaceProps*) { | 212 const SkSurfaceProps*) { |
213 return NULL; | 213 return nullptr; |
214 } | 214 } |
215 | 215 |
216 SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext*, const GrBackendRend
erTargetDesc&, | 216 SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext*, const GrBackendRend
erTargetDesc&, |
217 const SkSurfaceProps*) { | 217 const SkSurfaceProps*) { |
218 return NULL; | 218 return nullptr; |
219 } | 219 } |
220 | 220 |
221 #endif | 221 #endif |
OLD | NEW |