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 "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, const SkSurfaceProps*
); | 52 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, const SkSurfaceProps*
); |
53 virtual ~SkImage_Raster(); | 53 virtual ~SkImage_Raster(); |
54 | 54 |
55 void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) const SK_OVERRIDE
; | 55 void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) const SK_OVERRIDE
; |
56 void onDrawRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) con
st SK_OVERRIDE; | 56 void onDrawRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) con
st SK_OVERRIDE; |
57 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const SK_
OVERRIDE; | 57 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const SK_
OVERRIDE; |
58 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con
st SK_OVERRIDE; | 58 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con
st SK_OVERRIDE; |
59 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const SK_OVERRI
DE; | 59 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const SK_OVERRI
DE; |
60 bool getROPixels(SkBitmap*) const SK_OVERRIDE; | 60 bool getROPixels(SkBitmap*) const SK_OVERRIDE; |
61 void onPreroll() const SK_OVERRIDE; | |
62 | 61 |
63 // exposed for SkSurface_Raster via SkNewImageFromPixelRef | 62 // exposed for SkSurface_Raster via SkNewImageFromPixelRef |
64 SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes, const SkSur
faceProps*); | 63 SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes, const SkSur
faceProps*); |
65 | 64 |
66 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } | 65 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } |
67 | 66 |
68 virtual SkShader* onNewShader(SkShader::TileMode, | 67 virtual SkShader* onNewShader(SkShader::TileMode, |
69 SkShader::TileMode, | 68 SkShader::TileMode, |
70 const SkMatrix* localMatrix) const SK_OVERRIDE
; | 69 const SkMatrix* localMatrix) const SK_OVERRIDE
; |
71 | 70 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 *infoPtr = info; | 147 *infoPtr = info; |
149 *rowBytesPtr = fBitmap.rowBytes(); | 148 *rowBytesPtr = fBitmap.rowBytes(); |
150 return fBitmap.getPixels(); | 149 return fBitmap.getPixels(); |
151 } | 150 } |
152 | 151 |
153 bool SkImage_Raster::getROPixels(SkBitmap* dst) const { | 152 bool SkImage_Raster::getROPixels(SkBitmap* dst) const { |
154 *dst = fBitmap; | 153 *dst = fBitmap; |
155 return true; | 154 return true; |
156 } | 155 } |
157 | 156 |
158 void SkImage_Raster::onPreroll() const { | |
159 SkBitmap bm(fBitmap); | |
160 bm.lockPixels(); | |
161 bm.unlockPixels(); | |
162 } | |
163 | |
164 /////////////////////////////////////////////////////////////////////////////// | 157 /////////////////////////////////////////////////////////////////////////////// |
165 | 158 |
166 SkImage* SkImage::NewRasterCopy(const SkImageInfo& info, const void* pixels, siz
e_t rowBytes) { | 159 SkImage* SkImage::NewRasterCopy(const SkImageInfo& info, const void* pixels, siz
e_t rowBytes) { |
167 if (!SkImage_Raster::ValidArgs(info, rowBytes) || !pixels) { | 160 if (!SkImage_Raster::ValidArgs(info, rowBytes) || !pixels) { |
168 return NULL; | 161 return NULL; |
169 } | 162 } |
170 | 163 |
171 // Here we actually make a copy of the caller's pixel data | 164 // Here we actually make a copy of the caller's pixel data |
172 SkAutoDataUnref data(SkData::NewWithCopy(pixels, info.height() * rowBytes)); | 165 SkAutoDataUnref data(SkData::NewWithCopy(pixels, info.height() * rowBytes)); |
173 return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes, NULL)); | 166 return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes, NULL)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 202 } |
210 | 203 |
211 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) { | 204 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) { |
212 return ((const SkImage_Raster*)image)->getPixelRef(); | 205 return ((const SkImage_Raster*)image)->getPixelRef(); |
213 } | 206 } |
214 | 207 |
215 bool SkImage_Raster::isOpaque() const { | 208 bool SkImage_Raster::isOpaque() const { |
216 return fBitmap.isOpaque(); | 209 return fBitmap.isOpaque(); |
217 } | 210 } |
218 | 211 |
OLD | NEW |