| 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 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 95 | 84 |
| 96 /** | 85 /** |
| 97 * Encode the image's pixels and return the result as a new SkData, which | 86 * Encode the image's pixels and return the result as a new SkData, which |
| 98 * the caller must manage (i.e. call unref() when they are done). | 87 * the caller must manage (i.e. call unref() when they are done). |
| 99 * | 88 * |
| 100 * If the image type cannot be encoded, or the requested encoder type is | 89 * If the image type cannot be encoded, or the requested encoder type is |
| 101 * not supported, this will return NULL. | 90 * not supported, this will return NULL. |
| 102 */ | 91 */ |
| 103 SkData* encode(SkImageEncoder::Type t = SkImageEncoder::kPNG_Type, | 92 SkData* encode(SkImageEncoder::Type t = SkImageEncoder::kPNG_Type, |
| 104 int quality = 80) const; | 93 int quality = 80) const; |
| 105 | 94 |
| 95 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; |
| 96 |
| 97 /** |
| 98 * Draw the image, cropped to the src rect, to the dst rect of a canvas. |
| 99 * If src is larger than the bounds of the image, the rest of the image is |
| 100 * filled with transparent black pixels. |
| 101 * |
| 102 * See SkCanvas::drawBitmapRectToRect for similar behavior. |
| 103 */ |
| 104 void draw(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint*) c
onst; |
| 105 |
| 106 protected: | 106 protected: |
| 107 SkImage(int width, int height) : | 107 SkImage(int width, int height) : |
| 108 fWidth(width), | 108 fWidth(width), |
| 109 fHeight(height), | 109 fHeight(height), |
| 110 fUniqueID(NextUniqueID()) { | 110 fUniqueID(NextUniqueID()) { |
| 111 | 111 |
| 112 SkASSERT(width >= 0); | 112 SkASSERT(width >= 0); |
| 113 SkASSERT(height >= 0); | 113 SkASSERT(height >= 0); |
| 114 } | 114 } |
| 115 | 115 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 140 * On failure, false will be returned, and bitmap will unmodified. | 140 * On failure, false will be returned, and bitmap will unmodified. |
| 141 */ | 141 */ |
| 142 // On ice for now: | 142 // On ice for now: |
| 143 // - should it respect the particular colortype/alphatype of the src | 143 // - should it respect the particular colortype/alphatype of the src |
| 144 // - should it have separate entrypoints for preallocated and not bitmaps? | 144 // - 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? | 145 // - 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; | 146 bool readPixels(SkBitmap* bitmap, const SkIRect* subset = NULL) const; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 #endif | 149 #endif |
| OLD | NEW |