Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: src/core/SkSpecialImage.cpp

Issue 1896383003: Begin removing deprecated (and now, unused) ImageFilter code paths (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkSpecialImage.h ('k') | src/core/SkSpecialSurface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "SkSpecialImage.h" 7 #include "SkSpecialImage.h"
8 8
9 #if SK_SUPPORT_GPU 9 #if SK_SUPPORT_GPU
10 #include "GrTexture.h" 10 #include "GrTexture.h"
11 #include "GrTextureParams.h" 11 #include "GrTextureParams.h"
12 #include "SkGr.h" 12 #include "SkGr.h"
13 #endif 13 #endif
14 14
15 #include "SkBitmapCache.h" 15 #include "SkBitmapCache.h"
16 #include "SkCanvas.h" 16 #include "SkCanvas.h"
17 #include "SkImage_Base.h" 17 #include "SkImage_Base.h"
18 #include "SkSpecialSurface.h" 18 #include "SkSpecialSurface.h"
19 #include "SkSurfacePriv.h" 19 #include "SkSurfacePriv.h"
20 20
21 /////////////////////////////////////////////////////////////////////////////// 21 ///////////////////////////////////////////////////////////////////////////////
22 class SkSpecialImage_Base : public SkSpecialImage { 22 class SkSpecialImage_Base : public SkSpecialImage {
23 public: 23 public:
24 SkSpecialImage_Base(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint 32_t uniqueID, 24 SkSpecialImage_Base(const SkIRect& subset, uint32_t uniqueID, const SkSurfac eProps* props)
25 const SkSurfaceProps* props) 25 : INHERITED(subset, uniqueID, props) {
26 : INHERITED(proxy, subset, uniqueID, props) {
27 } 26 }
28 virtual ~SkSpecialImage_Base() { } 27 ~SkSpecialImage_Base() override { }
29 28
30 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const = 0; 29 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const = 0;
31 30
32 virtual bool onGetROPixels(SkBitmap*) const = 0; 31 virtual bool onGetROPixels(SkBitmap*) const = 0;
33 32
34 virtual GrTexture* onPeekTexture() const { return nullptr; } 33 virtual GrTexture* onPeekTexture() const { return nullptr; }
35 34
36 virtual GrTexture* onAsTextureRef(GrContext* context) const = 0; 35 virtual GrTexture* onAsTextureRef(GrContext* context) const = 0;
37 36
38 // Delete this entry point ASAP (see skbug.com/4965) 37 // Delete this entry point ASAP (see skbug.com/4965)
39 virtual bool getBitmapDeprecated(SkBitmap* result) const = 0; 38 virtual bool getBitmapDeprecated(SkBitmap* result) const = 0;
40 39
41 virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0; 40 virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0;
42 41
43 virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const = 0; 42 virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const = 0;
44 43
45 virtual sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const = 0; 44 virtual sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const = 0;
46 45
47 virtual sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const = 0; 46 virtual sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const = 0;
48 47
49 private: 48 private:
50 typedef SkSpecialImage INHERITED; 49 typedef SkSpecialImage INHERITED;
51 }; 50 };
52 51
53 /////////////////////////////////////////////////////////////////////////////// 52 ///////////////////////////////////////////////////////////////////////////////
54 static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) { 53 static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) {
55 return static_cast<const SkSpecialImage_Base*>(image); 54 return static_cast<const SkSpecialImage_Base*>(image);
56 } 55 }
57 56
58 SkSpecialImage::SkSpecialImage(SkImageFilter::Proxy* proxy, 57 SkSpecialImage::SkSpecialImage(const SkIRect& subset,
59 const SkIRect& subset,
60 uint32_t uniqueID, 58 uint32_t uniqueID,
61 const SkSurfaceProps* props) 59 const SkSurfaceProps* props)
62 : fProps(SkSurfacePropsCopyOrDefault(props)) 60 : fProps(SkSurfacePropsCopyOrDefault(props))
63 , fSubset(subset) 61 , fSubset(subset)
64 , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::Image ID() : uniqueID) 62 , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::Image ID() : uniqueID) {
65 , fProxy(proxy) {
66 } 63 }
67 64
68 sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(SkImageFilter::Proxy* pro xy, 65 sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(GrContext* context) {
69 GrContext* context) {
70 #if SK_SUPPORT_GPU 66 #if SK_SUPPORT_GPU
71 if (!context) { 67 if (!context) {
72 return nullptr; 68 return nullptr;
73 } 69 }
74 if (GrTexture* peek = as_SIB(this)->onPeekTexture()) { 70 if (GrTexture* peek = as_SIB(this)->onPeekTexture()) {
75 return peek->getContext() == context ? sk_sp<SkSpecialImage>(SkRef(this) ) : nullptr; 71 return peek->getContext() == context ? sk_sp<SkSpecialImage>(SkRef(this) ) : nullptr;
76 } 72 }
77 73
78 SkBitmap bmp; 74 SkBitmap bmp;
79 if (!this->internal_getBM(&bmp)) { 75 if (!this->internal_getBM(&bmp)) {
80 return nullptr; 76 return nullptr;
81 } 77 }
82 78
83 if (bmp.empty()) { 79 if (bmp.empty()) {
84 return SkSpecialImage::MakeFromRaster(proxy, SkIRect::MakeEmpty(), bmp, &this->props()); 80 return SkSpecialImage::MakeFromRaster(SkIRect::MakeEmpty(), bmp, &this-> props());
85 } 81 }
86 82
87 SkAutoTUnref<GrTexture> resultTex( 83 SkAutoTUnref<GrTexture> resultTex(
88 GrRefCachedBitmapTexture(context, bmp, GrTextureParams::ClampNoFilter()) ); 84 GrRefCachedBitmapTexture(context, bmp, GrTextureParams::ClampNoFilter()) );
89 if (!resultTex) { 85 if (!resultTex) {
90 return nullptr; 86 return nullptr;
91 } 87 }
92 88
93 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp e; 89 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp e;
94 90
95 return SkSpecialImage::MakeFromGpu(proxy, 91 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(resultTex->width(), resul tTex->height()),
96 SkIRect::MakeWH(resultTex->width(), resul tTex->height()),
97 this->uniqueID(), 92 this->uniqueID(),
98 resultTex, &this->props(), at); 93 resultTex, &this->props(), at);
99 #else 94 #else
100 return nullptr; 95 return nullptr;
101 #endif 96 #endif
102 } 97 }
103 98
104 void SkSpecialImage::draw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPain t* paint) const { 99 void SkSpecialImage::draw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPain t* paint) const {
105 return as_SIB(this)->onDraw(canvas, x, y, paint); 100 return as_SIB(this)->onDraw(canvas, x, y, paint);
106 } 101 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 142
148 sk_sp<SkImage> SkSpecialImage::makeTightSubset(const SkIRect& subset) const { 143 sk_sp<SkImage> SkSpecialImage::makeTightSubset(const SkIRect& subset) const {
149 return as_SIB(this)->onMakeTightSubset(subset); 144 return as_SIB(this)->onMakeTightSubset(subset);
150 } 145 }
151 146
152 #if SK_SUPPORT_GPU 147 #if SK_SUPPORT_GPU
153 #include "SkGr.h" 148 #include "SkGr.h"
154 #include "SkGrPixelRef.h" 149 #include "SkGrPixelRef.h"
155 #endif 150 #endif
156 151
157 sk_sp<SkSpecialImage> SkSpecialImage::internal_fromBM(SkImageFilter::Proxy* prox y, 152 sk_sp<SkSpecialImage> SkSpecialImage::internal_fromBM(const SkBitmap& src,
158 const SkBitmap& src,
159 const SkSurfaceProps* prop s) { 153 const SkSurfaceProps* prop s) {
160 // Need to test offset case! (see skbug.com/4967) 154 // Need to test offset case! (see skbug.com/4967)
161 if (src.getTexture()) { 155 if (src.getTexture()) {
162 return SkSpecialImage::MakeFromGpu(proxy, 156 return SkSpecialImage::MakeFromGpu(src.bounds(),
163 src.bounds(),
164 src.getGenerationID(), 157 src.getGenerationID(),
165 src.getTexture(), 158 src.getTexture(),
166 props); 159 props);
167 } 160 }
168 161
169 return SkSpecialImage::MakeFromRaster(proxy, src.bounds(), src, props); 162 return SkSpecialImage::MakeFromRaster(src.bounds(), src, props);
170 } 163 }
171 164
172 bool SkSpecialImage::internal_getBM(SkBitmap* result) { 165 bool SkSpecialImage::internal_getBM(SkBitmap* result) {
173 const SkSpecialImage_Base* ib = as_SIB(this); 166 const SkSpecialImage_Base* ib = as_SIB(this);
174 167
175 // TODO: need to test offset case! (see skbug.com/4967) 168 // TODO: need to test offset case! (see skbug.com/4967)
176 return ib->getBitmapDeprecated(result); 169 return ib->getBitmapDeprecated(result);
177 } 170 }
178 171
179 SkImageFilter::Proxy* SkSpecialImage::internal_getProxy() const {
180 return fProxy;
181 }
182
183 /////////////////////////////////////////////////////////////////////////////// 172 ///////////////////////////////////////////////////////////////////////////////
184 #include "SkImage.h" 173 #include "SkImage.h"
185 #if SK_SUPPORT_GPU 174 #if SK_SUPPORT_GPU
186 #include "GrContext.h" 175 #include "GrContext.h"
187 #include "SkGrPriv.h" 176 #include "SkGrPriv.h"
188 #endif 177 #endif
189 178
190 class SkSpecialImage_Image : public SkSpecialImage_Base { 179 class SkSpecialImage_Image : public SkSpecialImage_Base {
191 public: 180 public:
192 SkSpecialImage_Image(SkImageFilter::Proxy* proxy, 181 SkSpecialImage_Image(const SkIRect& subset,
193 const SkIRect& subset,
194 sk_sp<SkImage> image, 182 sk_sp<SkImage> image,
195 const SkSurfaceProps* props) 183 const SkSurfaceProps* props)
196 : INHERITED(proxy, subset, image->uniqueID(), props) 184 : INHERITED(subset, image->uniqueID(), props)
197 , fImage(image) { 185 , fImage(image) {
198 } 186 }
199 187
200 ~SkSpecialImage_Image() override { } 188 ~SkSpecialImage_Image() override { }
201 189
202 bool isOpaque() const override { return fImage->isOpaque(); } 190 bool isOpaque() const override { return fImage->isOpaque(); }
203 191
204 size_t getSize() const override { 192 size_t getSize() const override {
205 #if SK_SUPPORT_GPU 193 #if SK_SUPPORT_GPU
206 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) { 194 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 return as_IB(fImage.get())->asBitmapForImageFilters(result); 243 return as_IB(fImage.get())->asBitmapForImageFilters(result);
256 } 244 }
257 245
258 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid e { 246 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid e {
259 #if SK_SUPPORT_GPU 247 #if SK_SUPPORT_GPU
260 GrTexture* texture = as_IB(fImage.get())->peekTexture(); 248 GrTexture* texture = as_IB(fImage.get())->peekTexture();
261 if (texture) { 249 if (texture) {
262 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *texture->getCon text()->caps()); 250 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *texture->getCon text()->caps());
263 desc.fFlags = kRenderTarget_GrSurfaceFlag; 251 desc.fFlags = kRenderTarget_GrSurfaceFlag;
264 252
265 return SkSpecialSurface::MakeRenderTarget(this->proxy(), texture->ge tContext(), desc); 253 return SkSpecialSurface::MakeRenderTarget(texture->getContext(), des c);
266 } 254 }
267 #endif 255 #endif
268 return SkSpecialSurface::MakeRaster(this->proxy(), info, nullptr); 256 return SkSpecialSurface::MakeRaster(info, nullptr);
269 } 257 }
270 258
271 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { 259 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
272 sk_sp<SkImage> subsetImg(fImage->makeSubset(subset)); 260 sk_sp<SkImage> subsetImg(fImage->makeSubset(subset));
273 if (!subsetImg) { 261 if (!subsetImg) {
274 return nullptr; 262 return nullptr;
275 } 263 }
276 264
277 return SkSpecialImage::MakeFromImage(this->internal_getProxy(), 265 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(subset.width(), sub set.height()),
278 SkIRect::MakeWH(subset.width(), sub set.height()),
279 subsetImg, 266 subsetImg,
280 &this->props()); 267 &this->props());
281 } 268 }
282 269
283 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override { 270 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override {
284 return fImage->makeSubset(subset); 271 return fImage->makeSubset(subset);
285 } 272 }
286 273
287 sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override { 274 sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override {
288 #if SK_SUPPORT_GPU 275 #if SK_SUPPORT_GPU
(...skipping 18 matching lines...) Expand all
307 return true; 294 return true;
308 } 295 }
309 296
310 return rect.fLeft >= 0 && rect.fLeft < width && rect.fLeft < rect.fRight && 297 return rect.fLeft >= 0 && rect.fLeft < width && rect.fLeft < rect.fRight &&
311 rect.fRight >= 0 && rect.fRight <= width && 298 rect.fRight >= 0 && rect.fRight <= width &&
312 rect.fTop >= 0 && rect.fTop < height && rect.fTop < rect.fBottom && 299 rect.fTop >= 0 && rect.fTop < height && rect.fTop < rect.fBottom &&
313 rect.fBottom >= 0 && rect.fBottom <= height; 300 rect.fBottom >= 0 && rect.fBottom <= height;
314 } 301 }
315 #endif 302 #endif
316 303
317 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(SkImageFilter::Proxy* proxy, 304 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(const SkIRect& subset,
318 const SkIRect& subset,
319 sk_sp<SkImage> image, 305 sk_sp<SkImage> image,
320 const SkSurfaceProps* props) { 306 const SkSurfaceProps* props) {
321 SkASSERT(rect_fits(subset, image->width(), image->height())); 307 SkASSERT(rect_fits(subset, image->width(), image->height()));
322 308
323 return sk_make_sp<SkSpecialImage_Image>(proxy, subset, image, props); 309 return sk_make_sp<SkSpecialImage_Image>(subset, image, props);
324 } 310 }
325 311
326 /////////////////////////////////////////////////////////////////////////////// 312 ///////////////////////////////////////////////////////////////////////////////
327 #include "SkBitmap.h" 313 #include "SkBitmap.h"
328 #include "SkImageInfo.h" 314 #include "SkImageInfo.h"
329 #include "SkPixelRef.h" 315 #include "SkPixelRef.h"
330 316
331 class SkSpecialImage_Raster : public SkSpecialImage_Base { 317 class SkSpecialImage_Raster : public SkSpecialImage_Base {
332 public: 318 public:
333 SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, const SkIRect& subset, co nst SkBitmap& bm, 319 SkSpecialImage_Raster(const SkIRect& subset, const SkBitmap& bm, const SkSur faceProps* props)
334 const SkSurfaceProps* props) 320 : INHERITED(subset, bm.getGenerationID(), props)
335 : INHERITED(proxy, subset, bm.getGenerationID(), props)
336 , fBitmap(bm) { 321 , fBitmap(bm) {
337 if (bm.pixelRef() && bm.pixelRef()->isPreLocked()) { 322 if (bm.pixelRef() && bm.pixelRef()->isPreLocked()) {
338 // we only preemptively lock if there is no chance of triggering som ething expensive 323 // we only preemptively lock if there is no chance of triggering som ething expensive
339 // like a lazy decode or imagegenerator. PreLocked means it is flat pixels already. 324 // like a lazy decode or imagegenerator. PreLocked means it is flat pixels already.
340 fBitmap.lockPixels(); 325 fBitmap.lockPixels();
341 } 326 }
342 } 327 }
343 328
344 SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, 329 SkSpecialImage_Raster(const SkIRect& subset,
345 const SkIRect& subset,
346 const SkPixmap& pixmap, 330 const SkPixmap& pixmap,
347 RasterReleaseProc releaseProc, 331 RasterReleaseProc releaseProc,
348 ReleaseContext context, 332 ReleaseContext context,
349 const SkSurfaceProps* props) 333 const SkSurfaceProps* props)
350 : INHERITED(proxy, subset, kNeedNewImageUniqueID_SpecialImage, props) { 334 : INHERITED(subset, kNeedNewImageUniqueID_SpecialImage, props) {
351 fBitmap.installPixels(pixmap.info(), pixmap.writable_addr(), 335 fBitmap.installPixels(pixmap.info(), pixmap.writable_addr(),
352 pixmap.rowBytes(), pixmap.ctable(), 336 pixmap.rowBytes(), pixmap.ctable(),
353 releaseProc, context); 337 releaseProc, context);
354 } 338 }
355 339
356 ~SkSpecialImage_Raster() override { } 340 ~SkSpecialImage_Raster() override { }
357 341
358 bool isOpaque() const override { return fBitmap.isOpaque(); } 342 bool isOpaque() const override { return fBitmap.isOpaque(); }
359 343
360 size_t getSize() const override { return fBitmap.getSize(); } 344 size_t getSize() const override { return fBitmap.getSize(); }
(...skipping 20 matching lines...) Expand all
381 365
382 return nullptr; 366 return nullptr;
383 } 367 }
384 368
385 bool getBitmapDeprecated(SkBitmap* result) const override { 369 bool getBitmapDeprecated(SkBitmap* result) const override {
386 *result = fBitmap; 370 *result = fBitmap;
387 return true; 371 return true;
388 } 372 }
389 373
390 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid e { 374 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid e {
391 return SkSpecialSurface::MakeRaster(this->proxy(), info, nullptr); 375 return SkSpecialSurface::MakeRaster(info, nullptr);
392 } 376 }
393 377
394 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { 378 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
395 SkBitmap subsetBM; 379 SkBitmap subsetBM;
396 380
397 if (!fBitmap.extractSubset(&subsetBM, subset)) { 381 if (!fBitmap.extractSubset(&subsetBM, subset)) {
398 return nullptr; 382 return nullptr;
399 } 383 }
400 384
401 return SkSpecialImage::MakeFromRaster(this->internal_getProxy(), 385 return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(subset.width(), su bset.height()),
402 SkIRect::MakeWH(subset.width(), su bset.height()),
403 subsetBM, 386 subsetBM,
404 &this->props()); 387 &this->props());
405 } 388 }
406 389
407 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override { 390 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override {
408 SkBitmap subsetBM; 391 SkBitmap subsetBM;
409 392
410 if (!fBitmap.extractSubset(&subsetBM, subset)) { 393 if (!fBitmap.extractSubset(&subsetBM, subset)) {
411 return nullptr; 394 return nullptr;
412 } 395 }
413 396
414 return SkImage::MakeFromBitmap(subsetBM); 397 return SkImage::MakeFromBitmap(subsetBM);
415 } 398 }
416 399
417 sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override { 400 sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override {
418 return SkSurface::MakeRaster(info); 401 return SkSurface::MakeRaster(info);
419 } 402 }
420 403
421 private: 404 private:
422 SkBitmap fBitmap; 405 SkBitmap fBitmap;
423 406
424 typedef SkSpecialImage_Base INHERITED; 407 typedef SkSpecialImage_Base INHERITED;
425 }; 408 };
426 409
427 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(SkImageFilter::Proxy* proxy , 410 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(const SkIRect& subset,
428 const SkIRect& subset,
429 const SkBitmap& bm, 411 const SkBitmap& bm,
430 const SkSurfaceProps* props ) { 412 const SkSurfaceProps* props ) {
431 SkASSERT(nullptr == bm.getTexture()); 413 SkASSERT(nullptr == bm.getTexture());
432 SkASSERT(rect_fits(subset, bm.width(), bm.height())); 414 SkASSERT(rect_fits(subset, bm.width(), bm.height()));
433 415
434 return sk_make_sp<SkSpecialImage_Raster>(proxy, subset, bm, props); 416 return sk_make_sp<SkSpecialImage_Raster>(subset, bm, props);
435 } 417 }
436 418
437 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromPixmap(SkImageFilter::Proxy* proxy , 419 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromPixmap(const SkIRect& subset,
438 const SkIRect& subset,
439 const SkPixmap& src, 420 const SkPixmap& src,
440 RasterReleaseProc releasePr oc, 421 RasterReleaseProc releasePr oc,
441 ReleaseContext context, 422 ReleaseContext context,
442 const SkSurfaceProps* props ) { 423 const SkSurfaceProps* props ) {
443 if (!src.addr()) { 424 if (!src.addr()) {
444 return nullptr; 425 return nullptr;
445 } 426 }
446 427
447 return sk_make_sp<SkSpecialImage_Raster>(proxy, subset, src, releaseProc, co ntext, props); 428 return sk_make_sp<SkSpecialImage_Raster>(subset, src, releaseProc, context, props);
448 } 429 }
449 430
450 431
451 #if SK_SUPPORT_GPU 432 #if SK_SUPPORT_GPU
452 /////////////////////////////////////////////////////////////////////////////// 433 ///////////////////////////////////////////////////////////////////////////////
453 #include "GrTexture.h" 434 #include "GrTexture.h"
454 #include "SkImage_Gpu.h" 435 #include "SkImage_Gpu.h"
455 436
456 class SkSpecialImage_Gpu : public SkSpecialImage_Base { 437 class SkSpecialImage_Gpu : public SkSpecialImage_Base {
457 public: 438 public:
458 SkSpecialImage_Gpu(SkImageFilter::Proxy* proxy, const SkIRect& subset, 439 SkSpecialImage_Gpu(const SkIRect& subset,
459 uint32_t uniqueID, GrTexture* tex, SkAlphaType at, 440 uint32_t uniqueID, GrTexture* tex, SkAlphaType at,
460 const SkSurfaceProps* props) 441 const SkSurfaceProps* props)
461 : INHERITED(proxy, subset, uniqueID, props) 442 : INHERITED(subset, uniqueID, props)
462 , fTexture(SkRef(tex)) 443 , fTexture(SkRef(tex))
463 , fAlphaType(at) 444 , fAlphaType(at)
464 , fAddedRasterVersionToCache(false) { 445 , fAddedRasterVersionToCache(false) {
465 } 446 }
466 447
467 ~SkSpecialImage_Gpu() override { 448 ~SkSpecialImage_Gpu() override {
468 if (fAddedRasterVersionToCache.load()) { 449 if (fAddedRasterVersionToCache.load()) {
469 SkNotifyBitmapGenIDIsStale(this->uniqueID()); 450 SkNotifyBitmapGenIDIsStale(this->uniqueID());
470 } 451 }
471 } 452 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 517 }
537 518
538 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid e { 519 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid e {
539 if (!fTexture->getContext()) { 520 if (!fTexture->getContext()) {
540 return nullptr; 521 return nullptr;
541 } 522 }
542 523
543 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *fTexture->getContex t()->caps()); 524 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *fTexture->getContex t()->caps());
544 desc.fFlags = kRenderTarget_GrSurfaceFlag; 525 desc.fFlags = kRenderTarget_GrSurfaceFlag;
545 526
546 return SkSpecialSurface::MakeRenderTarget(this->proxy(), fTexture->getCo ntext(), desc); 527 return SkSpecialSurface::MakeRenderTarget(fTexture->getContext(), desc);
547 } 528 }
548 529
549 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { 530 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
550 return SkSpecialImage::MakeFromGpu(this->internal_getProxy(), 531 return SkSpecialImage::MakeFromGpu(subset,
551 subset,
552 this->uniqueID(), 532 this->uniqueID(),
553 fTexture, 533 fTexture,
554 &this->props(), 534 &this->props(),
555 fAlphaType); 535 fAlphaType);
556 } 536 }
557 537
558 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override { 538 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override {
559 if (0 == subset.fLeft && 0 == subset.fTop && 539 if (0 == subset.fLeft && 0 == subset.fTop &&
560 fTexture->width() == subset.width() && 540 fTexture->width() == subset.width() &&
561 fTexture->height() == subset.height()) { 541 fTexture->height() == subset.height()) {
(...skipping 23 matching lines...) Expand all
585 } 565 }
586 566
587 private: 567 private:
588 SkAutoTUnref<GrTexture> fTexture; 568 SkAutoTUnref<GrTexture> fTexture;
589 const SkAlphaType fAlphaType; 569 const SkAlphaType fAlphaType;
590 mutable SkAtomic<bool> fAddedRasterVersionToCache; 570 mutable SkAtomic<bool> fAddedRasterVersionToCache;
591 571
592 typedef SkSpecialImage_Base INHERITED; 572 typedef SkSpecialImage_Base INHERITED;
593 }; 573 };
594 574
595 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy, 575 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset,
596 const SkIRect& subset,
597 uint32_t uniqueID, 576 uint32_t uniqueID,
598 GrTexture* tex, 577 GrTexture* tex,
599 const SkSurfaceProps* props, 578 const SkSurfaceProps* props,
600 SkAlphaType at) { 579 SkAlphaType at) {
601 SkASSERT(rect_fits(subset, tex->width(), tex->height())); 580 SkASSERT(rect_fits(subset, tex->width(), tex->height()));
602 return sk_make_sp<SkSpecialImage_Gpu>(proxy, subset, uniqueID, tex, at, prop s); 581 return sk_make_sp<SkSpecialImage_Gpu>(subset, uniqueID, tex, at, props);
603 } 582 }
604 583
605 #else 584 #else
606 585
607 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy, 586 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset,
608 const SkIRect& subset,
609 uint32_t uniqueID, 587 uint32_t uniqueID,
610 GrTexture* tex, 588 GrTexture* tex,
611 const SkSurfaceProps* props, 589 const SkSurfaceProps* props,
612 SkAlphaType at) { 590 SkAlphaType at) {
613 return nullptr; 591 return nullptr;
614 } 592 }
615 593
616 #endif 594 #endif
OLDNEW
« no previous file with comments | « src/core/SkSpecialImage.h ('k') | src/core/SkSpecialSurface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698