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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
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*, SkScalar = SK_Scalar1) const override; |
73 GrTexture* asTextureRef(GrContext*, const GrTextureParams&) 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; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 const SkImageInfo prInfo = pr->info(); | 155 const SkImageInfo prInfo = pr->info(); |
156 const SkImageInfo bmInfo = fBitmap.info(); | 156 const SkImageInfo bmInfo = fBitmap.info(); |
157 | 157 |
158 // we only try if we (the image) cover the entire area of the pixelRef | 158 // we only try if we (the image) cover the entire area of the pixelRef |
159 if (prInfo.width() == bmInfo.width() && prInfo.height() == bmInfo.height())
{ | 159 if (prInfo.width() == bmInfo.width() && prInfo.height() == bmInfo.height())
{ |
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, SkScalar scaleHint) const { |
166 *dst = fBitmap; | 166 *dst = fBitmap; |
167 return true; | 167 return true; |
168 } | 168 } |
169 | 169 |
170 GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p
arams) 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 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // pixelref since the caller might call setImmutable() themselves | 285 // pixelref since the caller might call setImmutable() themselves |
286 // (thus changing our state). | 286 // (thus changing our state). |
287 if (fBitmap.isImmutable()) { | 287 if (fBitmap.isImmutable()) { |
288 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); | 288 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); |
289 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); | 289 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); |
290 return true; | 290 return true; |
291 } | 291 } |
292 } | 292 } |
293 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); | 293 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); |
294 } | 294 } |
OLD | NEW |