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

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

Issue 2037413002: Add SkSourceGammaTreatment enum so we know how to create mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix DM compilation Created 4 years, 6 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/SkShader.cpp ('k') | src/effects/SkPerlinNoiseShader.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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 if (!this->internal_getBM(&bmp)) { 77 if (!this->internal_getBM(&bmp)) {
78 return nullptr; 78 return nullptr;
79 } 79 }
80 80
81 if (bmp.empty()) { 81 if (bmp.empty()) {
82 return SkSpecialImage::MakeFromRaster(SkIRect::MakeEmpty(), bmp, &this-> props()); 82 return SkSpecialImage::MakeFromRaster(SkIRect::MakeEmpty(), bmp, &this-> props());
83 } 83 }
84 84
85 sk_sp<GrTexture> resultTex(GrRefCachedBitmapTexture(context, 85 sk_sp<GrTexture> resultTex(GrRefCachedBitmapTexture(context,
86 bmp, 86 bmp,
87 GrTextureParams::ClampNo Filter())); 87 GrTextureParams::ClampNo Filter(),
88 SkSourceGammaTreatment:: kRespect));
88 if (!resultTex) { 89 if (!resultTex) {
89 return nullptr; 90 return nullptr;
90 } 91 }
91 92
92 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp e; 93 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp e;
93 94
94 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(resultTex->width(), resul tTex->height()), 95 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(resultTex->width(), resul tTex->height()),
95 this->uniqueID(), 96 this->uniqueID(),
96 resultTex, &this->props(), at); 97 resultTex, &this->props(), at);
97 #else 98 #else
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 220
220 bool onGetROPixels(SkBitmap* bm) const override { 221 bool onGetROPixels(SkBitmap* bm) const override {
221 return as_IB(fImage)->getROPixels(bm); 222 return as_IB(fImage)->getROPixels(bm);
222 } 223 }
223 224
224 GrTexture* onPeekTexture() const override { return as_IB(fImage)->peekTextur e(); } 225 GrTexture* onPeekTexture() const override { return as_IB(fImage)->peekTextur e(); }
225 226
226 #if SK_SUPPORT_GPU 227 #if SK_SUPPORT_GPU
227 sk_sp<GrTexture> onAsTextureRef(GrContext* context) const override { 228 sk_sp<GrTexture> onAsTextureRef(GrContext* context) const override {
228 return sk_sp<GrTexture>(as_IB(fImage)->asTextureRef(context, 229 return sk_sp<GrTexture>(as_IB(fImage)->asTextureRef(context,
229 GrTextureParams::Cla mpNoFilter())); 230 GrTextureParams::Cla mpNoFilter(),
231 SkSourceGammaTreatme nt::kRespect));
230 } 232 }
231 #endif 233 #endif
232 234
233 bool getBitmapDeprecated(SkBitmap* result) const override { 235 bool getBitmapDeprecated(SkBitmap* result) const override {
234 #if SK_SUPPORT_GPU 236 #if SK_SUPPORT_GPU
235 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) { 237 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) {
236 const SkImageInfo info = GrMakeInfoFromTexture(texture, 238 const SkImageInfo info = GrMakeInfoFromTexture(texture,
237 fImage->width(), fIma ge->height(), 239 fImage->width(), fIma ge->height(),
238 fImage->isOpaque()); 240 fImage->isOpaque());
239 if (!result->setInfo(info)) { 241 if (!result->setInfo(info)) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 bool onGetROPixels(SkBitmap* bm) const override { 363 bool onGetROPixels(SkBitmap* bm) const override {
362 *bm = fBitmap; 364 *bm = fBitmap;
363 return true; 365 return true;
364 } 366 }
365 367
366 #if SK_SUPPORT_GPU 368 #if SK_SUPPORT_GPU
367 sk_sp<GrTexture> onAsTextureRef(GrContext* context) const override { 369 sk_sp<GrTexture> onAsTextureRef(GrContext* context) const override {
368 if (context) { 370 if (context) {
369 return sk_ref_sp(GrRefCachedBitmapTexture(context, 371 return sk_ref_sp(GrRefCachedBitmapTexture(context,
370 fBitmap, 372 fBitmap,
371 GrTextureParams::ClampNoFi lter())); 373 GrTextureParams::ClampNoFi lter(),
374 SkSourceGammaTreatment::kR espect));
372 } 375 }
373 376
374 return nullptr; 377 return nullptr;
375 } 378 }
376 #endif 379 #endif
377 380
378 bool getBitmapDeprecated(SkBitmap* result) const override { 381 bool getBitmapDeprecated(SkBitmap* result) const override {
379 *result = fBitmap; 382 *result = fBitmap;
380 return true; 383 return true;
381 } 384 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset, 587 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset,
585 uint32_t uniqueID, 588 uint32_t uniqueID,
586 sk_sp<GrTexture> tex, 589 sk_sp<GrTexture> tex,
587 const SkSurfaceProps* props, 590 const SkSurfaceProps* props,
588 SkAlphaType at) { 591 SkAlphaType at) {
589 SkASSERT(rect_fits(subset, tex->width(), tex->height())); 592 SkASSERT(rect_fits(subset, tex->width(), tex->height()));
590 return sk_make_sp<SkSpecialImage_Gpu>(subset, uniqueID, std::move(tex), at, props); 593 return sk_make_sp<SkSpecialImage_Gpu>(subset, uniqueID, std::move(tex), at, props);
591 } 594 }
592 595
593 #endif 596 #endif
OLDNEW
« no previous file with comments | « src/core/SkShader.cpp ('k') | src/effects/SkPerlinNoiseShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698