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" |
11 #include "GrDrawContext.h" | 11 #include "GrDrawContext.h" |
12 #include "GrImageIDTextureAdjuster.h" | 12 #include "GrImageIDTextureAdjuster.h" |
13 #include "effects/GrYUVEffect.h" | 13 #include "effects/GrYUVEffect.h" |
14 #include "SkCanvas.h" | 14 #include "SkCanvas.h" |
15 #include "SkBitmapCache.h" | 15 #include "SkBitmapCache.h" |
16 #include "SkGrPixelRef.h" | |
17 #include "SkGrPriv.h" | 16 #include "SkGrPriv.h" |
18 #include "SkImage_Gpu.h" | 17 #include "SkImage_Gpu.h" |
19 #include "SkMipMap.h" | 18 #include "SkMipMap.h" |
20 #include "SkPixelRef.h" | 19 #include "SkPixelRef.h" |
21 | 20 |
22 SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrText
ure* tex, | 21 SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrText
ure* tex, |
23 sk_sp<SkColorSpace> colorSpace, SkBudgeted budgeted) | 22 sk_sp<SkColorSpace> colorSpace, SkBudgeted budgeted) |
24 : INHERITED(w, h, uniqueID) | 23 : INHERITED(w, h, uniqueID) |
25 , fTexture(SkRef(tex)) | 24 , fTexture(SkRef(tex)) |
26 , fAlphaType(at) | 25 , fAlphaType(at) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 66 } |
68 | 67 |
69 dst->pixelRef()->setImmutableWithID(this->uniqueID()); | 68 dst->pixelRef()->setImmutableWithID(this->uniqueID()); |
70 if (kAllow_CachingHint == chint) { | 69 if (kAllow_CachingHint == chint) { |
71 SkBitmapCache::Add(this->uniqueID(), *dst); | 70 SkBitmapCache::Add(this->uniqueID(), *dst); |
72 fAddedRasterVersionToCache.store(true); | 71 fAddedRasterVersionToCache.store(true); |
73 } | 72 } |
74 return true; | 73 return true; |
75 } | 74 } |
76 | 75 |
77 bool SkImage_Gpu::asBitmapForImageFilters(SkBitmap* bitmap) const { | |
78 bitmap->setInfo(make_info(this->width(), this->height(), this->isOpaque(), f
ColorSpace)); | |
79 bitmap->setPixelRef(new SkGrPixelRef(bitmap->info(), fTexture))->unref(); | |
80 bitmap->pixelRef()->setImmutableWithID(this->uniqueID()); | |
81 return true; | |
82 } | |
83 | |
84 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& para
ms, | 76 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& para
ms, |
85 SkSourceGammaTreatment gammaTreatment) cons
t { | 77 SkSourceGammaTreatment gammaTreatment) cons
t { |
86 return GrImageTextureAdjuster(as_IB(this)).refTextureSafeForParams(params, g
ammaTreatment, | 78 return GrImageTextureAdjuster(as_IB(this)).refTextureSafeForParams(params, g
ammaTreatment, |
87 nullptr); | 79 nullptr); |
88 } | 80 } |
89 | 81 |
90 bool SkImage_Gpu::isOpaque() const { | 82 bool SkImage_Gpu::isOpaque() const { |
91 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_Sk
AlphaType; | 83 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_Sk
AlphaType; |
92 } | 84 } |
93 | 85 |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 return nullptr; | 544 return nullptr; |
553 } | 545 } |
554 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); | 546 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); |
555 if (!texture) { | 547 if (!texture) { |
556 return nullptr; | 548 return nullptr; |
557 } | 549 } |
558 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, | 550 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, |
559 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), | 551 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), |
560 budgeted); | 552 budgeted); |
561 } | 553 } |
OLD | NEW |