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

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

Issue 2037413002: Add SkSourceGammaTreatment enum so we know how to create mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix DM compilation Created 4 years, 6 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') | tests/ReadPixelsTest.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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 virtual ~SkImage_Raster(); 75 virtual ~SkImage_Raster();
76 76
77 SkImageInfo onImageInfo() const override { 77 SkImageInfo onImageInfo() const override {
78 return fBitmap.info(); 78 return fBitmap.info();
79 } 79 }
80 80
81 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, Cac hingHint) const override; 81 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, Cac hingHint) const override;
82 bool onPeekPixels(SkPixmap*) const override; 82 bool onPeekPixels(SkPixmap*) const override;
83 SkData* onRefEncoded(GrContext*) const override; 83 SkData* onRefEncoded(GrContext*) const override;
84 bool getROPixels(SkBitmap*, CachingHint) const override; 84 bool getROPixels(SkBitmap*, CachingHint) const override;
85 GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override; 85 GrTexture* asTextureRef(GrContext*, const GrTextureParams&,
86 SkSourceGammaTreatment) const override;
86 sk_sp<SkImage> onMakeSubset(const SkIRect&) const override; 87 sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
87 88
88 // exposed for SkSurface_Raster via SkNewImageFromPixelRef 89 // exposed for SkSurface_Raster via SkNewImageFromPixelRef
89 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& origin, size _t rowBytes); 90 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& origin, size _t rowBytes);
90 91
91 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } 92 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
92 93
93 bool isOpaque() const override; 94 bool isOpaque() const override;
94 bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override; 95 bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override;
95 96
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return pr->refEncodedData(); 168 return pr->refEncodedData();
168 } 169 }
169 return nullptr; 170 return nullptr;
170 } 171 }
171 172
172 bool SkImage_Raster::getROPixels(SkBitmap* dst, CachingHint) const { 173 bool SkImage_Raster::getROPixels(SkBitmap* dst, CachingHint) const {
173 *dst = fBitmap; 174 *dst = fBitmap;
174 return true; 175 return true;
175 } 176 }
176 177
177 GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p arams) const { 178 GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p arams,
179 SkSourceGammaTreatment gammaTreatment) c onst {
178 #if SK_SUPPORT_GPU 180 #if SK_SUPPORT_GPU
179 if (!ctx) { 181 if (!ctx) {
180 return nullptr; 182 return nullptr;
181 } 183 }
182 184
183 return GrRefCachedBitmapTexture(ctx, fBitmap, params); 185 return GrRefCachedBitmapTexture(ctx, fBitmap, params, gammaTreatment);
184 #endif 186 #endif
185 187
186 return nullptr; 188 return nullptr;
187 } 189 }
188 190
189 sk_sp<SkImage> SkImage_Raster::onMakeSubset(const SkIRect& subset) const { 191 sk_sp<SkImage> SkImage_Raster::onMakeSubset(const SkIRect& subset) const {
190 // TODO : could consider heurist of sharing pixels, if subset is pretty clos e to complete 192 // TODO : could consider heurist of sharing pixels, if subset is pretty clos e to complete
191 193
192 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi tmap.alphaType()); 194 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi tmap.alphaType());
193 auto surface(SkSurface::MakeRaster(info)); 195 auto surface(SkSurface::MakeRaster(info));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // pixelref since the caller might call setImmutable() themselves 294 // pixelref since the caller might call setImmutable() themselves
293 // (thus changing our state). 295 // (thus changing our state).
294 if (fBitmap.isImmutable()) { 296 if (fBitmap.isImmutable()) {
295 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); 297 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes());
296 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); 298 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin());
297 return true; 299 return true;
298 } 300 }
299 } 301 }
300 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); 302 return this->INHERITED::onAsLegacyBitmap(bitmap, mode);
301 } 303 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | tests/ReadPixelsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698