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

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

Issue 1604963002: SkStream/Priv cleanups (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update header description Created 4 years, 11 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_libico.cpp ('k') | src/ports/SkImageDecoder_CG.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 "SkData.h"
9 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
10 #include "SkScaledBitmapSampler.h" 11 #include "SkScaledBitmapSampler.h"
11 #include "SkStream.h" 12 #include "SkStream.h"
12 #include "SkStreamPriv.h" 13 #include "SkStreamPriv.h"
13 #include "SkTextureCompressor.h" 14 #include "SkTextureCompressor.h"
14 #include "SkTypes.h" 15 #include "SkTypes.h"
15 16
16 #include "etc1.h" 17 #include "etc1.h"
17 18
18 class SkPKMImageDecoder : public SkImageDecoder { 19 class SkPKMImageDecoder : public SkImageDecoder {
19 public: 20 public:
20 SkPKMImageDecoder() { } 21 SkPKMImageDecoder() { }
21 22
22 Format getFormat() const override { 23 Format getFormat() const override {
23 return kPKM_Format; 24 return kPKM_Format;
24 } 25 }
25 26
26 protected: 27 protected:
27 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) override; 28 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) override;
28 29
29 private: 30 private:
30 typedef SkImageDecoder INHERITED; 31 typedef SkImageDecoder INHERITED;
31 }; 32 };
32 33
33 //////////////////////////////////////////////////////////////////////////////// ///////// 34 //////////////////////////////////////////////////////////////////////////////// /////////
34 35
35 SkImageDecoder::Result SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* b m, Mode mode) { 36 SkImageDecoder::Result SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* b m, Mode mode) {
36 SkAutoMalloc autoMal; 37 SkAutoTUnref<SkData> data(SkCopyStreamToData(stream));
37 const size_t length = SkCopyStreamToStorage(&autoMal, stream); 38 if (!data || !data->size()) {
38 if (0 == length) {
39 return kFailure; 39 return kFailure;
40 } 40 }
41 41
42 unsigned char* buf = (unsigned char*)autoMal.get(); 42 unsigned char* buf = (unsigned char*) data->data();
43 43
44 // Make sure original PKM header is there... 44 // Make sure original PKM header is there...
45 SkASSERT(etc1_pkm_is_valid(buf)); 45 SkASSERT(etc1_pkm_is_valid(buf));
46 46
47 const unsigned short width = etc1_pkm_get_width(buf); 47 const unsigned short width = etc1_pkm_get_width(buf);
48 const unsigned short height = etc1_pkm_get_height(buf); 48 const unsigned short height = etc1_pkm_get_height(buf);
49 49
50 // Setup the sampler... 50 // Setup the sampler...
51 SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); 51 SkScaledBitmapSampler sampler(width, height, this->getSampleSize());
52 52
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 static SkImageDecoder_DecodeReg gReg(sk_libpkm_dfactory); 119 static SkImageDecoder_DecodeReg gReg(sk_libpkm_dfactory);
120 120
121 static SkImageDecoder::Format get_format_pkm(SkStreamRewindable* stream) { 121 static SkImageDecoder::Format get_format_pkm(SkStreamRewindable* stream) {
122 if (is_pkm(stream)) { 122 if (is_pkm(stream)) {
123 return SkImageDecoder::kPKM_Format; 123 return SkImageDecoder::kPKM_Format;
124 } 124 }
125 return SkImageDecoder::kUnknown_Format; 125 return SkImageDecoder::kUnknown_Format;
126 } 126 }
127 127
128 static SkImageDecoder_FormatReg gFormatReg(get_format_pkm); 128 static SkImageDecoder_FormatReg gFormatReg(get_format_pkm);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libico.cpp ('k') | src/ports/SkImageDecoder_CG.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698