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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
51 static SkImage* NewEmpty(); | 51 static SkImage* NewEmpty(); |
52 | 52 |
53 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb); | 53 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb); |
54 virtual ~SkImage_Raster(); | 54 virtual ~SkImage_Raster(); |
55 | 55 |
56 virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) const SK_
OVERRIDE; | 56 virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) const SK_
OVERRIDE; |
57 virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&, | 57 virtual void onDrawRect(SkCanvas*, const SkRect*, const SkRect&, |
58 const SkPaint*) const SK_OVERRIDE; | 58 const SkPaint*) const SK_OVERRIDE; |
59 virtual bool onReadPixels(SkBitmap*, const SkIRect&) const SK_OVERRIDE; | 59 virtual bool onReadPixels(SkBitmap*, const SkIRect&) const SK_OVERRIDE; |
60 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const S
K_OVERRIDE; | 60 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const S
K_OVERRIDE; |
61 virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE; | 61 virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE; |
62 | 62 |
63 // exposed for SkSurface_Raster via SkNewImageFromPixelRef | 63 // exposed for SkSurface_Raster via SkNewImageFromPixelRef |
64 SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes); | 64 SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes); |
65 | 65 |
66 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } | 66 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } |
67 | 67 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 SkShader* SkImage_Raster::onNewShader(SkShader::TileMode tileX, SkShader::TileMo
de tileY, | 125 SkShader* SkImage_Raster::onNewShader(SkShader::TileMode tileX, SkShader::TileMo
de tileY, |
126 const SkMatrix* localMatrix) const { | 126 const SkMatrix* localMatrix) const { |
127 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix); | 127 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix); |
128 } | 128 } |
129 | 129 |
130 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa
int* paint) const { | 130 void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPa
int* paint) const { |
131 canvas->drawBitmap(fBitmap, x, y, paint); | 131 canvas->drawBitmap(fBitmap, x, y, paint); |
132 } | 132 } |
133 | 133 |
134 void SkImage_Raster::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const
SkRect& dst, | 134 void SkImage_Raster::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRec
t& dst, |
135 const SkPaint* paint) const { | 135 const SkPaint* paint) const { |
136 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); | 136 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); |
137 } | 137 } |
138 | 138 |
139 bool SkImage_Raster::onReadPixels(SkBitmap* dst, const SkIRect& subset) const { | 139 bool SkImage_Raster::onReadPixels(SkBitmap* dst, const SkIRect& subset) const { |
140 if (dst->pixelRef()) { | 140 if (dst->pixelRef()) { |
141 return this->INHERITED::onReadPixels(dst, subset); | 141 return this->INHERITED::onReadPixels(dst, subset); |
142 } else { | 142 } else { |
143 SkBitmap src; | 143 SkBitmap src; |
144 if (!fBitmap.extractSubset(&src, subset)) { | 144 if (!fBitmap.extractSubset(&src, subset)) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes)); | 217 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes)); |
218 } | 218 } |
219 | 219 |
220 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { | 220 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { |
221 return ((SkImage_Raster*)image)->getPixelRef(); | 221 return ((SkImage_Raster*)image)->getPixelRef(); |
222 } | 222 } |
223 | 223 |
224 bool SkImage_Raster::isOpaque() const { | 224 bool SkImage_Raster::isOpaque() const { |
225 return fBitmap.isOpaque(); | 225 return fBitmap.isOpaque(); |
226 } | 226 } |
OLD | NEW |