| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 *minSize = size; | 57 *minSize = size; |
| 58 } | 58 } |
| 59 return true; | 59 return true; |
| 60 } | 60 } |
| 61 | 61 |
| 62 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, SkColorTable*, const
SkSurfaceProps*); | 62 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, SkColorTable*, const
SkSurfaceProps*); |
| 63 virtual ~SkImage_Raster(); | 63 virtual ~SkImage_Raster(); |
| 64 | 64 |
| 65 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const ove
rride; | 65 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const ove
rride; |
| 66 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con
st override; | 66 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con
st override; |
| 67 void onPreroll(GrContext*) const override; |
| 67 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override; | 68 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override; |
| 68 SkData* onRefEncoded() const override; | 69 SkData* onRefEncoded() const override; |
| 69 bool getROPixels(SkBitmap*) const override; | 70 bool getROPixels(SkBitmap*) const override; |
| 70 | 71 |
| 71 // exposed for SkSurface_Raster via SkNewImageFromPixelRef | 72 // exposed for SkSurface_Raster via SkNewImageFromPixelRef |
| 72 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& pixelRefOrig
in, size_t rowBytes, | 73 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& pixelRefOrig
in, size_t rowBytes, |
| 73 const SkSurfaceProps*); | 74 const SkSurfaceProps*); |
| 74 | 75 |
| 75 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } | 76 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } |
| 76 | 77 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesP
tr) const { | 157 const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesP
tr) const { |
| 157 const SkImageInfo info = fBitmap.info(); | 158 const SkImageInfo info = fBitmap.info(); |
| 158 if ((kUnknown_SkColorType == info.colorType()) || !fBitmap.getPixels()) { | 159 if ((kUnknown_SkColorType == info.colorType()) || !fBitmap.getPixels()) { |
| 159 return nullptr; | 160 return nullptr; |
| 160 } | 161 } |
| 161 *infoPtr = info; | 162 *infoPtr = info; |
| 162 *rowBytesPtr = fBitmap.rowBytes(); | 163 *rowBytesPtr = fBitmap.rowBytes(); |
| 163 return fBitmap.getPixels(); | 164 return fBitmap.getPixels(); |
| 164 } | 165 } |
| 165 | 166 |
| 167 void SkImage_Raster::onPreroll(GrContext* ctx) const { |
| 168 fBitmap.lockPixels(); |
| 169 fBitmap.unlockPixels(); |
| 170 } |
| 171 |
| 166 SkData* SkImage_Raster::onRefEncoded() const { | 172 SkData* SkImage_Raster::onRefEncoded() const { |
| 167 SkPixelRef* pr = fBitmap.pixelRef(); | 173 SkPixelRef* pr = fBitmap.pixelRef(); |
| 168 const SkImageInfo prInfo = pr->info(); | 174 const SkImageInfo prInfo = pr->info(); |
| 169 const SkImageInfo bmInfo = fBitmap.info(); | 175 const SkImageInfo bmInfo = fBitmap.info(); |
| 170 | 176 |
| 171 // we only try if we (the image) cover the entire area of the pixelRef | 177 // we only try if we (the image) cover the entire area of the pixelRef |
| 172 if (prInfo.width() == bmInfo.width() && prInfo.height() == bmInfo.height())
{ | 178 if (prInfo.width() == bmInfo.width() && prInfo.height() == bmInfo.height())
{ |
| 173 return pr->refEncodedData(); | 179 return pr->refEncodedData(); |
| 174 } | 180 } |
| 175 return nullptr; | 181 return nullptr; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // pixelref since the caller might call setImmutable() themselves | 291 // pixelref since the caller might call setImmutable() themselves |
| 286 // (thus changing our state). | 292 // (thus changing our state). |
| 287 if (fBitmap.isImmutable()) { | 293 if (fBitmap.isImmutable()) { |
| 288 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); | 294 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); |
| 289 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); | 295 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); |
| 290 return true; | 296 return true; |
| 291 } | 297 } |
| 292 } | 298 } |
| 293 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); | 299 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); |
| 294 } | 300 } |
| OLD | NEW |