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

Side by Side Diff: src/codec/SkIcoCodec.cpp

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkBmpCodec.h" 8 #include "SkBmpCodec.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 // If we cannot skip, assume we have reached the end of the stream and 122 // If we cannot skip, assume we have reached the end of the stream and
123 // stop trying to make codecs 123 // stop trying to make codecs
124 if (inputStream.get()->skip(offset - bytesRead) != offset - bytesRead) { 124 if (inputStream.get()->skip(offset - bytesRead) != offset - bytesRead) {
125 SkCodecPrintf("Warning: could not skip to ico offset.\n"); 125 SkCodecPrintf("Warning: could not skip to ico offset.\n");
126 break; 126 break;
127 } 127 }
128 bytesRead = offset; 128 bytesRead = offset;
129 129
130 // Create a new stream for the embedded codec 130 // Create a new stream for the embedded codec
131 SkAutoTUnref<SkData> data( 131 sk_sp<SkData> data(SkData::MakeFromStream(inputStream.get(), size));
132 SkData::NewFromStream(inputStream.get(), size));
133 if (nullptr == data.get()) { 132 if (nullptr == data.get()) {
134 SkCodecPrintf("Warning: could not create embedded stream.\n"); 133 SkCodecPrintf("Warning: could not create embedded stream.\n");
135 break; 134 break;
136 } 135 }
137 SkAutoTDelete<SkMemoryStream> embeddedStream(new SkMemoryStream(data.get ())); 136 SkAutoTDelete<SkMemoryStream> embeddedStream(new SkMemoryStream(data));
138 bytesRead += size; 137 bytesRead += size;
139 138
140 // Check if the embedded codec is bmp or png and create the codec 139 // Check if the embedded codec is bmp or png and create the codec
141 SkCodec* codec = nullptr; 140 SkCodec* codec = nullptr;
142 if (SkPngCodec::IsPng((const char*) data->bytes(), data->size())) { 141 if (SkPngCodec::IsPng((const char*) data->bytes(), data->size())) {
143 codec = SkPngCodec::NewFromStream(embeddedStream.release()); 142 codec = SkPngCodec::NewFromStream(embeddedStream.release());
144 } else { 143 } else {
145 codec = SkBmpCodec::NewFromIco(embeddedStream.release()); 144 codec = SkBmpCodec::NewFromIco(embeddedStream.release());
146 } 145 }
147 146
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 SkCodec::SkScanlineOrder SkIcoCodec::onGetScanlineOrder() const { 311 SkCodec::SkScanlineOrder SkIcoCodec::onGetScanlineOrder() const {
313 // FIXME: This function will possibly return the wrong value if it is called 312 // FIXME: This function will possibly return the wrong value if it is called
314 // before startScanlineDecode(). 313 // before startScanlineDecode().
315 return fCurrScanlineCodec ? fCurrScanlineCodec->getScanlineOrder() : 314 return fCurrScanlineCodec ? fCurrScanlineCodec->getScanlineOrder() :
316 INHERITED::onGetScanlineOrder(); 315 INHERITED::onGetScanlineOrder();
317 } 316 }
318 317
319 SkSampler* SkIcoCodec::getSampler(bool createIfNecessary) { 318 SkSampler* SkIcoCodec::getSampler(bool createIfNecessary) {
320 return fCurrScanlineCodec ? fCurrScanlineCodec->getSampler(createIfNecessary ) : nullptr; 319 return fCurrScanlineCodec ? fCurrScanlineCodec->getSampler(createIfNecessary ) : nullptr;
321 } 320 }
OLDNEW
« include/core/SkData.h ('K') | « samplecode/SampleLua.cpp ('k') | src/codec/SkRawCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698