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

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

Issue 583453002: SkCanvas::drawImage is the new way for drawing an SkImage to a Canvas (Closed) Base URL: https://skia.googlesource.com/skia.git@refactor_skImage
Patch Set: Again Created 6 years, 2 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
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 * Return the GrTexture that stores the image pixels. Calling getTexture 64 * Return the GrTexture that stores the image pixels. Calling getTexture
65 * does not affect the reference count of the GrTexture object. 65 * does not affect the reference count of the GrTexture object.
66 * Will return NULL if the image does not use a texture. 66 * Will return NULL if the image does not use a texture.
67 */ 67 */
68 GrTexture* getTexture(); 68 GrTexture* getTexture();
69 69
70 virtual SkShader* newShader(SkShader::TileMode, 70 virtual SkShader* newShader(SkShader::TileMode,
71 SkShader::TileMode, 71 SkShader::TileMode,
72 const SkMatrix* localMatrix = NULL) const; 72 const SkMatrix* localMatrix = NULL) const;
73 73
74 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const;
75
76 /**
77 * Draw the image, cropped to the src rect, to the dst rect of a canvas.
78 * If src is larger than the bounds of the image, the rest of the image is
79 * filled with transparent black pixels.
80 *
81 * See SkCanvas::drawBitmapRectToRect for similar behavior.
82 */
83 void draw(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint*) c onst;
84
85 /** 74 /**
86 * If the image has direct access to its pixels (i.e. they are in local 75 * If the image has direct access to its pixels (i.e. they are in local
87 * RAM) return the (const) address of those pixels, and if not null, return 76 * RAM) return the (const) address of those pixels, and if not null, return
88 * the ImageInfo and rowBytes. The returned address is only valid while 77 * the ImageInfo and rowBytes. The returned address is only valid while
89 * the image object is in scope. 78 * the image object is in scope.
90 * 79 *
91 * On failure, returns NULL and the info and rowBytes parameters are 80 * On failure, returns NULL and the info and rowBytes parameters are
92 * ignored. 81 * ignored.
93 */ 82 */
94 const void* peekPixels(SkImageInfo* info, size_t* rowBytes) const; 83 const void* peekPixels(SkImageInfo* info, size_t* rowBytes) const;
(...skipping 20 matching lines...) Expand all
115 104
116 private: 105 private:
117 const int fWidth; 106 const int fWidth;
118 const int fHeight; 107 const int fHeight;
119 const uint32_t fUniqueID; 108 const uint32_t fUniqueID;
120 109
121 static uint32_t NextUniqueID(); 110 static uint32_t NextUniqueID();
122 111
123 typedef SkRefCnt INHERITED; 112 typedef SkRefCnt INHERITED;
124 113
114 friend class SkCanvas;
115
116 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const;
117
118 /**
119 * Draw the image, cropped to the src rect, to the dst rect of a canvas.
120 * If src is larger than the bounds of the image, the rest of the image is
121 * filled with transparent black pixels.
122 *
123 * See SkCanvas::drawBitmapRectToRect for similar behavior.
124 */
125 void draw(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint*) c onst;
126
125 /** 127 /**
126 * Return a copy of the image's pixels, limiting them to the subset 128 * Return a copy of the image's pixels, limiting them to the subset
127 * rectangle's intersection wit the image bounds. If subset is NULL, then 129 * rectangle's intersection wit the image bounds. If subset is NULL, then
128 * the entire image will be considered. 130 * the entire image will be considered.
129 * 131 *
130 * If the bitmap's pixels have already been allocated, then readPixels() 132 * If the bitmap's pixels have already been allocated, then readPixels()
131 * will succeed only if it can support converting the image's pixels into 133 * will succeed only if it can support converting the image's pixels into
132 * the bitmap's ColorType/AlphaType. Any pixels in the bitmap that do not 134 * the bitmap's ColorType/AlphaType. Any pixels in the bitmap that do not
133 * intersect with the image's bounds and the subset (if not null) will be 135 * intersect with the image's bounds and the subset (if not null) will be
134 * left untouched. 136 * left untouched.
135 * 137 *
136 * If the bitmap is initially empty/unallocated, then it will be allocated 138 * If the bitmap is initially empty/unallocated, then it will be allocated
137 * using the default allocator, and the ColorType/AlphaType will be chosen 139 * using the default allocator, and the ColorType/AlphaType will be chosen
138 * to most closely fit the image's configuration. 140 * to most closely fit the image's configuration.
139 * 141 *
140 * On failure, false will be returned, and bitmap will unmodified. 142 * On failure, false will be returned, and bitmap will unmodified.
141 */ 143 */
142 // On ice for now: 144 // On ice for now:
143 // - should it respect the particular colortype/alphatype of the src 145 // - should it respect the particular colortype/alphatype of the src
144 // - should it have separate entrypoints for preallocated and not bitmaps? 146 // - should it have separate entrypoints for preallocated and not bitmaps?
145 // - isn't it enough to allow the caller to draw() the image into a canvas? 147 // - isn't it enough to allow the caller to draw() the image into a canvas?
146 bool readPixels(SkBitmap* bitmap, const SkIRect* subset = NULL) const; 148 bool readPixels(SkBitmap* bitmap, const SkIRect* subset = NULL) const;
147 }; 149 };
148 150
149 #endif 151 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698