OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_CODEC_PNG_CODEC_H_ | 5 #ifndef UI_GFX_CODEC_PNG_CODEC_H_ |
6 #define UI_GFX_CODEC_PNG_CODEC_H_ | 6 #define UI_GFX_CODEC_PNG_CODEC_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 static bool Decode(const unsigned char* input, size_t input_size, | 108 static bool Decode(const unsigned char* input, size_t input_size, |
109 ColorFormat format, std::vector<unsigned char>* output, | 109 ColorFormat format, std::vector<unsigned char>* output, |
110 int* w, int* h); | 110 int* w, int* h); |
111 | 111 |
112 // Decodes the PNG data directly into the passed in SkBitmap. This is | 112 // Decodes the PNG data directly into the passed in SkBitmap. This is |
113 // significantly faster than the vector<unsigned char> version of Decode() | 113 // significantly faster than the vector<unsigned char> version of Decode() |
114 // above when dealing with PNG files that are >500K, which a lot of theme | 114 // above when dealing with PNG files that are >500K, which a lot of theme |
115 // images are. (There are a lot of themes that have a NTP image of about ~1 | 115 // images are. (There are a lot of themes that have a NTP image of about ~1 |
116 // megabyte, and those require a 7-10 megabyte side buffer.) | 116 // megabyte, and those require a 7-10 megabyte side buffer.) |
117 // | 117 // |
| 118 // If |percent| is not NULL, it is filled with the value from Chrome's custom |
| 119 // csCl chunk, if present, or -1 otherwise. |
| 120 // |
118 // Returns true if data is non-null and can be decoded as a png, false | 121 // Returns true if data is non-null and can be decoded as a png, false |
119 // otherwise. | 122 // otherwise. |
120 static bool Decode(const unsigned char* input, size_t input_size, | 123 static bool Decode(const unsigned char* input, size_t input_size, |
| 124 SkBitmap* bitmap, int* percent); |
| 125 |
| 126 // Most clients don't need the |percent| argument. |
| 127 static bool Decode(const unsigned char* input, size_t input_size, |
121 SkBitmap* bitmap); | 128 SkBitmap* bitmap); |
122 | 129 |
123 // Create a SkBitmap from a decoded BGRA DIB. The caller owns the returned | 130 // Create a SkBitmap from a decoded BGRA DIB. The caller owns the returned |
124 // SkBitmap. | 131 // SkBitmap. |
125 static SkBitmap* CreateSkBitmapFromBGRAFormat( | 132 static SkBitmap* CreateSkBitmapFromBGRAFormat( |
126 std::vector<unsigned char>& bgra, int width, int height); | 133 std::vector<unsigned char>& bgra, int width, int height); |
127 | 134 |
128 private: | 135 private: |
129 DISALLOW_COPY_AND_ASSIGN(PNGCodec); | 136 DISALLOW_COPY_AND_ASSIGN(PNGCodec); |
130 }; | 137 }; |
131 | 138 |
132 } // namespace gfx | 139 } // namespace gfx |
133 | 140 |
134 #endif // UI_GFX_CODEC_PNG_CODEC_H_ | 141 #endif // UI_GFX_CODEC_PNG_CODEC_H_ |
OLD | NEW |