Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: include/core/SkImage.h

Issue 821083002: add newImage API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: check when subset == bounds Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkFilterQuality.h ('k') | include/core/SkPaint.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « include/core/SkFilterQuality.h ('k') | include/core/SkPaint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698