| OLD | NEW |
| 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 Loading... |
| 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&, bool gammaCorrec
t) const override; |
| 86 sk_sp<SkImage> onMakeSubset(const SkIRect&) const override; | 86 sk_sp<SkImage> onMakeSubset(const SkIRect&) const override; |
| 87 | 87 |
| 88 // exposed for SkSurface_Raster via SkNewImageFromPixelRef | 88 // exposed for SkSurface_Raster via SkNewImageFromPixelRef |
| 89 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& origin, size
_t rowBytes); | 89 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& origin, size
_t rowBytes); |
| 90 | 90 |
| 91 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } | 91 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } |
| 92 | 92 |
| 93 bool isOpaque() const override; | 93 bool isOpaque() const override; |
| 94 bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override; | 94 bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override; |
| 95 | 95 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 return pr->refEncodedData(); | 167 return pr->refEncodedData(); |
| 168 } | 168 } |
| 169 return nullptr; | 169 return nullptr; |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool SkImage_Raster::getROPixels(SkBitmap* dst, CachingHint) const { | 172 bool SkImage_Raster::getROPixels(SkBitmap* dst, CachingHint) const { |
| 173 *dst = fBitmap; | 173 *dst = fBitmap; |
| 174 return true; | 174 return true; |
| 175 } | 175 } |
| 176 | 176 |
| 177 GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p
arams) const { | 177 GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p
arams, |
| 178 bool gammaCorrect) const { |
| 178 #if SK_SUPPORT_GPU | 179 #if SK_SUPPORT_GPU |
| 179 if (!ctx) { | 180 if (!ctx) { |
| 180 return nullptr; | 181 return nullptr; |
| 181 } | 182 } |
| 182 | 183 |
| 183 return GrRefCachedBitmapTexture(ctx, fBitmap, params); | 184 return GrRefCachedBitmapTexture(ctx, fBitmap, params, gammaCorrect); |
| 184 #endif | 185 #endif |
| 185 | 186 |
| 186 return nullptr; | 187 return nullptr; |
| 187 } | 188 } |
| 188 | 189 |
| 189 sk_sp<SkImage> SkImage_Raster::onMakeSubset(const SkIRect& subset) const { | 190 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 | 191 // TODO : could consider heurist of sharing pixels, if subset is pretty clos
e to complete |
| 191 | 192 |
| 192 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi
tmap.alphaType()); | 193 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi
tmap.alphaType()); |
| 193 auto surface(SkSurface::MakeRaster(info)); | 194 auto surface(SkSurface::MakeRaster(info)); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 // pixelref since the caller might call setImmutable() themselves | 293 // pixelref since the caller might call setImmutable() themselves |
| 293 // (thus changing our state). | 294 // (thus changing our state). |
| 294 if (fBitmap.isImmutable()) { | 295 if (fBitmap.isImmutable()) { |
| 295 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); | 296 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); |
| 296 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); | 297 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); |
| 297 return true; | 298 return true; |
| 298 } | 299 } |
| 299 } | 300 } |
| 300 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); | 301 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); |
| 301 } | 302 } |
| OLD | NEW |