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_DEFINED | 8 #ifndef SkImage_DEFINED |
9 #define SkImage_DEFINED | 9 #define SkImage_DEFINED |
10 | 10 |
11 #include "SkImageInfo.h" | 11 #include "SkImageInfo.h" |
12 #include "SkImageEncoder.h" | 12 #include "SkImageEncoder.h" |
13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
14 #include "SkScalar.h" | 14 #include "SkScalar.h" |
15 #include "SkShader.h" | 15 #include "SkShader.h" |
16 | 16 |
17 class SkData; | 17 class SkData; |
18 class SkCanvas; | 18 class SkCanvas; |
19 class SkImageGenerator; | 19 class SkImageGenerator; |
20 class SkPaint; | 20 class SkPaint; |
| 21 class SkSurface; |
| 22 class SkSurfaceProps; |
21 class GrContext; | 23 class GrContext; |
22 class GrTexture; | 24 class GrTexture; |
23 | 25 |
24 /** | 26 /** |
25 * SkImage is an abstraction for drawing a rectagle of pixels, though the | 27 * SkImage is an abstraction for drawing a rectagle of pixels, though the |
26 * particular type of image could be actually storing its data on the GPU, or | 28 * particular type of image could be actually storing its data on the GPU, or |
27 * as drawing commands (picture or PDF or otherwise), ready to be played back | 29 * as drawing commands (picture or PDF or otherwise), ready to be played back |
28 * into another canvas. | 30 * into another canvas. |
29 * | 31 * |
30 * The content of SkImage is always immutable, though the actual storage may | 32 * The content of SkImage is always immutable, though the actual storage may |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 /** | 87 /** |
86 * Encode the image's pixels and return the result as a new SkData, which | 88 * Encode the image's pixels and return the result as a new SkData, which |
87 * the caller must manage (i.e. call unref() when they are done). | 89 * the caller must manage (i.e. call unref() when they are done). |
88 * | 90 * |
89 * If the image type cannot be encoded, or the requested encoder type is | 91 * If the image type cannot be encoded, or the requested encoder type is |
90 * not supported, this will return NULL. | 92 * not supported, this will return NULL. |
91 */ | 93 */ |
92 SkData* encode(SkImageEncoder::Type t = SkImageEncoder::kPNG_Type, | 94 SkData* encode(SkImageEncoder::Type t = SkImageEncoder::kPNG_Type, |
93 int quality = 80) const; | 95 int quality = 80) const; |
94 | 96 |
| 97 /** |
| 98 * Return a new surface that is compatible with this image's internal repre
sentation |
| 99 * (e.g. raster or gpu). |
| 100 * |
| 101 * If no surfaceprops are specified, the image will attempt to match the pr
ops of when it |
| 102 * was created (if it came from a surface). |
| 103 */ |
| 104 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL) cons
t; |
| 105 |
95 protected: | 106 protected: |
96 SkImage(int width, int height) : | 107 SkImage(int width, int height) : |
97 fWidth(width), | 108 fWidth(width), |
98 fHeight(height), | 109 fHeight(height), |
99 fUniqueID(NextUniqueID()) { | 110 fUniqueID(NextUniqueID()) { |
100 | 111 |
101 SkASSERT(width >= 0); | 112 SkASSERT(width >= 0); |
102 SkASSERT(height >= 0); | 113 SkASSERT(height >= 0); |
103 } | 114 } |
104 | 115 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 * On failure, false will be returned, and bitmap will unmodified. | 153 * On failure, false will be returned, and bitmap will unmodified. |
143 */ | 154 */ |
144 // On ice for now: | 155 // On ice for now: |
145 // - should it respect the particular colortype/alphatype of the src | 156 // - should it respect the particular colortype/alphatype of the src |
146 // - should it have separate entrypoints for preallocated and not bitmaps? | 157 // - should it have separate entrypoints for preallocated and not bitmaps? |
147 // - isn't it enough to allow the caller to draw() the image into a canvas? | 158 // - isn't it enough to allow the caller to draw() the image into a canvas? |
148 bool readPixels(SkBitmap* bitmap, const SkIRect* subset = NULL) const; | 159 bool readPixels(SkBitmap* bitmap, const SkIRect* subset = NULL) const; |
149 }; | 160 }; |
150 | 161 |
151 #endif | 162 #endif |
OLD | NEW |