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 "SkFilterQuality.h" |
11 #include "SkImageInfo.h" | 12 #include "SkImageInfo.h" |
12 #include "SkImageEncoder.h" | 13 #include "SkImageEncoder.h" |
13 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
14 #include "SkScalar.h" | 15 #include "SkScalar.h" |
15 #include "SkShader.h" | 16 #include "SkShader.h" |
16 | 17 |
17 class SkData; | 18 class SkData; |
18 class SkCanvas; | 19 class SkCanvas; |
19 class SkImageGenerator; | 20 class SkImageGenerator; |
20 class SkPaint; | 21 class SkPaint; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 * Return a new surface that is compatible with this image's internal repre
sentation | 126 * Return a new surface that is compatible with this image's internal repre
sentation |
126 * (e.g. raster or gpu). | 127 * (e.g. raster or gpu). |
127 * | 128 * |
128 * If no surfaceprops are specified, the image will attempt to match the pr
ops of when it | 129 * If no surfaceprops are specified, the image will attempt to match the pr
ops of when it |
129 * was created (if it came from a surface). | 130 * was created (if it came from a surface). |
130 */ | 131 */ |
131 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL) cons
t; | 132 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL) cons
t; |
132 | 133 |
133 const char* toString(SkString*) const; | 134 const char* toString(SkString*) const; |
134 | 135 |
| 136 /** |
| 137 * Return an image that is a rescale of this image (using newWidth, newHeig
ht). |
| 138 * |
| 139 * If subset is NULL, then the entire original image is used as the src for
the scaling. |
| 140 * If subset is not NULL, then it specifies subset of src-pixels used for s
caling. If |
| 141 * subset extends beyond the bounds of the original image, then NULL is ret
urned. |
| 142 * |
| 143 * Notes: |
| 144 * - newWidth and newHeight must be > 0 or NULL will be returned. |
| 145 * |
| 146 * - it is legal for the returned image to be the same instance as the src
image |
| 147 * (if the new dimensions == the src dimensions and subset is NULL or ==
src dimensions). |
| 148 * |
| 149 * - it is legal for the "scaled" image to have changed its SkAlphaType fro
m unpremul |
| 150 * to premul (as required by the impl). The image should draw (nearly) id
entically, |
| 151 * since during drawing we will "apply the alpha" to the pixels. Future o
ptimizations |
| 152 * may take away this caveat, preserving unpremul. |
| 153 */ |
| 154 SkImage* newImage(int newWidth, int newHeight, const SkIRect* subset = NULL, |
| 155 SkFilterQuality = kNone_SkFilterQuality) const; |
| 156 |
135 protected: | 157 protected: |
136 SkImage(int width, int height) : | 158 SkImage(int width, int height) : |
137 fWidth(width), | 159 fWidth(width), |
138 fHeight(height), | 160 fHeight(height), |
139 fUniqueID(NextUniqueID()) { | 161 fUniqueID(NextUniqueID()) { |
140 | 162 |
141 SkASSERT(width > 0); | 163 SkASSERT(width > 0); |
142 SkASSERT(height > 0); | 164 SkASSERT(height > 0); |
143 } | 165 } |
144 | 166 |
(...skipping 14 matching lines...) Expand all Loading... |
159 * Draw the image, cropped to the src rect, to the dst rect of a canvas. | 181 * Draw the image, cropped to the src rect, to the dst rect of a canvas. |
160 * If src is larger than the bounds of the image, the rest of the image is | 182 * If src is larger than the bounds of the image, the rest of the image is |
161 * filled with transparent black pixels. | 183 * filled with transparent black pixels. |
162 * | 184 * |
163 * See SkCanvas::drawBitmapRectToRect for similar behavior. | 185 * See SkCanvas::drawBitmapRectToRect for similar behavior. |
164 */ | 186 */ |
165 void drawRect(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint
*) const; | 187 void drawRect(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint
*) const; |
166 }; | 188 }; |
167 | 189 |
168 #endif | 190 #endif |
OLD | NEW |