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

Side by Side Diff: src/image/SkImage_Gpu.cpp

Issue 1507973005: Make "alpha only" be a property of GrTextureProducer (Closed) Base URL: https://skia.googlesource.com/skia.git@producernine
Patch Set: fix unused var Created 5 years 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/gpu/SkGpuDevice_drawTexture.cpp ('k') | no next file » | 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 "GrCaps.h" 8 #include "GrCaps.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrDrawContext.h" 10 #include "GrDrawContext.h"
11 #include "GrTextureParamsAdjuster.h" 11 #include "GrImageIDTextureAdjuster.h"
12 #include "effects/GrYUVtoRGBEffect.h" 12 #include "effects/GrYUVtoRGBEffect.h"
13 #include "SkCanvas.h" 13 #include "SkCanvas.h"
14 #include "SkBitmapCache.h" 14 #include "SkBitmapCache.h"
15 #include "SkGpuDevice.h" 15 #include "SkGpuDevice.h"
16 #include "SkGrPixelRef.h" 16 #include "SkGrPixelRef.h"
17 #include "SkGrPriv.h" 17 #include "SkGrPriv.h"
18 #include "SkImageFilter.h" 18 #include "SkImageFilter.h"
19 #include "SkImage_Gpu.h" 19 #include "SkImage_Gpu.h"
20 #include "SkPixelRef.h" 20 #include "SkPixelRef.h"
21 21
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return true; 71 return true;
72 } 72 }
73 73
74 bool SkImage_Gpu::asBitmapForImageFilters(SkBitmap* bitmap) const { 74 bool SkImage_Gpu::asBitmapForImageFilters(SkBitmap* bitmap) const {
75 bitmap->setInfo(make_info(this->width(), this->height(), this->isOpaque())); 75 bitmap->setInfo(make_info(this->width(), this->height(), this->isOpaque()));
76 bitmap->setPixelRef(new SkGrPixelRef(bitmap->info(), fTexture))->unref(); 76 bitmap->setPixelRef(new SkGrPixelRef(bitmap->info(), fTexture))->unref();
77 bitmap->pixelRef()->setImmutableWithID(this->uniqueID()); 77 bitmap->pixelRef()->setImmutableWithID(this->uniqueID());
78 return true; 78 return true;
79 } 79 }
80 80
81 class GpuImage_GrTextureAdjuster : public GrTextureAdjuster {
82 public:
83 GpuImage_GrTextureAdjuster(const SkImage_Gpu* image)
84 : INHERITED(image->peekTexture())
85 , fImage(image)
86 {}
87
88 protected:
89 void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override {
90 GrUniqueKey baseKey;
91 GrMakeKeyFromImageID(&baseKey, fImage->uniqueID(),
92 SkIRect::MakeWH(fImage->width(), fImage->height())) ;
93 MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
94 }
95
96 void didCacheCopy(const GrUniqueKey& copyKey) override { as_IB(fImage)->noti fyAddedToCache(); }
97
98 private:
99 const SkImage* fImage;
100
101 typedef GrTextureAdjuster INHERITED;
102 };
103
104 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& para ms) const { 81 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& para ms) const {
105 return GpuImage_GrTextureAdjuster(this).refTextureSafeForParams(params, null ptr); 82 return GrImageTextureAdjuster(as_IB(this)).refTextureSafeForParams(params, n ullptr);
106 } 83 }
107 84
108 bool SkImage_Gpu::isOpaque() const { 85 bool SkImage_Gpu::isOpaque() const {
109 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_Sk AlphaType; 86 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_Sk AlphaType;
110 } 87 }
111 88
112 static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) { 89 static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) {
113 switch (info.colorType()) { 90 switch (info.colorType()) {
114 case kRGBA_8888_SkColorType: 91 case kRGBA_8888_SkColorType:
115 case kBGRA_8888_SkColorType: 92 case kBGRA_8888_SkColorType:
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (!dst) { 368 if (!dst) {
392 return nullptr; 369 return nullptr;
393 } 370 }
394 371
395 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); 372 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
396 const SkIPoint dstP = SkIPoint::Make(0, 0); 373 const SkIPoint dstP = SkIPoint::Make(0, 0);
397 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); 374 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp);
398 return dst; 375 return dst;
399 } 376 }
400 377
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice_drawTexture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698