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

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

Issue 1411353002: Revert recent CLs around GrTextureMaker/GrTextureParamsAdjuster (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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/gpu/SkGrPriv.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 "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkImage_Gpu.h" 9 #include "SkImage_Gpu.h"
10 #include "GrCaps.h" 10 #include "GrCaps.h"
11 #include "GrContext.h" 11 #include "GrContext.h"
12 #include "GrDrawContext.h" 12 #include "GrDrawContext.h"
13 #include "GrTextureParamsAdjuster.h" 13 #include "GrTextureMaker.h"
14 #include "effects/GrYUVtoRGBEffect.h" 14 #include "effects/GrYUVtoRGBEffect.h"
15 #include "SkCanvas.h" 15 #include "SkCanvas.h"
16 #include "SkGpuDevice.h" 16 #include "SkGpuDevice.h"
17 #include "SkGr.h" 17 #include "SkGr.h"
18 #include "SkPixelRef.h" 18 #include "SkPixelRef.h"
19 19
20 SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrText ure* tex, 20 SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrText ure* tex,
21 SkSurface::Budgeted budgeted) 21 SkSurface::Budgeted budgeted)
22 : INHERITED(w, h, uniqueID) 22 : INHERITED(w, h, uniqueID)
23 , fTexture(SkRef(tex)) 23 , fTexture(SkRef(tex))
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 dst->getPixels(), dst->rowBytes())) { 57 dst->getPixels(), dst->rowBytes())) {
58 return false; 58 return false;
59 } 59 }
60 60
61 dst->pixelRef()->setImmutableWithID(this->uniqueID()); 61 dst->pixelRef()->setImmutableWithID(this->uniqueID());
62 SkBitmapCache::Add(this->uniqueID(), *dst); 62 SkBitmapCache::Add(this->uniqueID(), *dst);
63 fAddedRasterVersionToCache.store(true); 63 fAddedRasterVersionToCache.store(true);
64 return true; 64 return true;
65 } 65 }
66 66
67 static void make_raw_texture_stretched_key(uint32_t imageID, 67 static void make_raw_texture_stretched_key(uint32_t imageID, const SkGrStretch& stretch,
68 const GrTextureParamsAdjuster::CopyPa rams& params,
69 GrUniqueKey* stretchedKey) { 68 GrUniqueKey* stretchedKey) {
69 SkASSERT(SkGrStretch::kNone_Type != stretch.fType);
70
71 uint32_t width = SkToU16(stretch.fWidth);
72 uint32_t height = SkToU16(stretch.fHeight);
73
70 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); 74 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
71 GrUniqueKey::Builder builder(stretchedKey, kDomain, 4); 75 GrUniqueKey::Builder builder(stretchedKey, kDomain, 3);
72 builder[0] = imageID; 76 builder[0] = imageID;
73 builder[1] = params.fFilter; 77 builder[1] = stretch.fType;
74 builder[2] = params.fWidth; 78 builder[2] = width | (height << 16);
75 builder[3] = params.fHeight; 79 builder.finish();
76 } 80 }
77 81
78 class Texture_GrTextureParamsAdjuster : public GrTextureParamsAdjuster { 82 class Texture_GrTextureMaker : public GrTextureMaker {
79 public: 83 public:
80 Texture_GrTextureParamsAdjuster(const SkImage* image, GrTexture* unstretched ) 84 Texture_GrTextureMaker(const SkImage* image, GrTexture* unstretched)
81 : INHERITED(image->width(), image->height()) 85 : INHERITED(image->width(), image->height())
82 , fImage(image) 86 , fImage(image)
83 , fOriginal(unstretched) 87 , fUnstretched(unstretched)
84 {} 88 {}
85 89
86 protected: 90 protected:
87 GrTexture* refOriginalTexture(GrContext* ctx) override { 91 GrTexture* onRefUnstretchedTexture(GrContext* ctx) override {
88 return SkRef(fOriginal); 92 return SkRef(fUnstretched);
89 } 93 }
90 94
91 void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) overrid e { 95 bool onMakeStretchedKey(const SkGrStretch& stretch, GrUniqueKey* stretchedKe y) override {
92 make_raw_texture_stretched_key(fImage->uniqueID(), copyParams, copyKey); 96 make_raw_texture_stretched_key(fImage->uniqueID(), stretch, stretchedKey );
97 return stretchedKey->isValid();
93 } 98 }
94 99
95 void didCacheCopy(const GrUniqueKey& copyKey) override { 100 void onNotifyStretchCached(const GrUniqueKey& stretchedKey) override {
96 as_IB(fImage)->notifyAddedToCache(); 101 as_IB(fImage)->notifyAddedToCache();
97 } 102 }
98 103
99 bool getROBitmap(SkBitmap* bitmap) override { 104 bool onGetROBitmap(SkBitmap* bitmap) override {
100 return as_IB(fImage)->getROPixels(bitmap); 105 return as_IB(fImage)->getROPixels(bitmap);
101 } 106 }
102 107
103 private: 108 private:
104 const SkImage* fImage; 109 const SkImage* fImage;
105 GrTexture* fOriginal; 110 GrTexture* fUnstretched;
106 111
107 typedef GrTextureParamsAdjuster INHERITED; 112 typedef GrTextureMaker INHERITED;
108 }; 113 };
109 114
110 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& para ms) const { 115 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& para ms) const {
111 return Texture_GrTextureParamsAdjuster(this, fTexture).refTextureForParams(c tx, params); 116 return Texture_GrTextureMaker(this, fTexture).refCachedTexture(ctx, params);
112 } 117 }
113 118
114 bool SkImage_Gpu::isOpaque() const { 119 bool SkImage_Gpu::isOpaque() const {
115 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_Sk AlphaType; 120 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_Sk AlphaType;
116 } 121 }
117 122
118 static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) { 123 static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) {
119 switch (info.colorType()) { 124 switch (info.colorType()) {
120 case kRGBA_8888_SkColorType: 125 case kRGBA_8888_SkColorType:
121 case kBGRA_8888_SkColorType: 126 case kBGRA_8888_SkColorType:
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 if (!dst) { 404 if (!dst) {
400 return nullptr; 405 return nullptr;
401 } 406 }
402 407
403 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); 408 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
404 const SkIPoint dstP = SkIPoint::Make(0, 0); 409 const SkIPoint dstP = SkIPoint::Make(0, 0);
405 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); 410 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp);
406 return dst; 411 return dst;
407 } 412 }
408 413
OLDNEW
« no previous file with comments | « src/gpu/SkGrPriv.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698