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

Side by Side Diff: src/image/SkImage_Gpu.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/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.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 2012 Google Inc. 2 * Copyright 2012 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 "SkAutoPixmapStorage.h" 8 #include "SkAutoPixmapStorage.h"
9 #include "GrCaps.h" 9 #include "GrCaps.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return true; 70 return true;
71 } 71 }
72 72
73 bool SkImage_Gpu::asBitmapForImageFilters(SkBitmap* bitmap) const { 73 bool SkImage_Gpu::asBitmapForImageFilters(SkBitmap* bitmap) const {
74 bitmap->setInfo(make_info(this->width(), this->height(), this->isOpaque())); 74 bitmap->setInfo(make_info(this->width(), this->height(), this->isOpaque()));
75 bitmap->setPixelRef(new SkGrPixelRef(bitmap->info(), fTexture))->unref(); 75 bitmap->setPixelRef(new SkGrPixelRef(bitmap->info(), fTexture))->unref();
76 bitmap->pixelRef()->setImmutableWithID(this->uniqueID()); 76 bitmap->pixelRef()->setImmutableWithID(this->uniqueID());
77 return true; 77 return true;
78 } 78 }
79 79
80 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& para ms) const { 80 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& para ms,
81 return GrImageTextureAdjuster(as_IB(this)).refTextureSafeForParams(params, n ullptr); 81 SkSourceGammaTreatment gammaTreatment) cons t {
82 return GrImageTextureAdjuster(as_IB(this)).refTextureSafeForParams(params, g ammaTreatment,
83 nullptr);
82 } 84 }
83 85
84 bool SkImage_Gpu::isOpaque() const { 86 bool SkImage_Gpu::isOpaque() const {
85 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_Sk AlphaType; 87 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_Sk AlphaType;
86 } 88 }
87 89
88 static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) { 90 static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) {
89 switch (info.colorType()) { 91 switch (info.colorType()) {
90 case kRGBA_8888_SkColorType: 92 case kRGBA_8888_SkColorType:
91 case kBGRA_8888_SkColorType: 93 case kBGRA_8888_SkColorType:
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heigh t)); 272 const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heigh t));
271 273
272 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), rect); 274 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), rect);
273 ctx->flushSurfaceWrites(drawContext->accessRenderTarget()); 275 ctx->flushSurfaceWrites(drawContext->accessRenderTarget());
274 return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID, 276 return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID,
275 kOpaque_SkAlphaType, 277 kOpaque_SkAlphaType,
276 drawContext->asTexture().get(), budgeted); 278 drawContext->asTexture().get(), budgeted);
277 } 279 }
278 280
279 static sk_sp<SkImage> create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, uint32_t id) { 281 static sk_sp<SkImage> create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, uint32_t id) {
280 SkAutoTUnref<GrTexture> texture(maker->refTextureForParams(GrTextureParams:: ClampNoFilter())); 282 SkAutoTUnref<GrTexture> texture(maker->refTextureForParams(GrTextureParams:: ClampNoFilter(),
283 SkSourceGammaTrea tment::kRespect));
281 if (!texture) { 284 if (!texture) {
282 return nullptr; 285 return nullptr;
283 } 286 }
284 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), id, at, texture, 287 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), id, at, texture,
285 SkBudgeted::kNo); 288 SkBudgeted::kNo);
286 } 289 }
287 290
288 sk_sp<SkImage> SkImage::makeTextureImage(GrContext *context) const { 291 sk_sp<SkImage> SkImage::makeTextureImage(GrContext *context) const {
289 if (!context) { 292 if (!context) {
290 return nullptr; 293 return nullptr;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (!ctx) { 477 if (!ctx) {
475 return nullptr; 478 return nullptr;
476 } 479 }
477 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m ipLevelCount)); 480 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m ipLevelCount));
478 if (!texture) { 481 if (!texture) {
479 return nullptr; 482 return nullptr;
480 } 483 }
481 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew ImageUniqueID, 484 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew ImageUniqueID,
482 info.alphaType(), texture, budgeted); 485 info.alphaType(), texture, budgeted);
483 } 486 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698