Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: src/images/SkImageDecoder_ktx.cpp

Issue 1779263003: Make sp variants for SkData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/images/SkImageDecoder_astc.cpp ('k') | src/images/SkImageDecoder_libbmp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkImageGenerator.h" 10 #include "SkImageGenerator.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 protected: 44 protected:
45 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) override; 45 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) override;
46 46
47 private: 47 private:
48 typedef SkImageDecoder INHERITED; 48 typedef SkImageDecoder INHERITED;
49 }; 49 };
50 50
51 SkImageDecoder::Result SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* b m, Mode mode) { 51 SkImageDecoder::Result SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* b m, Mode mode) {
52 // TODO: Implement SkStream::copyToData() that's cheap for memory and file s treams 52 // TODO: Implement SkStream::copyToData() that's cheap for memory and file s treams
53 SkAutoDataUnref data(SkCopyStreamToData(stream)); 53 auto data = SkCopyStreamToData(stream);
54 if (nullptr == data) { 54 if (nullptr == data) {
55 return kFailure; 55 return kFailure;
56 } 56 }
57 57
58 SkKTXFile ktxFile(data); 58 SkKTXFile ktxFile(data.get());
59 if (!ktxFile.valid()) { 59 if (!ktxFile.valid()) {
60 return kFailure; 60 return kFailure;
61 } 61 }
62 62
63 const unsigned short width = ktxFile.width(); 63 const unsigned short width = ktxFile.width();
64 const unsigned short height = ktxFile.height(); 64 const unsigned short height = ktxFile.height();
65 65
66 // Set a flag if our source is premultiplied alpha 66 // Set a flag if our source is premultiplied alpha
67 const SkString premulKey("KTXPremultipliedAlpha"); 67 const SkString premulKey("KTXPremultipliedAlpha");
68 const bool bSrcIsPremul = ktxFile.getValueForKey(premulKey) == SkString("Tru e"); 68 const bool bSrcIsPremul = ktxFile.getValueForKey(premulKey) == SkString("Tru e");
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 return SkImageDecoder::kUnknown_Format; 322 return SkImageDecoder::kUnknown_Format;
323 } 323 }
324 324
325 SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) { 325 SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) {
326 return (SkImageEncoder::kKTX_Type == t) ? new SkKTXImageEncoder : nullptr; 326 return (SkImageEncoder::kKTX_Type == t) ? new SkKTXImageEncoder : nullptr;
327 } 327 }
328 328
329 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); 329 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory);
330 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); 330 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx);
331 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); 331 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_astc.cpp ('k') | src/images/SkImageDecoder_libbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698