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

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

Issue 1491293002: detect when we can filter bitmaps/images directly, w/o a tmp layer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move include to the top 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/image/SkImage_Gpu.h ('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 "SkBitmapCache.h"
9 #include "SkImage_Gpu.h"
10 #include "GrCaps.h" 8 #include "GrCaps.h"
11 #include "GrContext.h" 9 #include "GrContext.h"
12 #include "GrDrawContext.h" 10 #include "GrDrawContext.h"
13 #include "GrTextureParamsAdjuster.h" 11 #include "GrTextureParamsAdjuster.h"
14 #include "effects/GrYUVtoRGBEffect.h" 12 #include "effects/GrYUVtoRGBEffect.h"
15 #include "SkCanvas.h" 13 #include "SkCanvas.h"
14 #include "SkBitmapCache.h"
16 #include "SkGpuDevice.h" 15 #include "SkGpuDevice.h"
16 #include "SkGrPixelRef.h"
17 #include "SkGrPriv.h" 17 #include "SkGrPriv.h"
18 #include "SkImageFilter.h"
19 #include "SkImage_Gpu.h"
18 #include "SkPixelRef.h" 20 #include "SkPixelRef.h"
19 21
20 SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrText ure* tex, 22 SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrText ure* tex,
21 SkSurface::Budgeted budgeted) 23 SkSurface::Budgeted budgeted)
22 : INHERITED(w, h, uniqueID) 24 : INHERITED(w, h, uniqueID)
23 , fTexture(SkRef(tex)) 25 , fTexture(SkRef(tex))
24 , fAlphaType(at) 26 , fAlphaType(at)
25 , fBudgeted(budgeted) 27 , fBudgeted(budgeted)
26 , fAddedRasterVersionToCache(false) 28 , fAddedRasterVersionToCache(false)
27 { 29 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 64 }
63 65
64 dst->pixelRef()->setImmutableWithID(this->uniqueID()); 66 dst->pixelRef()->setImmutableWithID(this->uniqueID());
65 if (kAllow_CachingHint == chint) { 67 if (kAllow_CachingHint == chint) {
66 SkBitmapCache::Add(this->uniqueID(), *dst); 68 SkBitmapCache::Add(this->uniqueID(), *dst);
67 fAddedRasterVersionToCache.store(true); 69 fAddedRasterVersionToCache.store(true);
68 } 70 }
69 return true; 71 return true;
70 } 72 }
71 73
74 bool SkImage_Gpu::asBitmapForImageFilters(SkBitmap* bitmap) const {
75 bitmap->setInfo(make_info(this->width(), this->height(), this->isOpaque()));
76 bitmap->setPixelRef(new SkGrPixelRef(bitmap->info(), fTexture))->unref();
77 bitmap->pixelRef()->setImmutableWithID(this->uniqueID());
78 return true;
79 }
80
72 class GpuImage_GrTextureAdjuster : public GrTextureAdjuster { 81 class GpuImage_GrTextureAdjuster : public GrTextureAdjuster {
73 public: 82 public:
74 GpuImage_GrTextureAdjuster(const SkImage_Gpu* image) 83 GpuImage_GrTextureAdjuster(const SkImage_Gpu* image)
75 : INHERITED(image->peekTexture()) 84 : INHERITED(image->peekTexture())
76 , fImage(image) 85 , fImage(image)
77 {} 86 {}
78 87
79 protected: 88 protected:
80 void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override { 89 void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override {
81 GrUniqueKey baseKey; 90 GrUniqueKey baseKey;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (!subTx) { 168 if (!subTx) {
160 return nullptr; 169 return nullptr;
161 } 170 }
162 ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0)); 171 ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0));
163 return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, fAl phaType, subTx, 172 return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, fAl phaType, subTx,
164 fBudgeted); 173 fBudgeted);
165 } 174 }
166 175
167 //////////////////////////////////////////////////////////////////////////////// /////////////////// 176 //////////////////////////////////////////////////////////////////////////////// ///////////////////
168 177
169 #include "SkGrPixelRef.h"
170 #include "SkImageFilter.h"
171
172 class SkGpuImageFilterProxy : public SkImageFilter::Proxy { 178 class SkGpuImageFilterProxy : public SkImageFilter::Proxy {
173 GrContext* fCtx; 179 GrContext* fCtx;
174 180
175 public: 181 public:
176 SkGpuImageFilterProxy(GrContext* ctx) : fCtx(ctx) {} 182 SkGpuImageFilterProxy(GrContext* ctx) : fCtx(ctx) {}
177 183
178 SkBaseDevice* createDevice(int width, int height) override { 184 SkBaseDevice* createDevice(int width, int height) override {
179 GrSurfaceDesc desc; 185 GrSurfaceDesc desc;
180 desc.fConfig = kSkia8888_GrPixelConfig; 186 desc.fConfig = kSkia8888_GrPixelConfig;
181 desc.fFlags = kRenderTarget_GrSurfaceFlag; 187 desc.fFlags = kRenderTarget_GrSurfaceFlag;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 if (!dst) { 391 if (!dst) {
386 return nullptr; 392 return nullptr;
387 } 393 }
388 394
389 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); 395 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
390 const SkIPoint dstP = SkIPoint::Make(0, 0); 396 const SkIPoint dstP = SkIPoint::Make(0, 0);
391 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); 397 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp);
392 return dst; 398 return dst;
393 } 399 }
394 400
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698