OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkImage_Base.h" | 9 #include "SkImage_Base.h" |
10 #include "SkSpecialImage.h" | 10 #include "SkSpecialImage.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 virtual bool onPeekPixels(SkPixmap*) const { return false; } | 25 virtual bool onPeekPixels(SkPixmap*) const { return false; } |
26 | 26 |
27 virtual GrTexture* onPeekTexture() const { return nullptr; } | 27 virtual GrTexture* onPeekTexture() const { return nullptr; } |
28 | 28 |
29 virtual bool testingOnlyOnGetROPixels(SkBitmap*) const = 0; | 29 virtual bool testingOnlyOnGetROPixels(SkBitmap*) const = 0; |
30 | 30 |
31 // Delete this entry point ASAP (see skbug.com/4965) | 31 // Delete this entry point ASAP (see skbug.com/4965) |
32 virtual bool getBitmapDeprecated(SkBitmap* result) const = 0; | 32 virtual bool getBitmapDeprecated(SkBitmap* result) const = 0; |
33 | 33 |
34 virtual SkSpecialSurface* onNewSurface(const SkImageInfo& info) const = 0; | 34 virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const
= 0; |
35 | 35 |
36 virtual SkSpecialImage* onExtractSubset(const SkIRect& subset) const = 0; | 36 virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0; |
37 | 37 |
38 private: | 38 private: |
39 typedef SkSpecialImage INHERITED; | 39 typedef SkSpecialImage INHERITED; |
40 }; | 40 }; |
41 | 41 |
42 /////////////////////////////////////////////////////////////////////////////// | 42 /////////////////////////////////////////////////////////////////////////////// |
43 static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) { | 43 static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) { |
44 return static_cast<const SkSpecialImage_Base*>(image); | 44 return static_cast<const SkSpecialImage_Base*>(image); |
45 } | 45 } |
46 | 46 |
47 void SkSpecialImage::draw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPain
t* paint) const { | 47 void SkSpecialImage::draw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPain
t* paint) const { |
48 return as_SIB(this)->onDraw(canvas, x, y, paint); | 48 return as_SIB(this)->onDraw(canvas, x, y, paint); |
49 } | 49 } |
50 | 50 |
51 bool SkSpecialImage::peekPixels(SkPixmap* pixmap) const { | 51 bool SkSpecialImage::peekPixels(SkPixmap* pixmap) const { |
52 return as_SIB(this)->onPeekPixels(pixmap); | 52 return as_SIB(this)->onPeekPixels(pixmap); |
53 } | 53 } |
54 | 54 |
55 GrTexture* SkSpecialImage::peekTexture() const { | 55 GrTexture* SkSpecialImage::peekTexture() const { |
56 return as_SIB(this)->onPeekTexture(); | 56 return as_SIB(this)->onPeekTexture(); |
57 } | 57 } |
58 | 58 |
59 bool SkSpecialImage::testingOnlyGetROPixels(SkBitmap* result) const { | 59 bool SkSpecialImage::testingOnlyGetROPixels(SkBitmap* result) const { |
60 return as_SIB(this)->testingOnlyOnGetROPixels(result); | 60 return as_SIB(this)->testingOnlyOnGetROPixels(result); |
61 } | 61 } |
62 | 62 |
63 SkSpecialSurface* SkSpecialImage::newSurface(const SkImageInfo& info) const { | 63 sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkImageInfo& info) con
st { |
64 return as_SIB(this)->onNewSurface(info); | 64 return as_SIB(this)->onMakeSurface(info); |
65 } | 65 } |
66 | 66 |
67 SkSpecialImage* SkSpecialImage::extractSubset(const SkIRect& subset) const { | 67 sk_sp<SkSpecialImage> SkSpecialImage::makeSubset(const SkIRect& subset) const { |
68 return as_SIB(this)->onExtractSubset(subset); | 68 return as_SIB(this)->onMakeSubset(subset); |
69 } | 69 } |
70 | 70 |
71 #if SK_SUPPORT_GPU | 71 #if SK_SUPPORT_GPU |
72 #include "SkGr.h" | 72 #include "SkGr.h" |
73 #include "SkGrPixelRef.h" | 73 #include "SkGrPixelRef.h" |
74 #endif | 74 #endif |
75 | 75 |
76 SkSpecialImage* SkSpecialImage::internal_fromBM(SkImageFilter::Proxy* proxy, | 76 sk_sp<SkSpecialImage> SkSpecialImage::internal_fromBM(SkImageFilter::Proxy* prox
y, |
77 const SkBitmap& src) { | 77 const SkBitmap& src) { |
78 // Need to test offset case! (see skbug.com/4967) | 78 // Need to test offset case! (see skbug.com/4967) |
79 if (src.getTexture()) { | 79 if (src.getTexture()) { |
80 return SkSpecialImage::NewFromGpu(proxy, | 80 return SkSpecialImage::MakeFromGpu(proxy, |
81 src.bounds(), | 81 src.bounds(), |
82 src.getGenerationID(), | 82 src.getGenerationID(), |
83 src.getTexture()); | 83 src.getTexture()); |
84 } | 84 } |
85 | 85 |
86 return SkSpecialImage::NewFromRaster(proxy, src.bounds(), src); | 86 return SkSpecialImage::MakeFromRaster(proxy, src.bounds(), src); |
87 } | 87 } |
88 | 88 |
89 bool SkSpecialImage::internal_getBM(SkBitmap* result) { | 89 bool SkSpecialImage::internal_getBM(SkBitmap* result) { |
90 const SkSpecialImage_Base* ib = as_SIB(this); | 90 const SkSpecialImage_Base* ib = as_SIB(this); |
91 | 91 |
92 // TODO: need to test offset case! (see skbug.com/4967) | 92 // TODO: need to test offset case! (see skbug.com/4967) |
93 return ib->getBitmapDeprecated(result); | 93 return ib->getBitmapDeprecated(result); |
94 } | 94 } |
95 | 95 |
96 SkImageFilter::Proxy* SkSpecialImage::internal_getProxy() const { | 96 SkImageFilter::Proxy* SkSpecialImage::internal_getProxy() const { |
97 return fProxy; | 97 return fProxy; |
98 } | 98 } |
99 | 99 |
100 /////////////////////////////////////////////////////////////////////////////// | 100 /////////////////////////////////////////////////////////////////////////////// |
101 #include "SkImage.h" | 101 #include "SkImage.h" |
102 #if SK_SUPPORT_GPU | 102 #if SK_SUPPORT_GPU |
103 #include "SkGrPriv.h" | 103 #include "SkGrPriv.h" |
104 #endif | 104 #endif |
105 | 105 |
106 class SkSpecialImage_Image : public SkSpecialImage_Base { | 106 class SkSpecialImage_Image : public SkSpecialImage_Base { |
107 public: | 107 public: |
108 SkSpecialImage_Image(SkImageFilter::Proxy* proxy, const SkIRect& subset, con
st SkImage* image) | 108 SkSpecialImage_Image(SkImageFilter::Proxy* proxy, |
| 109 const SkIRect& subset, |
| 110 const sk_sp<const SkImage>& image) |
109 : INHERITED(proxy, subset, image->uniqueID()) | 111 : INHERITED(proxy, subset, image->uniqueID()) |
110 , fImage(SkRef(image)) { | 112 , fImage(image) { |
111 } | 113 } |
112 | 114 |
113 ~SkSpecialImage_Image() override { } | 115 ~SkSpecialImage_Image() override { } |
114 | 116 |
115 bool isOpaque() const override { return fImage->isOpaque(); } | 117 bool isOpaque() const override { return fImage->isOpaque(); } |
116 | 118 |
117 size_t getSize() const override { | 119 size_t getSize() const override { |
118 #if SK_SUPPORT_GPU | 120 #if SK_SUPPORT_GPU |
119 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) { | 121 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) { |
120 return texture->gpuMemorySize(); | 122 return texture->gpuMemorySize(); |
121 } else | 123 } else |
122 #endif | 124 #endif |
123 { | 125 { |
124 SkPixmap pm; | 126 SkPixmap pm; |
125 if (fImage->peekPixels(&pm)) { | 127 if (fImage->peekPixels(&pm)) { |
126 return pm.height() * pm.rowBytes(); | 128 return pm.height() * pm.rowBytes(); |
127 } | 129 } |
128 } | 130 } |
129 return 0; | 131 return 0; |
130 } | 132 } |
131 | 133 |
132 void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint)
const override { | 134 void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint)
const override { |
133 SkRect dst = SkRect::MakeXYWH(x, y, this->subset().width(), this->subset
().height()); | 135 SkRect dst = SkRect::MakeXYWH(x, y, this->subset().width(), this->subset
().height()); |
134 | 136 |
135 canvas->drawImageRect(fImage, this->subset(), | 137 canvas->drawImageRect(fImage.get(), this->subset(), |
136 dst, paint, SkCanvas::kStrict_SrcRectConstraint); | 138 dst, paint, SkCanvas::kStrict_SrcRectConstraint); |
137 } | 139 } |
138 | 140 |
139 bool onPeekPixels(SkPixmap* pixmap) const override { | 141 bool onPeekPixels(SkPixmap* pixmap) const override { |
140 return fImage->peekPixels(pixmap); | 142 return fImage->peekPixels(pixmap); |
141 } | 143 } |
142 | 144 |
143 GrTexture* onPeekTexture() const override { return as_IB(fImage.get())->peek
Texture(); } | 145 GrTexture* onPeekTexture() const override { return as_IB(fImage.get())->peek
Texture(); } |
144 | 146 |
145 bool getBitmapDeprecated(SkBitmap* result) const override { | 147 bool getBitmapDeprecated(SkBitmap* result) const override { |
(...skipping 11 matching lines...) Expand all Loading... |
157 } | 159 } |
158 #endif | 160 #endif |
159 | 161 |
160 return as_IB(fImage.get())->asBitmapForImageFilters(result); | 162 return as_IB(fImage.get())->asBitmapForImageFilters(result); |
161 } | 163 } |
162 | 164 |
163 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { | 165 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { |
164 return fImage->asLegacyBitmap(result, SkImage::kRO_LegacyBitmapMode); | 166 return fImage->asLegacyBitmap(result, SkImage::kRO_LegacyBitmapMode); |
165 } | 167 } |
166 | 168 |
167 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { | 169 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid
e { |
168 #if SK_SUPPORT_GPU | 170 #if SK_SUPPORT_GPU |
169 GrTexture* texture = as_IB(fImage.get())->peekTexture(); | 171 GrTexture* texture = as_IB(fImage.get())->peekTexture(); |
170 if (texture) { | 172 if (texture) { |
171 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *texture->getCon
text()->caps()); | 173 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *texture->getCon
text()->caps()); |
172 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 174 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
173 | 175 |
174 return SkSpecialSurface::NewRenderTarget(this->proxy(), texture->get
Context(), desc); | 176 return SkSpecialSurface::MakeRenderTarget(this->proxy(), texture->ge
tContext(), desc); |
175 } | 177 } |
176 #endif | 178 #endif |
177 return SkSpecialSurface::NewRaster(this->proxy(), info, nullptr); | 179 return SkSpecialSurface::MakeRaster(this->proxy(), info, nullptr); |
178 } | 180 } |
179 | 181 |
180 SkSpecialImage* onExtractSubset(const SkIRect& subset) const override { | 182 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { |
181 SkAutoTUnref<SkImage> subsetImg(fImage->newSubset(subset)); | 183 sk_sp<SkImage> subsetImg(fImage->makeSubset(subset)); |
182 if (!subsetImg) { | 184 if (!subsetImg) { |
183 return nullptr; | 185 return nullptr; |
184 } | 186 } |
185 | 187 |
186 return SkSpecialImage::NewFromImage(this->internal_getProxy(), | 188 return SkSpecialImage::MakeFromImage(this->internal_getProxy(), |
187 SkIRect::MakeWH(subset.width(), subs
et.height()), | 189 SkIRect::MakeWH(subset.width(), sub
set.height()), |
188 subsetImg); | 190 subsetImg); |
189 } | 191 } |
190 | 192 |
191 private: | 193 private: |
192 SkAutoTUnref<const SkImage> fImage; | 194 sk_sp<const SkImage> fImage; |
193 | 195 |
194 typedef SkSpecialImage_Base INHERITED; | 196 typedef SkSpecialImage_Base INHERITED; |
195 }; | 197 }; |
196 | 198 |
197 #ifdef SK_DEBUG | 199 #ifdef SK_DEBUG |
198 static bool rect_fits(const SkIRect& rect, int width, int height) { | 200 static bool rect_fits(const SkIRect& rect, int width, int height) { |
199 if (0 == width && 0 == height) { | 201 if (0 == width && 0 == height) { |
200 SkASSERT(0 == rect.fLeft && 0 == rect.fRight && 0 == rect.fTop && 0 == r
ect.fBottom); | 202 SkASSERT(0 == rect.fLeft && 0 == rect.fRight && 0 == rect.fTop && 0 == r
ect.fBottom); |
201 return true; | 203 return true; |
202 } | 204 } |
203 | 205 |
204 return rect.fLeft >= 0 && rect.fLeft < width && rect.fLeft < rect.fRight && | 206 return rect.fLeft >= 0 && rect.fLeft < width && rect.fLeft < rect.fRight && |
205 rect.fRight >= 0 && rect.fRight <= width && | 207 rect.fRight >= 0 && rect.fRight <= width && |
206 rect.fTop >= 0 && rect.fTop < height && rect.fTop < rect.fBottom && | 208 rect.fTop >= 0 && rect.fTop < height && rect.fTop < rect.fBottom && |
207 rect.fBottom >= 0 && rect.fBottom <= height; | 209 rect.fBottom >= 0 && rect.fBottom <= height; |
208 } | 210 } |
209 #endif | 211 #endif |
210 | 212 |
211 SkSpecialImage* SkSpecialImage::NewFromImage(SkImageFilter::Proxy* proxy, | 213 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(SkImageFilter::Proxy* proxy, |
212 const SkIRect& subset, | 214 const SkIRect& subset, |
213 const SkImage* image) { | 215 const sk_sp<const SkImage>&
image) { |
214 SkASSERT(rect_fits(subset, image->width(), image->height())); | 216 SkASSERT(rect_fits(subset, image->width(), image->height())); |
215 return new SkSpecialImage_Image(proxy, subset, image); | 217 |
| 218 return sk_make_sp<SkSpecialImage_Image>(proxy, subset, image); |
216 } | 219 } |
217 | 220 |
218 /////////////////////////////////////////////////////////////////////////////// | 221 /////////////////////////////////////////////////////////////////////////////// |
219 #include "SkBitmap.h" | 222 #include "SkBitmap.h" |
220 #include "SkImageInfo.h" | 223 #include "SkImageInfo.h" |
221 #include "SkPixelRef.h" | 224 #include "SkPixelRef.h" |
222 | 225 |
223 class SkSpecialImage_Raster : public SkSpecialImage_Base { | 226 class SkSpecialImage_Raster : public SkSpecialImage_Base { |
224 public: | 227 public: |
225 SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, const SkIRect& subset, co
nst SkBitmap& bm) | 228 SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, const SkIRect& subset, co
nst SkBitmap& bm) |
226 : INHERITED(proxy, subset, bm.getGenerationID()) | 229 : INHERITED(proxy, subset, bm.getGenerationID()) |
227 , fBitmap(bm) { | 230 , fBitmap(bm) { |
228 if (bm.pixelRef() && bm.pixelRef()->isPreLocked()) { | 231 if (bm.pixelRef() && bm.pixelRef()->isPreLocked()) { |
229 // we only preemptively lock if there is no chance of triggering som
ething expensive | 232 // we only preemptively lock if there is no chance of triggering som
ething expensive |
230 // like a lazy decode or imagegenerator. PreLocked means it is flat
pixels already. | 233 // like a lazy decode or imagegenerator. PreLocked means it is flat
pixels already. |
231 fBitmap.lockPixels(); | 234 fBitmap.lockPixels(); |
232 } | 235 } |
233 } | 236 } |
234 | 237 |
235 SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, | 238 SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, |
236 const SkIRect& subset, | 239 const SkIRect& subset, |
237 const SkPixmap& pixmap, | 240 const SkPixmap& pixmap, |
238 void (*releaseProc)(void* addr, void* context), | 241 RasterReleaseProc releaseProc, |
239 void* context) | 242 ReleaseContext context) |
240 : INHERITED(proxy, subset, kNeedNewImageUniqueID_SpecialImage) { | 243 : INHERITED(proxy, subset, kNeedNewImageUniqueID_SpecialImage) { |
241 fBitmap.installPixels(pixmap.info(), pixmap.writable_addr(), | 244 fBitmap.installPixels(pixmap.info(), pixmap.writable_addr(), |
242 pixmap.rowBytes(), pixmap.ctable(), | 245 pixmap.rowBytes(), pixmap.ctable(), |
243 releaseProc, context); | 246 releaseProc, context); |
244 } | 247 } |
245 | 248 |
246 ~SkSpecialImage_Raster() override { } | 249 ~SkSpecialImage_Raster() override { } |
247 | 250 |
248 bool isOpaque() const override { return fBitmap.isOpaque(); } | 251 bool isOpaque() const override { return fBitmap.isOpaque(); } |
249 | 252 |
(...skipping 19 matching lines...) Expand all Loading... |
269 bool getBitmapDeprecated(SkBitmap* result) const override { | 272 bool getBitmapDeprecated(SkBitmap* result) const override { |
270 *result = fBitmap; | 273 *result = fBitmap; |
271 return true; | 274 return true; |
272 } | 275 } |
273 | 276 |
274 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { | 277 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { |
275 *result = fBitmap; | 278 *result = fBitmap; |
276 return true; | 279 return true; |
277 } | 280 } |
278 | 281 |
279 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { | 282 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid
e { |
280 return SkSpecialSurface::NewRaster(this->proxy(), info, nullptr); | 283 return SkSpecialSurface::MakeRaster(this->proxy(), info, nullptr); |
281 } | 284 } |
282 | 285 |
283 SkSpecialImage* onExtractSubset(const SkIRect& subset) const override { | 286 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { |
284 SkBitmap subsetBM; | 287 SkBitmap subsetBM; |
285 | 288 |
286 if (!fBitmap.extractSubset(&subsetBM, subset)) { | 289 if (!fBitmap.extractSubset(&subsetBM, subset)) { |
287 return nullptr; | 290 return nullptr; |
288 } | 291 } |
289 | 292 |
290 return SkSpecialImage::NewFromRaster(this->internal_getProxy(), | 293 return SkSpecialImage::MakeFromRaster(this->internal_getProxy(), |
291 SkIRect::MakeWH(subset.width(), sub
set.height()), | 294 SkIRect::MakeWH(subset.width(), su
bset.height()), |
292 subsetBM); | 295 subsetBM); |
293 } | 296 } |
294 | 297 |
295 private: | 298 private: |
296 SkBitmap fBitmap; | 299 SkBitmap fBitmap; |
297 | 300 |
298 typedef SkSpecialImage_Base INHERITED; | 301 typedef SkSpecialImage_Base INHERITED; |
299 }; | 302 }; |
300 | 303 |
301 SkSpecialImage* SkSpecialImage::NewFromRaster(SkImageFilter::Proxy* proxy, | 304 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(SkImageFilter::Proxy* proxy
, |
302 const SkIRect& subset, | 305 const SkIRect& subset, |
303 const SkBitmap& bm) { | 306 const SkBitmap& bm) { |
304 SkASSERT(nullptr == bm.getTexture()); | 307 SkASSERT(nullptr == bm.getTexture()); |
305 SkASSERT(rect_fits(subset, bm.width(), bm.height())); | 308 SkASSERT(rect_fits(subset, bm.width(), bm.height())); |
306 return new SkSpecialImage_Raster(proxy, subset, bm); | 309 |
| 310 return sk_make_sp<SkSpecialImage_Raster>(proxy, subset, bm); |
307 } | 311 } |
308 | 312 |
309 SkSpecialImage* SkSpecialImage::NewFromPixmap(SkImageFilter::Proxy* proxy, | 313 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromPixmap(SkImageFilter::Proxy* proxy
, |
310 const SkIRect& subset, | 314 const SkIRect& subset, |
311 const SkPixmap& src, | 315 const SkPixmap& src, |
312 void (*releaseProc)(void* addr, vo
id* context), | 316 RasterReleaseProc releasePr
oc, |
313 void* context) { | 317 ReleaseContext context) { |
314 return new SkSpecialImage_Raster(proxy, subset, src, releaseProc, context); | 318 if (!src.addr()) { |
| 319 return nullptr; |
| 320 } |
| 321 |
| 322 return sk_make_sp<SkSpecialImage_Raster>(proxy, subset, src, releaseProc, co
ntext); |
315 } | 323 } |
316 | 324 |
317 | 325 |
318 #if SK_SUPPORT_GPU | 326 #if SK_SUPPORT_GPU |
319 /////////////////////////////////////////////////////////////////////////////// | 327 /////////////////////////////////////////////////////////////////////////////// |
320 #include "GrTexture.h" | 328 #include "GrTexture.h" |
321 | 329 |
322 class SkSpecialImage_Gpu : public SkSpecialImage_Base { | 330 class SkSpecialImage_Gpu : public SkSpecialImage_Base { |
323 public: | 331 public: |
324 SkSpecialImage_Gpu(SkImageFilter::Proxy* proxy, const SkIRect& subset, | 332 SkSpecialImage_Gpu(SkImageFilter::Proxy* proxy, const SkIRect& subset, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 386 |
379 if (!fTexture->readPixels(0, 0, result->width(), result->height(), kSkia
8888_GrPixelConfig, | 387 if (!fTexture->readPixels(0, 0, result->width(), result->height(), kSkia
8888_GrPixelConfig, |
380 result->getPixels(), result->rowBytes())) { | 388 result->getPixels(), result->rowBytes())) { |
381 return false; | 389 return false; |
382 } | 390 } |
383 | 391 |
384 result->pixelRef()->setImmutable(); | 392 result->pixelRef()->setImmutable(); |
385 return true; | 393 return true; |
386 } | 394 } |
387 | 395 |
388 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { | 396 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid
e { |
389 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *fTexture->getContex
t()->caps()); | 397 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *fTexture->getContex
t()->caps()); |
390 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 398 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
391 | 399 |
392 return SkSpecialSurface::NewRenderTarget(this->proxy(), fTexture->getCon
text(), desc); | 400 return SkSpecialSurface::MakeRenderTarget(this->proxy(), fTexture->getCo
ntext(), desc); |
393 } | 401 } |
394 | 402 |
395 SkSpecialImage* onExtractSubset(const SkIRect& subset) const override { | 403 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { |
396 return SkSpecialImage::NewFromGpu(this->internal_getProxy(), | 404 return SkSpecialImage::MakeFromGpu(this->internal_getProxy(), |
397 subset, | 405 subset, |
398 this->uniqueID(), | 406 this->uniqueID(), |
399 fTexture, | 407 fTexture, |
400 fAlphaType); | 408 fAlphaType); |
401 } | 409 } |
402 | 410 |
403 private: | 411 private: |
404 SkAutoTUnref<GrTexture> fTexture; | 412 SkAutoTUnref<GrTexture> fTexture; |
405 const SkAlphaType fAlphaType; | 413 const SkAlphaType fAlphaType; |
406 | 414 |
407 typedef SkSpecialImage_Base INHERITED; | 415 typedef SkSpecialImage_Base INHERITED; |
408 }; | 416 }; |
409 | 417 |
410 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy, | 418 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy, |
411 const SkIRect& subset, | 419 const SkIRect& subset, |
412 uint32_t uniqueID, | 420 uint32_t uniqueID, |
413 GrTexture* tex, | 421 GrTexture* tex, |
414 SkAlphaType at) { | 422 SkAlphaType at) { |
415 SkASSERT(rect_fits(subset, tex->width(), tex->height())); | 423 SkASSERT(rect_fits(subset, tex->width(), tex->height())); |
416 return new SkSpecialImage_Gpu(proxy, subset, uniqueID, tex, at); | 424 return sk_make_sp<SkSpecialImage_Gpu>(proxy, subset, uniqueID, tex, at); |
417 } | 425 } |
418 | 426 |
419 #else | 427 #else |
420 | 428 |
421 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy, | 429 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy, |
422 const SkIRect& subset, | 430 const SkIRect& subset, |
423 uint32_t uniqueID, | 431 uint32_t uniqueID, |
424 GrTexture* tex, | 432 GrTexture* tex, |
425 SkAlphaType at) { | 433 SkAlphaType at) { |
426 return nullptr; | 434 return nullptr; |
427 } | 435 } |
428 | 436 |
429 #endif | 437 #endif |
OLD | NEW |