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

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

Issue 1404433002: Remove image usage type enum. Use GrTextureParams instead. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix no gpu build 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/image/SkImage_Gpu.cpp ('k') | src/utils/SkImageGeneratorUtils.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 "SkImage_Base.h" 8 #include "SkImage_Base.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return true; 63 return true;
64 } 64 }
65 65
66 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, SkColorTable*); 66 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, SkColorTable*);
67 virtual ~SkImage_Raster(); 67 virtual ~SkImage_Raster();
68 68
69 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con st override; 69 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con st override;
70 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override; 70 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override;
71 SkData* onRefEncoded() const override; 71 SkData* onRefEncoded() const override;
72 bool getROPixels(SkBitmap*) const override; 72 bool getROPixels(SkBitmap*) const override;
73 GrTexture* asTextureRef(GrContext*, SkImageUsageType) const override; 73 GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override;
74 SkImage* onNewSubset(const SkIRect&) const override; 74 SkImage* onNewSubset(const SkIRect&) const override;
75 75
76 // exposed for SkSurface_Raster via SkNewImageFromPixelRef 76 // exposed for SkSurface_Raster via SkNewImageFromPixelRef
77 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& origin, size _t rowBytes); 77 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& origin, size _t rowBytes);
78 78
79 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } 79 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
80 80
81 bool isOpaque() const override; 81 bool isOpaque() const override;
82 bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override; 82 bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override;
83 83
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 return pr->refEncodedData(); 160 return pr->refEncodedData();
161 } 161 }
162 return nullptr; 162 return nullptr;
163 } 163 }
164 164
165 bool SkImage_Raster::getROPixels(SkBitmap* dst) const { 165 bool SkImage_Raster::getROPixels(SkBitmap* dst) const {
166 *dst = fBitmap; 166 *dst = fBitmap;
167 return true; 167 return true;
168 } 168 }
169 169
170 GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, SkImageUsageType usage) const { 170 GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p arams) const {
171 #if SK_SUPPORT_GPU 171 #if SK_SUPPORT_GPU
172 if (!ctx) { 172 if (!ctx) {
173 return nullptr; 173 return nullptr;
174 } 174 }
175 175
176 // textures (at least the texture-key) only support 16bit dimensions, so abo rt early 176 // textures (at least the texture-key) only support 16bit dimensions, so abo rt early
177 // if we're too big. 177 // if we're too big.
178 if (fBitmap.width() > 0xFFFF || fBitmap.height() > 0xFFFF) { 178 if (fBitmap.width() > 0xFFFF || fBitmap.height() > 0xFFFF) {
179 return nullptr; 179 return nullptr;
180 } 180 }
181 181
182 GrUniqueKey key; 182 GrUniqueKey key;
183 GrMakeKeyFromImageID(&key, fBitmap.getGenerationID(), 183 GrMakeKeyFromImageID(&key, fBitmap.getGenerationID(),
184 SkIRect::MakeWH(fBitmap.width(), fBitmap.height()), 184 SkIRect::MakeWH(fBitmap.width(), fBitmap.height()),
185 *ctx->caps(), usage); 185 *ctx->caps(), params);
186 186
187 if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(ke y)) { 187 if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(ke y)) {
188 return tex; 188 return tex;
189 } 189 }
190 return GrRefCachedBitmapTexture(ctx, fBitmap, usage); 190 return GrRefCachedBitmapTexture(ctx, fBitmap, params);
191 #endif 191 #endif
192 192
193 return nullptr; 193 return nullptr;
194 } 194 }
195 195
196 SkImage* SkImage_Raster::onNewSubset(const SkIRect& subset) const { 196 SkImage* SkImage_Raster::onNewSubset(const SkIRect& subset) const {
197 // TODO : could consider heurist of sharing pixels, if subset is pretty clos e to complete 197 // TODO : could consider heurist of sharing pixels, if subset is pretty clos e to complete
198 198
199 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi tmap.alphaType()); 199 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi tmap.alphaType());
200 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); 200 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // pixelref since the caller might call setImmutable() themselves 299 // pixelref since the caller might call setImmutable() themselves
300 // (thus changing our state). 300 // (thus changing our state).
301 if (fBitmap.isImmutable()) { 301 if (fBitmap.isImmutable()) {
302 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); 302 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes());
303 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); 303 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin());
304 return true; 304 return true;
305 } 305 }
306 } 306 }
307 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); 307 return this->INHERITED::onAsLegacyBitmap(bitmap, mode);
308 } 308 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | src/utils/SkImageGeneratorUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698