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

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

Issue 670453002: Remove image decoder and encoder autoregistration (Closed) Base URL: https://skia.googlesource.com/skia.git@separate-image-decoder-01-skpicture
Patch Set: Created 6 years, 1 month 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_pkm.h ('k') | src/images/SkImageDecoder_wbmp.h » ('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 #include "SkImageDecoder_pkm.h"
8 #include "SkColorPriv.h" 8 #include "SkColorPriv.h"
9 #include "SkImageDecoder.h"
10 #include "SkScaledBitmapSampler.h" 9 #include "SkScaledBitmapSampler.h"
11 #include "SkStream.h" 10 #include "SkStream.h"
12 #include "SkStreamPriv.h" 11 #include "SkStreamPriv.h"
13 #include "SkTextureCompressor.h" 12 #include "SkTextureCompressor.h"
14 #include "SkTypes.h" 13 #include "SkTypes.h"
15 14
16 #include "etc1.h" 15 #include "etc1.h"
17 16
18 class SkPKMImageDecoder : public SkImageDecoder { 17 class SkPKMImageDecoder : public SkImageDecoder {
19 public: 18 public:
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 const uint8_t *srcRow = reinterpret_cast<uint8_t *>(outRGBDataPtr); 94 const uint8_t *srcRow = reinterpret_cast<uint8_t *>(outRGBDataPtr);
96 srcRow += sampler.srcY0() * srcRowBytes; 95 srcRow += sampler.srcY0() * srcRowBytes;
97 for (int y = 0; y < dstHeight; ++y) { 96 for (int y = 0; y < dstHeight; ++y) {
98 sampler.next(srcRow); 97 sampler.next(srcRow);
99 srcRow += sampler.srcDY() * srcRowBytes; 98 srcRow += sampler.srcDY() * srcRowBytes;
100 } 99 }
101 100
102 return kSuccess; 101 return kSuccess;
103 } 102 }
104 103
105 //////////////////////////////////////////////////////////////////////////////// ///////// 104 SkImageDecoder::Format SkDetectFormatPKMImageDecoder(SkStreamRewindable* stream) {
106 DEFINE_DECODER_CREATOR(PKMImageDecoder);
107 //////////////////////////////////////////////////////////////////////////////// /////////
108
109 static bool is_pkm(SkStreamRewindable* stream) {
110 // Read the PKM header and make sure it's valid.
111 unsigned char buf[ETC_PKM_HEADER_SIZE]; 105 unsigned char buf[ETC_PKM_HEADER_SIZE];
112 if (stream->read((void*)buf, ETC_PKM_HEADER_SIZE) != ETC_PKM_HEADER_SIZE) { 106 if (stream->read((void*)buf, ETC_PKM_HEADER_SIZE) != ETC_PKM_HEADER_SIZE ||
113 return false; 107 !etc1_pkm_is_valid(buf)) {
108 return SkImageDecoder::kUnknown_Format;
114 } 109 }
115 110 return SkImageDecoder::kPKM_Format;
116 return SkToBool(etc1_pkm_is_valid(buf));
117 } 111 }
118 112
119 static SkImageDecoder* sk_libpkm_dfactory(SkStreamRewindable* stream) { 113 SkImageDecoder* SkCreatePKMImageDecoder(SkImageDecoder::Format format) {
120 if (is_pkm(stream)) { 114 SkASSERT(SkImageDecoder::kPKM_Format == format);
121 return SkNEW(SkPKMImageDecoder); 115 return SkNEW(SkPKMImageDecoder);
122 }
123 return NULL;
124 } 116 }
125 117
126 static SkImageDecoder_DecodeReg gReg(sk_libpkm_dfactory);
127
128 static SkImageDecoder::Format get_format_pkm(SkStreamRewindable* stream) {
129 if (is_pkm(stream)) {
130 return SkImageDecoder::kPKM_Format;
131 }
132 return SkImageDecoder::kUnknown_Format;
133 }
134
135 static SkImageDecoder_FormatReg gFormatReg(get_format_pkm);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_pkm.h ('k') | src/images/SkImageDecoder_wbmp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698