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 "SkImageEncoder.h" |
11 #include "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
12 #include "SkScalar.h" | 13 #include "SkScalar.h" |
13 | 14 |
14 class SkData; | 15 class SkData; |
15 class SkCanvas; | 16 class SkCanvas; |
16 class SkPaint; | 17 class SkPaint; |
17 class SkShader; | 18 class SkShader; |
18 class GrContext; | 19 class GrContext; |
19 class GrTexture; | 20 class GrTexture; |
20 | 21 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 * does not affect the reference count of the GrTexture object. | 76 * does not affect the reference count of the GrTexture object. |
76 * Will return NULL if the image does not use a texture. | 77 * Will return NULL if the image does not use a texture. |
77 */ | 78 */ |
78 GrTexture* getTexture(); | 79 GrTexture* getTexture(); |
79 | 80 |
80 SkShader* newShaderClamp() const; | 81 SkShader* newShaderClamp() const; |
81 SkShader* newShader(SkShader::TileMode, SkShader::TileMode) const; | 82 SkShader* newShader(SkShader::TileMode, SkShader::TileMode) const; |
82 | 83 |
83 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*); | 84 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*); |
84 | 85 |
85 enum EncodeType { | |
86 kBMP_EncodeType, | |
87 kGIF_EncodeType, | |
88 kICO_EncodeType, | |
89 kJPEG_EncodeType, | |
90 kPNG_EncodeType, | |
91 kWBMP_EncodeType, | |
92 kWEBP_EncodeType, | |
93 }; | |
94 /** | 86 /** |
95 * Encode the image's pixels and return the result as a new SkData, which | 87 * Encode the image's pixels and return the result as a new SkData, which |
96 * the caller must manage (i.e. call unref() when they are done). | 88 * the caller must manage (i.e. call unref() when they are done). |
97 * | 89 * |
98 * If the image type cannot be encoded, or the requested encoder type is | 90 * If the image type cannot be encoded, or the requested encoder type is |
99 * not supported, this will return NULL. | 91 * not supported, this will return NULL. |
100 */ | 92 */ |
101 SkData* encode(EncodeType t = kPNG_EncodeType, int quality = 80) const; | 93 SkData* encode(SkImageEncoder::Type t = SkImageEncoder::kPNG_Type, |
| 94 int quality = 80) const; |
102 | 95 |
103 protected: | 96 protected: |
104 SkImage(int width, int height) : | 97 SkImage(int width, int height) : |
105 fWidth(width), | 98 fWidth(width), |
106 fHeight(height), | 99 fHeight(height), |
107 fUniqueID(NextUniqueID()) { | 100 fUniqueID(NextUniqueID()) { |
108 | 101 |
109 SkASSERT(width >= 0); | 102 SkASSERT(width >= 0); |
110 SkASSERT(height >= 0); | 103 SkASSERT(height >= 0); |
111 } | 104 } |
112 | 105 |
113 private: | 106 private: |
114 const int fWidth; | 107 const int fWidth; |
115 const int fHeight; | 108 const int fHeight; |
116 const uint32_t fUniqueID; | 109 const uint32_t fUniqueID; |
117 | 110 |
118 static uint32_t NextUniqueID(); | 111 static uint32_t NextUniqueID(); |
119 | 112 |
120 typedef SkRefCnt INHERITED; | 113 typedef SkRefCnt INHERITED; |
121 }; | 114 }; |
122 | 115 |
123 #endif | 116 #endif |
OLD | NEW |