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

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

Issue 1817383002: switch surface to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/SkRecorder.cpp ('k') | src/gpu/GrLayerHoister.cpp » ('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"
(...skipping 23 matching lines...) Expand all
34 34
35 // Delete this entry point ASAP (see skbug.com/4965) 35 // Delete this entry point ASAP (see skbug.com/4965)
36 virtual bool getBitmapDeprecated(SkBitmap* result) const = 0; 36 virtual bool getBitmapDeprecated(SkBitmap* result) const = 0;
37 37
38 virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0; 38 virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0;
39 39
40 virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const = 0; 40 virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const = 0;
41 41
42 virtual sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const = 0; 42 virtual sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const = 0;
43 43
44 virtual SkSurface* onMakeTightSurface(const SkImageInfo& info) const = 0; 44 virtual sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const = 0;
45 45
46 private: 46 private:
47 typedef SkSpecialImage INHERITED; 47 typedef SkSpecialImage INHERITED;
48 }; 48 };
49 49
50 /////////////////////////////////////////////////////////////////////////////// 50 ///////////////////////////////////////////////////////////////////////////////
51 static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) { 51 static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) {
52 return static_cast<const SkSpecialImage_Base*>(image); 52 return static_cast<const SkSpecialImage_Base*>(image);
53 } 53 }
54 54
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 bool SkSpecialImage::testingOnlyGetROPixels(SkBitmap* result) const { 99 bool SkSpecialImage::testingOnlyGetROPixels(SkBitmap* result) const {
100 return as_SIB(this)->testingOnlyOnGetROPixels(result); 100 return as_SIB(this)->testingOnlyOnGetROPixels(result);
101 } 101 }
102 102
103 sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkImageInfo& info) con st { 103 sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkImageInfo& info) con st {
104 return as_SIB(this)->onMakeSurface(info); 104 return as_SIB(this)->onMakeSurface(info);
105 } 105 }
106 106
107 sk_sp<SkSurface> SkSpecialImage::makeTightSurface(const SkImageInfo& info) const { 107 sk_sp<SkSurface> SkSpecialImage::makeTightSurface(const SkImageInfo& info) const {
108 sk_sp<SkSurface> tmp(as_SIB(this)->onMakeTightSurface(info)); 108 return as_SIB(this)->onMakeTightSurface(info);
109 return tmp;
110 } 109 }
111 110
112 sk_sp<SkSpecialImage> SkSpecialImage::makeSubset(const SkIRect& subset) const { 111 sk_sp<SkSpecialImage> SkSpecialImage::makeSubset(const SkIRect& subset) const {
113 return as_SIB(this)->onMakeSubset(subset); 112 return as_SIB(this)->onMakeSubset(subset);
114 } 113 }
115 114
116 sk_sp<SkImage> SkSpecialImage::makeTightSubset(const SkIRect& subset) const { 115 sk_sp<SkImage> SkSpecialImage::makeTightSubset(const SkIRect& subset) const {
117 return as_SIB(this)->onMakeTightSubset(subset); 116 return as_SIB(this)->onMakeTightSubset(subset);
118 } 117 }
119 118
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 236
238 return SkSpecialImage::MakeFromImage(this->internal_getProxy(), 237 return SkSpecialImage::MakeFromImage(this->internal_getProxy(),
239 SkIRect::MakeWH(subset.width(), sub set.height()), 238 SkIRect::MakeWH(subset.width(), sub set.height()),
240 subsetImg); 239 subsetImg);
241 } 240 }
242 241
243 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override { 242 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override {
244 return fImage->makeSubset(subset); 243 return fImage->makeSubset(subset);
245 } 244 }
246 245
247 SkSurface* onMakeTightSurface(const SkImageInfo& info) const override { 246 sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override {
248 #if SK_SUPPORT_GPU 247 #if SK_SUPPORT_GPU
249 GrTexture* texture = as_IB(fImage.get())->peekTexture(); 248 GrTexture* texture = as_IB(fImage.get())->peekTexture();
250 if (texture) { 249 if (texture) {
251 return SkSurface::NewRenderTarget(texture->getContext(), SkBudgeted: :kYes, info, 0); 250 return SkSurface::MakeRenderTarget(texture->getContext(), SkBudgeted ::kYes, info);
252 } 251 }
253 #endif 252 #endif
254 return SkSurface::NewRaster(info, nullptr); 253 return SkSurface::MakeRaster(info, nullptr);
255 } 254 }
256 255
257 private: 256 private:
258 sk_sp<SkImage> fImage; 257 sk_sp<SkImage> fImage;
259 258
260 typedef SkSpecialImage_Base INHERITED; 259 typedef SkSpecialImage_Base INHERITED;
261 }; 260 };
262 261
263 #ifdef SK_DEBUG 262 #ifdef SK_DEBUG
264 static bool rect_fits(const SkIRect& rect, int width, int height) { 263 static bool rect_fits(const SkIRect& rect, int width, int height) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override { 361 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override {
363 SkBitmap subsetBM; 362 SkBitmap subsetBM;
364 363
365 if (!fBitmap.extractSubset(&subsetBM, subset)) { 364 if (!fBitmap.extractSubset(&subsetBM, subset)) {
366 return nullptr; 365 return nullptr;
367 } 366 }
368 367
369 return SkImage::MakeFromBitmap(subsetBM); 368 return SkImage::MakeFromBitmap(subsetBM);
370 } 369 }
371 370
372 SkSurface* onMakeTightSurface(const SkImageInfo& info) const override { 371 sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override {
373 return SkSurface::NewRaster(info); 372 return SkSurface::MakeRaster(info);
374 } 373 }
375 374
376 private: 375 private:
377 SkBitmap fBitmap; 376 SkBitmap fBitmap;
378 377
379 typedef SkSpecialImage_Base INHERITED; 378 typedef SkSpecialImage_Base INHERITED;
380 }; 379 };
381 380
382 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(SkImageFilter::Proxy* proxy , 381 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(SkImageFilter::Proxy* proxy ,
383 const SkIRect& subset, 382 const SkIRect& subset,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 SkAutoTUnref<GrTexture> subTx(ctx->textureProvider()->createTexture(desc , 504 SkAutoTUnref<GrTexture> subTx(ctx->textureProvider()->createTexture(desc ,
506 SkBu dgeted::kYes)); 505 SkBu dgeted::kYes));
507 if (!subTx) { 506 if (!subTx) {
508 return nullptr; 507 return nullptr;
509 } 508 }
510 ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0)); 509 ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0));
511 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageU niqueID, 510 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageU niqueID,
512 fAlphaType, subTx, SkBudgeted::kYes); 511 fAlphaType, subTx, SkBudgeted::kYes);
513 } 512 }
514 513
515 SkSurface* onMakeTightSurface(const SkImageInfo& info) const override { 514 sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override {
516 return SkSurface::NewRenderTarget(fTexture->getContext(), SkBudgeted::kY es, info); 515 return SkSurface::MakeRenderTarget(fTexture->getContext(), SkBudgeted::k Yes, info);
517 } 516 }
518 517
519 private: 518 private:
520 SkAutoTUnref<GrTexture> fTexture; 519 SkAutoTUnref<GrTexture> fTexture;
521 const SkAlphaType fAlphaType; 520 const SkAlphaType fAlphaType;
522 521
523 typedef SkSpecialImage_Base INHERITED; 522 typedef SkSpecialImage_Base INHERITED;
524 }; 523 };
525 524
526 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy, 525 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy,
527 const SkIRect& subset, 526 const SkIRect& subset,
528 uint32_t uniqueID, 527 uint32_t uniqueID,
529 GrTexture* tex, 528 GrTexture* tex,
530 SkAlphaType at) { 529 SkAlphaType at) {
531 SkASSERT(rect_fits(subset, tex->width(), tex->height())); 530 SkASSERT(rect_fits(subset, tex->width(), tex->height()));
532 return sk_make_sp<SkSpecialImage_Gpu>(proxy, subset, uniqueID, tex, at); 531 return sk_make_sp<SkSpecialImage_Gpu>(proxy, subset, uniqueID, tex, at);
533 } 532 }
534 533
535 #else 534 #else
536 535
537 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy, 536 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy,
538 const SkIRect& subset, 537 const SkIRect& subset,
539 uint32_t uniqueID, 538 uint32_t uniqueID,
540 GrTexture* tex, 539 GrTexture* tex,
541 SkAlphaType at) { 540 SkAlphaType at) {
542 return nullptr; 541 return nullptr;
543 } 542 }
544 543
545 #endif 544 #endif
OLDNEW
« no previous file with comments | « src/core/SkRecorder.cpp ('k') | src/gpu/GrLayerHoister.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698