| 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 18 matching lines...) Expand all Loading... |
| 29 // | 29 // |
| 30 // This decoder is meant to be used with an SkDiscardablePixelRef so that GPU ba
ckends | 30 // This decoder is meant to be used with an SkDiscardablePixelRef so that GPU ba
ckends |
| 31 // can sniff the data before creating a texture. If they encounter a compressed
format | 31 // can sniff the data before creating a texture. If they encounter a compressed
format |
| 32 // that they understand, they can then upload the data directly to the GPU. Othe
rwise, | 32 // that they understand, they can then upload the data directly to the GPU. Othe
rwise, |
| 33 // they will decode the data into a format that Skia supports. | 33 // they will decode the data into a format that Skia supports. |
| 34 | 34 |
| 35 class SkKTXImageDecoder : public SkImageDecoder { | 35 class SkKTXImageDecoder : public SkImageDecoder { |
| 36 public: | 36 public: |
| 37 SkKTXImageDecoder() { } | 37 SkKTXImageDecoder() { } |
| 38 | 38 |
| 39 Format getFormat() const SK_OVERRIDE { | 39 SkEncodedFormat getFormat() const SK_OVERRIDE { |
| 40 return kKTX_Format; | 40 return kKTX_SkEncodedFormat; |
| 41 } | 41 } |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE; | 44 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE; |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 typedef SkImageDecoder INHERITED; | 47 typedef SkImageDecoder INHERITED; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 SkImageDecoder::Result SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* b
m, Mode mode) { | 50 SkImageDecoder::Result SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* b
m, Mode mode) { |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 DEFINE_ENCODER_CREATOR(KTXImageEncoder); | 307 DEFINE_ENCODER_CREATOR(KTXImageEncoder); |
| 308 ////////////////////////////////////////////////////////////////////////////////
///////// | 308 ////////////////////////////////////////////////////////////////////////////////
///////// |
| 309 | 309 |
| 310 static SkImageDecoder* sk_libktx_dfactory(SkStreamRewindable* stream) { | 310 static SkImageDecoder* sk_libktx_dfactory(SkStreamRewindable* stream) { |
| 311 if (SkKTXFile::is_ktx(stream)) { | 311 if (SkKTXFile::is_ktx(stream)) { |
| 312 return SkNEW(SkKTXImageDecoder); | 312 return SkNEW(SkKTXImageDecoder); |
| 313 } | 313 } |
| 314 return NULL; | 314 return NULL; |
| 315 } | 315 } |
| 316 | 316 |
| 317 static SkImageDecoder::Format get_format_ktx(SkStreamRewindable* stream) { | 317 static SkEncodedFormat get_format_ktx(SkStreamRewindable* stream) { |
| 318 if (SkKTXFile::is_ktx(stream)) { | 318 if (SkKTXFile::is_ktx(stream)) { |
| 319 return SkImageDecoder::kKTX_Format; | 319 return kKTX_SkEncodedFormat; |
| 320 } | 320 } |
| 321 return SkImageDecoder::kUnknown_Format; | 321 return kUnknown_SkEncodedFormat; |
| 322 } | 322 } |
| 323 | 323 |
| 324 SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) { | 324 SkImageEncoder* sk_libktx_efactory(SkEncodedFormat t) { |
| 325 return (SkImageEncoder::kKTX_Type == t) ? SkNEW(SkKTXImageEncoder) : NULL; | 325 return (kKTX_SkEncodedFormat == t) ? SkNEW(SkKTXImageEncoder) : NULL; |
| 326 } | 326 } |
| 327 | 327 |
| 328 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); | 328 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); |
| 329 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); | 329 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); |
| 330 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); | 330 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); |
| OLD | NEW |