| 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 "SkImageInfo.h" | 11 #include "SkImageInfo.h" |
| 12 #include "SkImageEncoder.h" | 12 #include "SkImageEncoder.h" |
| 13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
| 14 #include "SkScalar.h" | 14 #include "SkScalar.h" |
| 15 #include "SkShader.h" | 15 #include "SkShader.h" |
| 16 | 16 |
| 17 class SkData; | 17 class SkData; |
| 18 class SkCanvas; | 18 class SkCanvas; |
| 19 class SkImageGenerator; |
| 19 class SkPaint; | 20 class SkPaint; |
| 20 class GrContext; | 21 class GrContext; |
| 21 class GrTexture; | 22 class GrTexture; |
| 22 | 23 |
| 23 /** | 24 /** |
| 24 * SkImage is an abstraction for drawing a rectagle of pixels, though the | 25 * SkImage is an abstraction for drawing a rectagle of pixels, though the |
| 25 * particular type of image could be actually storing its data on the GPU, or | 26 * particular type of image could be actually storing its data on the GPU, or |
| 26 * as drawing commands (picture or PDF or otherwise), ready to be played back | 27 * as drawing commands (picture or PDF or otherwise), ready to be played back |
| 27 * into another canvas. | 28 * into another canvas. |
| 28 * | 29 * |
| (...skipping 11 matching lines...) Expand all Loading... |
| 40 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes); | 41 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes); |
| 41 static SkImage* NewEncodedData(SkData*); | 42 static SkImage* NewEncodedData(SkData*); |
| 42 | 43 |
| 43 /** | 44 /** |
| 44 * GrTexture is a more logical parameter for this factory, but its | 45 * GrTexture is a more logical parameter for this factory, but its |
| 45 * interactions with scratch cache still has issues, so for now we take | 46 * interactions with scratch cache still has issues, so for now we take |
| 46 * SkBitmap instead. This will be changed in the future. skbug.com/1449 | 47 * SkBitmap instead. This will be changed in the future. skbug.com/1449 |
| 47 */ | 48 */ |
| 48 static SkImage* NewTexture(const SkBitmap&); | 49 static SkImage* NewTexture(const SkBitmap&); |
| 49 | 50 |
| 51 /** |
| 52 * Construct a new SkImage based on the given ImageGenerator. |
| 53 * This function will always take ownership of the passed |
| 54 * ImageGenerator. Returns NULL on error. |
| 55 */ |
| 56 static SkImage* NewFromGenerator(SkImageGenerator*); |
| 57 |
| 50 int width() const { return fWidth; } | 58 int width() const { return fWidth; } |
| 51 int height() const { return fHeight; } | 59 int height() const { return fHeight; } |
| 52 uint32_t uniqueID() const { return fUniqueID; } | 60 uint32_t uniqueID() const { return fUniqueID; } |
| 53 | 61 |
| 54 /** | 62 /** |
| 55 * Return the GrTexture that stores the image pixels. Calling getTexture | 63 * Return the GrTexture that stores the image pixels. Calling getTexture |
| 56 * does not affect the reference count of the GrTexture object. | 64 * does not affect the reference count of the GrTexture object. |
| 57 * Will return NULL if the image does not use a texture. | 65 * Will return NULL if the image does not use a texture. |
| 58 */ | 66 */ |
| 59 GrTexture* getTexture(); | 67 GrTexture* getTexture(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 * On failure, false will be returned, and bitmap will unmodified. | 139 * On failure, false will be returned, and bitmap will unmodified. |
| 132 */ | 140 */ |
| 133 // On ice for now: | 141 // On ice for now: |
| 134 // - should it respect the particular colortype/alphatype of the src | 142 // - should it respect the particular colortype/alphatype of the src |
| 135 // - should it have separate entrypoints for preallocated and not bitmaps? | 143 // - should it have separate entrypoints for preallocated and not bitmaps? |
| 136 // - isn't it enough to allow the caller to draw() the image into a canvas? | 144 // - isn't it enough to allow the caller to draw() the image into a canvas? |
| 137 bool readPixels(SkBitmap* bitmap, const SkIRect* subset = NULL) const; | 145 bool readPixels(SkBitmap* bitmap, const SkIRect* subset = NULL) const; |
| 138 }; | 146 }; |
| 139 | 147 |
| 140 #endif | 148 #endif |
| OLD | NEW |