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

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: add gm 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
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 * - it is legal for the returned image to be the same instance as the src image
145 * (if the new dimensions == the src dimensions and subset is NULL or == src dimensions).
146 *
147 * - it is legal for the "scaled" image to have changed its SkAlphaType fro m unpremul
148 * to premul (as required by the impl). The image should draw (nearly) id entically,
scroggo 2015/01/21 22:24:57 As discussed in person, it seems like this will *r
149 * since during drawing we will "apply the alpha" to the pixels. Future o ptimizations
150 * may take away this caveat, preserving unpremul.
151 */
152 SkImage* newImage(int newWidth, int newHeight, const SkIRect* subset = NULL,
153 SkFilterQuality = kNone_SkFilterQuality) const;
154
135 protected: 155 protected:
136 SkImage(int width, int height) : 156 SkImage(int width, int height) :
137 fWidth(width), 157 fWidth(width),
138 fHeight(height), 158 fHeight(height),
139 fUniqueID(NextUniqueID()) { 159 fUniqueID(NextUniqueID()) {
140 160
141 SkASSERT(width > 0); 161 SkASSERT(width > 0);
142 SkASSERT(height > 0); 162 SkASSERT(height > 0);
143 } 163 }
144 164
(...skipping 14 matching lines...) Expand all
159 * Draw the image, cropped to the src rect, to the dst rect of a canvas. 179 * 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 180 * If src is larger than the bounds of the image, the rest of the image is
161 * filled with transparent black pixels. 181 * filled with transparent black pixels.
162 * 182 *
163 * See SkCanvas::drawBitmapRectToRect for similar behavior. 183 * See SkCanvas::drawBitmapRectToRect for similar behavior.
164 */ 184 */
165 void drawRect(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint *) const; 185 void drawRect(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint *) const;
166 }; 186 };
167 187
168 #endif 188 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698