| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
| 9 #include "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
| 10 #include "SkPixelRef.h" | 10 #include "SkPixelRef.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 typedef SkImageEncoder INHERITED; | 265 typedef SkImageEncoder INHERITED; |
| 266 }; | 266 }; |
| 267 | 267 |
| 268 bool SkKTXImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int)
{ | 268 bool SkKTXImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int)
{ |
| 269 if (!bitmap.pixelRef()) { | 269 if (!bitmap.pixelRef()) { |
| 270 return false; | 270 return false; |
| 271 } | 271 } |
| 272 SkAutoDataUnref data(bitmap.pixelRef()->refEncodedData()); | 272 SkAutoDataUnref data(bitmap.pixelRef()->refEncodedData()); |
| 273 | 273 |
| 274 // Is this even encoded data? | 274 // Is this even encoded data? |
| 275 if (NULL != data) { | 275 if (data) { |
| 276 const uint8_t *bytes = data->bytes(); | 276 const uint8_t *bytes = data->bytes(); |
| 277 if (etc1_pkm_is_valid(bytes)) { | 277 if (etc1_pkm_is_valid(bytes)) { |
| 278 return this->encodePKM(stream, data); | 278 return this->encodePKM(stream, data); |
| 279 } | 279 } |
| 280 | 280 |
| 281 // Is it a KTX file?? | 281 // Is it a KTX file?? |
| 282 if (SkKTXFile::is_ktx(bytes)) { | 282 if (SkKTXFile::is_ktx(bytes)) { |
| 283 return stream->write(bytes, data->size()); | 283 return stream->write(bytes, data->size()); |
| 284 } | 284 } |
| 285 | 285 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 return SkImageDecoder::kUnknown_Format; | 328 return SkImageDecoder::kUnknown_Format; |
| 329 } | 329 } |
| 330 | 330 |
| 331 SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) { | 331 SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) { |
| 332 return (SkImageEncoder::kKTX_Type == t) ? SkNEW(SkKTXImageEncoder) : NULL; | 332 return (SkImageEncoder::kKTX_Type == t) ? SkNEW(SkKTXImageEncoder) : NULL; |
| 333 } | 333 } |
| 334 | 334 |
| 335 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); | 335 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); |
| 336 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); | 336 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); |
| 337 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); | 337 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); |
| OLD | NEW |