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 #ifndef SkImage_Base_DEFINED | 8 #ifndef SkImage_Base_DEFINED |
9 #define SkImage_Base_DEFINED | 9 #define SkImage_Base_DEFINED |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 new (mutableProps) SkSurfaceProps(props); | 34 new (mutableProps) SkSurfaceProps(props); |
35 } | 35 } |
36 | 36 |
37 const SkSurfaceProps& props() const { return fProps; } | 37 const SkSurfaceProps& props() const { return fProps; } |
38 | 38 |
39 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const
= 0; | 39 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const
= 0; |
40 virtual void onDrawRect(SkCanvas*, const SkRect* src, | 40 virtual void onDrawRect(SkCanvas*, const SkRect* src, |
41 const SkRect& dst, const SkPaint*) const = 0; | 41 const SkRect& dst, const SkPaint*) const = 0; |
42 virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) c
onst = 0; | 42 virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) c
onst = 0; |
43 | 43 |
44 // Default impl calls onDraw | |
45 virtual bool onReadPixels(SkBitmap*, const SkIRect& subset) const; | |
46 | |
47 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const { | 44 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const { |
48 return NULL; | 45 return NULL; |
49 } | 46 } |
50 | 47 |
| 48 // Default impl calls onDraw |
| 49 virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_
t dstRowBytes, |
| 50 int srcX, int srcY) const; |
| 51 |
51 virtual GrTexture* onGetTexture() const { return NULL; } | 52 virtual GrTexture* onGetTexture() const { return NULL; } |
52 | 53 |
53 // return a read-only copy of the pixels. We promise to not modify them, | 54 // return a read-only copy of the pixels. We promise to not modify them, |
54 // but only inspect them (or encode them). | 55 // but only inspect them (or encode them). |
55 virtual bool getROPixels(SkBitmap*) const { return false; } | 56 virtual bool getROPixels(SkBitmap*) const { return false; } |
56 | 57 |
57 virtual SkShader* onNewShader(SkShader::TileMode, | 58 virtual SkShader* onNewShader(SkShader::TileMode, |
58 SkShader::TileMode, | 59 SkShader::TileMode, |
59 const SkMatrix* localMatrix) const { return NU
LL; }; | 60 const SkMatrix* localMatrix) const { return NU
LL; }; |
60 | 61 |
61 private: | 62 private: |
62 const SkSurfaceProps fProps; | 63 const SkSurfaceProps fProps; |
63 | 64 |
64 typedef SkImage INHERITED; | 65 typedef SkImage INHERITED; |
65 }; | 66 }; |
66 | 67 |
67 static inline SkImage_Base* as_IB(SkImage* image) { | 68 static inline SkImage_Base* as_IB(SkImage* image) { |
68 return static_cast<SkImage_Base*>(image); | 69 return static_cast<SkImage_Base*>(image); |
69 } | 70 } |
70 | 71 |
71 static inline const SkImage_Base* as_IB(const SkImage* image) { | 72 static inline const SkImage_Base* as_IB(const SkImage* image) { |
72 return static_cast<const SkImage_Base*>(image); | 73 return static_cast<const SkImage_Base*>(image); |
73 } | 74 } |
74 | 75 |
75 #endif | 76 #endif |
OLD | NEW |