OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |