Chromium Code Reviews| 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 "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
| 12 #include "SkScalar.h" | 12 #include "SkScalar.h" |
| 13 | 13 |
| 14 class SkData; | 14 class SkData; |
| 15 class SkCanvas; | 15 class SkCanvas; |
| 16 class SkPaint; | 16 class SkPaint; |
| 17 class SkShader; | 17 class SkShader; |
| 18 class GrContext; | 18 class GrContext; |
| 19 class GrTexture; | 19 class GrTexture; |
| 20 | 20 |
| 21 // need for TileMode | 21 // need for TileMode |
| 22 #include "SkShader.h" | 22 #include "SkShader.h" |
| 23 | 23 |
| 24 ////// EXPERIMENTAL | |
| 25 | |
| 26 /** | 24 /** |
| 27 * 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 |
| 28 * 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 |
| 29 * 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 |
| 30 * into another canvas. | 28 * into another canvas. |
| 31 * | 29 * |
| 32 * The content of SkImage is always immutable, though the actual storage may | 30 * The content of SkImage is always immutable, though the actual storage may |
| 33 * change, if for example that image can be re-created via encoded data or | 31 * change, if for example that image can be re-created via encoded data or |
| 34 * other means. | 32 * other means. |
| 35 */ | 33 */ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 * does not affect the reference count of the GrTexture object. | 75 * does not affect the reference count of the GrTexture object. |
| 78 * Will return NULL if the image does not use a texture. | 76 * Will return NULL if the image does not use a texture. |
| 79 */ | 77 */ |
| 80 GrTexture* getTexture(); | 78 GrTexture* getTexture(); |
| 81 | 79 |
| 82 SkShader* newShaderClamp() const; | 80 SkShader* newShaderClamp() const; |
| 83 SkShader* newShader(SkShader::TileMode, SkShader::TileMode) const; | 81 SkShader* newShader(SkShader::TileMode, SkShader::TileMode) const; |
| 84 | 82 |
| 85 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*); | 83 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*); |
| 86 | 84 |
| 85 enum EncodeType { | |
| 86 kPNG_EncodeType, | |
|
scroggo
2013/05/16 17:34:41
Any reason we don't support all types in SkImageEn
reed1
2013/05/16 17:55:02
Laziness. At first I tried to include SkImageEncod
| |
| 87 kJPEG_EncodeType, | |
| 88 }; | |
| 89 /** | |
| 90 * Encode the image's pixels and return the result as a new SkData, which | |
| 91 * the caller must manage (i.e. call unref() when they are done). | |
| 92 * | |
| 93 * If the image type cannot be encoded, or the requested encoder type is | |
| 94 * not supported, this will return NULL. | |
| 95 */ | |
| 96 SkData* encode(EncodeType t = kPNG_EncodeType, int quality = 80) const; | |
| 97 | |
| 87 protected: | 98 protected: |
| 88 SkImage(int width, int height) : | 99 SkImage(int width, int height) : |
| 89 fWidth(width), | 100 fWidth(width), |
| 90 fHeight(height), | 101 fHeight(height), |
| 91 fUniqueID(NextUniqueID()) { | 102 fUniqueID(NextUniqueID()) { |
| 92 | 103 |
| 93 SkASSERT(width >= 0); | 104 SkASSERT(width >= 0); |
| 94 SkASSERT(height >= 0); | 105 SkASSERT(height >= 0); |
| 95 } | 106 } |
| 96 | 107 |
| 97 private: | 108 private: |
| 98 const int fWidth; | 109 const int fWidth; |
| 99 const int fHeight; | 110 const int fHeight; |
| 100 const uint32_t fUniqueID; | 111 const uint32_t fUniqueID; |
| 101 | 112 |
| 102 static uint32_t NextUniqueID(); | 113 static uint32_t NextUniqueID(); |
| 103 | 114 |
| 104 typedef SkRefCnt INHERITED; | 115 typedef SkRefCnt INHERITED; |
| 105 }; | 116 }; |
| 106 | 117 |
| 107 #endif | 118 #endif |
| OLD | NEW |