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

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

Issue 2163343002: Adding color space to SkSpecialImage (Closed) Base URL: https://skia.googlesource.com/skia.git@colorspace-on-image
Patch Set: Created 4 years, 5 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
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 21 matching lines...) Expand all
32 : INHERITED(subset, uniqueID, props) { 32 : INHERITED(subset, uniqueID, props) {
33 } 33 }
34 ~SkSpecialImage_Base() override { } 34 ~SkSpecialImage_Base() override { }
35 35
36 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const = 0; 36 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const = 0;
37 37
38 virtual bool onGetROPixels(SkBitmap*) const = 0; 38 virtual bool onGetROPixels(SkBitmap*) const = 0;
39 39
40 virtual GrTexture* onPeekTexture() const { return nullptr; } 40 virtual GrTexture* onPeekTexture() const { return nullptr; }
41 41
42 virtual SkColorSpace* onGetColorSpace() const = 0;
43
42 #if SK_SUPPORT_GPU 44 #if SK_SUPPORT_GPU
43 virtual sk_sp<GrTexture> onAsTextureRef(GrContext* context) const = 0; 45 virtual sk_sp<GrTexture> onAsTextureRef(GrContext* context) const = 0;
44 #endif 46 #endif
45 47
46 // Delete this entry point ASAP (see skbug.com/4965) 48 // Delete this entry point ASAP (see skbug.com/4965)
47 virtual bool getBitmapDeprecated(SkBitmap* result) const = 0; 49 virtual bool getBitmapDeprecated(SkBitmap* result) const = 0;
48 50
49 virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0; 51 virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0;
50 52
51 virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const = 0; 53 virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const = 0;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 GrTextureParams::ClampNo Filter(), 96 GrTextureParams::ClampNo Filter(),
95 SkSourceGammaTreatment:: kRespect)); 97 SkSourceGammaTreatment:: kRespect));
96 if (!resultTex) { 98 if (!resultTex) {
97 return nullptr; 99 return nullptr;
98 } 100 }
99 101
100 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp e; 102 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp e;
101 103
102 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(resultTex->width(), resul tTex->height()), 104 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(resultTex->width(), resul tTex->height()),
103 this->uniqueID(), 105 this->uniqueID(),
104 resultTex, &this->props(), at); 106 resultTex, sk_ref_sp(this->getColorSpace( )), &this->props(),
107 at);
105 #else 108 #else
106 return nullptr; 109 return nullptr;
107 #endif 110 #endif
108 } 111 }
109 112
110 void SkSpecialImage::draw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPain t* paint) const { 113 void SkSpecialImage::draw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPain t* paint) const {
111 return as_SIB(this)->onDraw(canvas, x, y, paint); 114 return as_SIB(this)->onDraw(canvas, x, y, paint);
112 } 115 }
113 116
114 bool SkSpecialImage::getROPixels(SkBitmap* bm) const { 117 bool SkSpecialImage::getROPixels(SkBitmap* bm) const {
(...skipping 12 matching lines...) Expand all
127 #if SK_SUPPORT_GPU 130 #if SK_SUPPORT_GPU
128 GrTexture* texture = as_SIB(this)->onPeekTexture(); 131 GrTexture* texture = as_SIB(this)->onPeekTexture();
129 132
130 if (texture) { 133 if (texture) {
131 return texture->getContext(); 134 return texture->getContext();
132 } 135 }
133 #endif 136 #endif
134 return nullptr; 137 return nullptr;
135 } 138 }
136 139
140 SkColorSpace* SkSpecialImage::getColorSpace() const {
141 return as_SIB(this)->onGetColorSpace();
142 }
143
137 #if SK_SUPPORT_GPU 144 #if SK_SUPPORT_GPU
138 sk_sp<GrTexture> SkSpecialImage::asTextureRef(GrContext* context) const { 145 sk_sp<GrTexture> SkSpecialImage::asTextureRef(GrContext* context) const {
139 return as_SIB(this)->onAsTextureRef(context); 146 return as_SIB(this)->onAsTextureRef(context);
140 } 147 }
141 #endif 148 #endif
142 149
143 sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkImageInfo& info) con st { 150 sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkImageInfo& info) con st {
144 return as_SIB(this)->onMakeSurface(info); 151 return as_SIB(this)->onMakeSurface(info);
145 } 152 }
146 153
(...skipping 15 matching lines...) Expand all
162 #endif 169 #endif
163 170
164 sk_sp<SkSpecialImage> SkSpecialImage::internal_fromBM(const SkBitmap& src, 171 sk_sp<SkSpecialImage> SkSpecialImage::internal_fromBM(const SkBitmap& src,
165 const SkSurfaceProps* prop s) { 172 const SkSurfaceProps* prop s) {
166 #if SK_SUPPORT_GPU 173 #if SK_SUPPORT_GPU
167 // Need to test offset case! (see skbug.com/4967) 174 // Need to test offset case! (see skbug.com/4967)
168 if (src.getTexture()) { 175 if (src.getTexture()) {
169 return SkSpecialImage::MakeFromGpu(src.bounds(), 176 return SkSpecialImage::MakeFromGpu(src.bounds(),
170 src.getGenerationID(), 177 src.getGenerationID(),
171 sk_ref_sp(src.getTexture()), 178 sk_ref_sp(src.getTexture()),
179 sk_ref_sp(src.colorSpace()),
172 props); 180 props);
173 } 181 }
174 #endif 182 #endif
175 183
176 return SkSpecialImage::MakeFromRaster(src.bounds(), src, props); 184 return SkSpecialImage::MakeFromRaster(src.bounds(), src, props);
177 } 185 }
178 186
179 bool SkSpecialImage::internal_getBM(SkBitmap* result) { 187 bool SkSpecialImage::internal_getBM(SkBitmap* result) {
180 const SkSpecialImage_Base* ib = as_SIB(this); 188 const SkSpecialImage_Base* ib = as_SIB(this);
181 189
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 SkRect dst = SkRect::MakeXYWH(x, y, this->subset().width(), this->subset ().height()); 230 SkRect dst = SkRect::MakeXYWH(x, y, this->subset().width(), this->subset ().height());
223 231
224 canvas->drawImageRect(fImage.get(), this->subset(), 232 canvas->drawImageRect(fImage.get(), this->subset(),
225 dst, paint, SkCanvas::kStrict_SrcRectConstraint); 233 dst, paint, SkCanvas::kStrict_SrcRectConstraint);
226 } 234 }
227 235
228 bool onGetROPixels(SkBitmap* bm) const override { 236 bool onGetROPixels(SkBitmap* bm) const override {
229 return as_IB(fImage)->getROPixels(bm); 237 return as_IB(fImage)->getROPixels(bm);
230 } 238 }
231 239
240 SkColorSpace* onGetColorSpace() const override {
241 return as_IB(fImage)->onImageInfo().colorSpace();
242 }
243
232 GrTexture* onPeekTexture() const override { return as_IB(fImage)->peekTextur e(); } 244 GrTexture* onPeekTexture() const override { return as_IB(fImage)->peekTextur e(); }
233 245
234 #if SK_SUPPORT_GPU 246 #if SK_SUPPORT_GPU
235 sk_sp<GrTexture> onAsTextureRef(GrContext* context) const override { 247 sk_sp<GrTexture> onAsTextureRef(GrContext* context) const override {
236 return sk_sp<GrTexture>(as_IB(fImage)->asTextureRef(context, 248 return sk_sp<GrTexture>(as_IB(fImage)->asTextureRef(context,
237 GrTextureParams::Cla mpNoFilter(), 249 GrTextureParams::Cla mpNoFilter(),
238 SkSourceGammaTreatme nt::kRespect)); 250 SkSourceGammaTreatme nt::kRespect));
239 } 251 }
240 #endif 252 #endif
241 253
242 bool getBitmapDeprecated(SkBitmap* result) const override { 254 bool getBitmapDeprecated(SkBitmap* result) const override {
243 #if SK_SUPPORT_GPU 255 #if SK_SUPPORT_GPU
244 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) { 256 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) {
245 const SkImageInfo info = GrMakeInfoFromTexture(texture, 257 const SkImageInfo info = GrMakeInfoFromTexture(texture,
246 fImage->width(), fIma ge->height(), 258 fImage->width(), fIma ge->height(),
247 fImage->isOpaque()); 259 fImage->isOpaque(),
260 sk_ref_sp(this->onGet ColorSpace()));
248 if (!result->setInfo(info)) { 261 if (!result->setInfo(info)) {
249 return false; 262 return false;
250 } 263 }
251 264
252 result->setPixelRef(new SkGrPixelRef(info, texture))->unref(); 265 result->setPixelRef(new SkGrPixelRef(info, texture))->unref();
253 return true; 266 return true;
254 } 267 }
255 #endif 268 #endif
256 269
257 return as_IB(fImage.get())->asBitmapForImageFilters(result); 270 return as_IB(fImage.get())->asBitmapForImageFilters(result);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 369
357 canvas->drawBitmapRect(fBitmap, this->subset(), 370 canvas->drawBitmapRect(fBitmap, this->subset(),
358 dst, paint, SkCanvas::kStrict_SrcRectConstraint); 371 dst, paint, SkCanvas::kStrict_SrcRectConstraint);
359 } 372 }
360 373
361 bool onGetROPixels(SkBitmap* bm) const override { 374 bool onGetROPixels(SkBitmap* bm) const override {
362 *bm = fBitmap; 375 *bm = fBitmap;
363 return true; 376 return true;
364 } 377 }
365 378
379 SkColorSpace* onGetColorSpace() const override {
380 return fBitmap.colorSpace();
381 }
382
366 #if SK_SUPPORT_GPU 383 #if SK_SUPPORT_GPU
367 sk_sp<GrTexture> onAsTextureRef(GrContext* context) const override { 384 sk_sp<GrTexture> onAsTextureRef(GrContext* context) const override {
368 if (context) { 385 if (context) {
369 return sk_ref_sp(GrRefCachedBitmapTexture(context, 386 return sk_ref_sp(GrRefCachedBitmapTexture(context,
370 fBitmap, 387 fBitmap,
371 GrTextureParams::ClampNoFi lter(), 388 GrTextureParams::ClampNoFi lter(),
372 SkSourceGammaTreatment::kR espect)); 389 SkSourceGammaTreatment::kR espect));
373 } 390 }
374 391
375 return nullptr; 392 return nullptr;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 454
438 #if SK_SUPPORT_GPU 455 #if SK_SUPPORT_GPU
439 /////////////////////////////////////////////////////////////////////////////// 456 ///////////////////////////////////////////////////////////////////////////////
440 #include "GrTexture.h" 457 #include "GrTexture.h"
441 #include "SkImage_Gpu.h" 458 #include "SkImage_Gpu.h"
442 459
443 class SkSpecialImage_Gpu : public SkSpecialImage_Base { 460 class SkSpecialImage_Gpu : public SkSpecialImage_Base {
444 public: 461 public:
445 SkSpecialImage_Gpu(const SkIRect& subset, 462 SkSpecialImage_Gpu(const SkIRect& subset,
446 uint32_t uniqueID, sk_sp<GrTexture> tex, SkAlphaType at, 463 uint32_t uniqueID, sk_sp<GrTexture> tex, SkAlphaType at,
447 const SkSurfaceProps* props) 464 sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* pro ps)
448 : INHERITED(subset, uniqueID, props) 465 : INHERITED(subset, uniqueID, props)
449 , fTexture(std::move(tex)) 466 , fTexture(std::move(tex))
450 , fAlphaType(at) 467 , fAlphaType(at)
468 , fColorSpace(std::move(colorSpace))
451 , fAddedRasterVersionToCache(false) { 469 , fAddedRasterVersionToCache(false) {
452 } 470 }
453 471
454 ~SkSpecialImage_Gpu() override { 472 ~SkSpecialImage_Gpu() override {
455 if (fAddedRasterVersionToCache.load()) { 473 if (fAddedRasterVersionToCache.load()) {
456 SkNotifyBitmapGenIDIsStale(this->uniqueID()); 474 SkNotifyBitmapGenIDIsStale(this->uniqueID());
457 } 475 }
458 } 476 }
459 477
460 bool isOpaque() const override { 478 bool isOpaque() const override {
461 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaqu e_SkAlphaType; 479 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaqu e_SkAlphaType;
462 } 480 }
463 481
464 size_t getSize() const override { return fTexture->gpuMemorySize(); } 482 size_t getSize() const override { return fTexture->gpuMemorySize(); }
465 483
466 void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const override { 484 void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const override {
467 SkRect dst = SkRect::MakeXYWH(x, y, 485 SkRect dst = SkRect::MakeXYWH(x, y,
468 this->subset().width(), this->subset().hei ght()); 486 this->subset().width(), this->subset().hei ght());
469 487
470 // TODO: Supply correct color space after we're storing it here
471 auto img = sk_sp<SkImage>(new SkImage_Gpu(fTexture->width(), fTexture->h eight(), 488 auto img = sk_sp<SkImage>(new SkImage_Gpu(fTexture->width(), fTexture->h eight(),
472 this->uniqueID(), fAlphaType, fTexture.get(), 489 this->uniqueID(), fAlphaType, fTexture.get(),
473 nullptr, SkBudgeted::kNo)); 490 fColorSpace, SkBudgeted::kNo)) ;
474 491
475 canvas->drawImageRect(img, this->subset(), 492 canvas->drawImageRect(img, this->subset(),
476 dst, paint, SkCanvas::kStrict_SrcRectConstraint); 493 dst, paint, SkCanvas::kStrict_SrcRectConstraint);
477 } 494 }
478 495
479 GrTexture* onPeekTexture() const override { return fTexture.get(); } 496 GrTexture* onPeekTexture() const override { return fTexture.get(); }
480 497
481 sk_sp<GrTexture> onAsTextureRef(GrContext*) const override { return fTexture ; } 498 sk_sp<GrTexture> onAsTextureRef(GrContext*) const override { return fTexture ; }
482 499
483 bool onGetROPixels(SkBitmap* dst) const override { 500 bool onGetROPixels(SkBitmap* dst) const override {
484 if (SkBitmapCache::Find(this->uniqueID(), dst)) { 501 if (SkBitmapCache::Find(this->uniqueID(), dst)) {
485 SkASSERT(dst->getGenerationID() == this->uniqueID()); 502 SkASSERT(dst->getGenerationID() == this->uniqueID());
486 SkASSERT(dst->isImmutable()); 503 SkASSERT(dst->isImmutable());
487 SkASSERT(dst->getPixels()); 504 SkASSERT(dst->getPixels());
488 return true; 505 return true;
489 } 506 }
490 507
491 SkImageInfo info = SkImageInfo::MakeN32(this->width(), this->height(), 508 SkImageInfo info = SkImageInfo::MakeN32(this->width(), this->height(),
492 this->isOpaque() ? kOpaque_SkAlp haType 509 this->isOpaque() ? kOpaque_SkAlp haType
493 : kPremul_SkAlp haType); 510 : kPremul_SkAlp haType,
511 fColorSpace);
494 512
495 if (!dst->tryAllocPixels(info)) { 513 if (!dst->tryAllocPixels(info)) {
496 return false; 514 return false;
497 } 515 }
498 516
499 if (!fTexture->readPixels(0, 0, dst->width(), dst->height(), kSkia8888_G rPixelConfig, 517 if (!fTexture->readPixels(0, 0, dst->width(), dst->height(), kSkia8888_G rPixelConfig,
500 dst->getPixels(), dst->rowBytes())) { 518 dst->getPixels(), dst->rowBytes())) {
501 return false; 519 return false;
502 } 520 }
503 521
504 dst->pixelRef()->setImmutableWithID(this->uniqueID()); 522 dst->pixelRef()->setImmutableWithID(this->uniqueID());
505 SkBitmapCache::Add(this->uniqueID(), *dst); 523 SkBitmapCache::Add(this->uniqueID(), *dst);
506 fAddedRasterVersionToCache.store(true); 524 fAddedRasterVersionToCache.store(true);
507 return true; 525 return true;
508 } 526 }
509 527
528 SkColorSpace* onGetColorSpace() const override {
529 return fColorSpace.get();
530 }
531
510 bool getBitmapDeprecated(SkBitmap* result) const override { 532 bool getBitmapDeprecated(SkBitmap* result) const override {
511 const SkImageInfo info = GrMakeInfoFromTexture(fTexture.get(), 533 const SkImageInfo info = GrMakeInfoFromTexture(fTexture.get(),
512 this->width(), this->heig ht(), 534 this->width(), this->heig ht(),
513 this->isOpaque()); 535 this->isOpaque(), fColorS pace);
514 if (!result->setInfo(info)) { 536 if (!result->setInfo(info)) {
515 return false; 537 return false;
516 } 538 }
517 539
518 const SkImageInfo prInfo = info.makeWH(fTexture->width(), fTexture->heig ht()); 540 const SkImageInfo prInfo = info.makeWH(fTexture->width(), fTexture->heig ht());
519 541
520 SkAutoTUnref<SkGrPixelRef> pixelRef(new SkGrPixelRef(prInfo, fTexture.ge t())); 542 SkAutoTUnref<SkGrPixelRef> pixelRef(new SkGrPixelRef(prInfo, fTexture.ge t()));
521 result->setPixelRef(pixelRef, this->subset().fLeft, this->subset().fTop) ; 543 result->setPixelRef(pixelRef, this->subset().fLeft, this->subset().fTop) ;
522 return true; 544 return true;
523 } 545 }
524 546
525 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid e { 547 sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const overrid e {
526 if (!fTexture->getContext()) { 548 if (!fTexture->getContext()) {
527 return nullptr; 549 return nullptr;
528 } 550 }
529 551
530 GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fTexture->getCon text()->caps()); 552 GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fTexture->getCon text()->caps());
531 553
532 return SkSpecialSurface::MakeRenderTarget(fTexture->getContext(), 554 return SkSpecialSurface::MakeRenderTarget(fTexture->getContext(),
533 info.width(), info.height(), 555 info.width(), info.height(),
534 config); 556 config);
535 } 557 }
536 558
537 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { 559 sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
538 return SkSpecialImage::MakeFromGpu(subset, 560 return SkSpecialImage::MakeFromGpu(subset,
539 this->uniqueID(), 561 this->uniqueID(),
540 fTexture, 562 fTexture,
563 fColorSpace,
541 &this->props(), 564 &this->props(),
542 fAlphaType); 565 fAlphaType);
543 } 566 }
544 567
545 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override { 568 sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const override {
546 if (0 == subset.fLeft && 0 == subset.fTop && 569 if (0 == subset.fLeft && 0 == subset.fTop &&
547 fTexture->width() == subset.width() && 570 fTexture->width() == subset.width() &&
548 fTexture->height() == subset.height()) { 571 fTexture->height() == subset.height()) {
549 // The existing GrTexture is already tight so reuse it in the SkImag e 572 // The existing GrTexture is already tight so reuse it in the SkImag e
550 // TODO: Supply correct color space after we're storing it here
551 return sk_make_sp<SkImage_Gpu>(fTexture->width(), fTexture->height() , 573 return sk_make_sp<SkImage_Gpu>(fTexture->width(), fTexture->height() ,
552 kNeedNewImageUniqueID, 574 kNeedNewImageUniqueID,
553 fAlphaType, fTexture.get(), nullptr, SkBudgeted::kYes); 575 fAlphaType, fTexture.get(), fColorSpa ce,
576 SkBudgeted::kYes);
554 } 577 }
555 578
556 GrContext* ctx = fTexture->getContext(); 579 GrContext* ctx = fTexture->getContext();
557 GrSurfaceDesc desc = fTexture->desc(); 580 GrSurfaceDesc desc = fTexture->desc();
558 desc.fWidth = subset.width(); 581 desc.fWidth = subset.width();
559 desc.fHeight = subset.height(); 582 desc.fHeight = subset.height();
560 583
561 sk_sp<GrTexture> subTx(ctx->textureProvider()->createTexture(desc, SkBud geted::kYes)); 584 sk_sp<GrTexture> subTx(ctx->textureProvider()->createTexture(desc, SkBud geted::kYes));
562 if (!subTx) { 585 if (!subTx) {
563 return nullptr; 586 return nullptr;
564 } 587 }
565 ctx->copySurface(subTx.get(), fTexture.get(), subset, SkIPoint::Make(0, 0)); 588 ctx->copySurface(subTx.get(), fTexture.get(), subset, SkIPoint::Make(0, 0));
566 // TODO: Supply correct color space after we're storing it here
567 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageU niqueID, 589 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageU niqueID,
568 fAlphaType, subTx.get(), nullptr, SkBudge ted::kYes); 590 fAlphaType, subTx.get(), fColorSpace, SkB udgeted::kYes);
569 } 591 }
570 592
571 sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override { 593 sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override {
572 return SkSurface::MakeRenderTarget(fTexture->getContext(), SkBudgeted::k Yes, info); 594 return SkSurface::MakeRenderTarget(fTexture->getContext(), SkBudgeted::k Yes, info);
573 } 595 }
574 596
575 private: 597 private:
576 sk_sp<GrTexture> fTexture; 598 sk_sp<GrTexture> fTexture;
577 const SkAlphaType fAlphaType; 599 const SkAlphaType fAlphaType;
600 sk_sp<SkColorSpace> fColorSpace;
578 mutable SkAtomic<bool> fAddedRasterVersionToCache; 601 mutable SkAtomic<bool> fAddedRasterVersionToCache;
579 602
580 typedef SkSpecialImage_Base INHERITED; 603 typedef SkSpecialImage_Base INHERITED;
581 }; 604 };
582 605
583 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset, 606 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset,
584 uint32_t uniqueID, 607 uint32_t uniqueID,
585 sk_sp<GrTexture> tex, 608 sk_sp<GrTexture> tex,
609 sk_sp<SkColorSpace> colorSpace ,
586 const SkSurfaceProps* props, 610 const SkSurfaceProps* props,
587 SkAlphaType at) { 611 SkAlphaType at) {
588 SkASSERT(rect_fits(subset, tex->width(), tex->height())); 612 SkASSERT(rect_fits(subset, tex->width(), tex->height()));
589 return sk_make_sp<SkSpecialImage_Gpu>(subset, uniqueID, std::move(tex), at, props); 613 return sk_make_sp<SkSpecialImage_Gpu>(subset, uniqueID, std::move(tex), at,
614 std::move(colorSpace), props);
590 } 615 }
591 616
592 #endif 617 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698