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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& pixelRefOrig
in, size_t rowBytes, | 72 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& pixelRefOrig
in, size_t rowBytes, |
73 const SkSurfaceProps*); | 73 const SkSurfaceProps*); |
74 | 74 |
75 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } | 75 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } |
76 | 76 |
77 SkShader* onNewShader(SkShader::TileMode, | 77 SkShader* onNewShader(SkShader::TileMode, |
78 SkShader::TileMode, | 78 SkShader::TileMode, |
79 const SkMatrix* localMatrix) const override; | 79 const SkMatrix* localMatrix) const override; |
80 | 80 |
81 bool isOpaque() const override; | 81 bool isOpaque() const override; |
| 82 bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override; |
82 | 83 |
83 SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props) | 84 SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props) |
84 : INHERITED(bm.width(), bm.height(), props) | 85 : INHERITED(bm.width(), bm.height(), props) |
85 , fBitmap(bm) {} | 86 , fBitmap(bm) {} |
86 | 87 |
87 private: | 88 private: |
88 SkImage_Raster() : INHERITED(0, 0, NULL) {} | 89 SkImage_Raster() : INHERITED(0, 0, NULL) {} |
89 | 90 |
90 SkBitmap fBitmap; | 91 SkBitmap fBitmap; |
91 | 92 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 256 } |
256 | 257 |
257 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) { | 258 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) { |
258 return ((const SkImage_Raster*)image)->getPixelRef(); | 259 return ((const SkImage_Raster*)image)->getPixelRef(); |
259 } | 260 } |
260 | 261 |
261 bool SkImage_Raster::isOpaque() const { | 262 bool SkImage_Raster::isOpaque() const { |
262 return fBitmap.isOpaque(); | 263 return fBitmap.isOpaque(); |
263 } | 264 } |
264 | 265 |
| 266 bool SkImage_Raster::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) c
onst { |
| 267 if (kRO_LegacyBitmapMode == mode) { |
| 268 // When we're a snapshot from a surface, our bitmap may not be marked im
mutable |
| 269 // even though logically always we are, but in that case we can't physic
ally share our |
| 270 // pixelref since the caller might call setImmutable() themselves |
| 271 // (thus changing our state). |
| 272 if (fBitmap.isImmutable()) { |
| 273 bitmap->setInfo(fBitmap.info()); |
| 274 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); |
| 275 return true; |
| 276 } |
| 277 } |
| 278 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); |
| 279 } |
OLD | NEW |