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

Side by Side Diff: src/images/SkImageDecoder_astc.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/effects/SkColorCubeFilter.cpp ('k') | src/images/SkImageDecoder_ktx.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 "SkData.h" 8 #include "SkData.h"
9 #include "SkEndian.h" 9 #include "SkEndian.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 26 matching lines...) Expand all
37 37
38 static inline int read_24bit(const uint8_t* buf) { 38 static inline int read_24bit(const uint8_t* buf) {
39 // Assume everything is little endian... 39 // Assume everything is little endian...
40 return 40 return
41 static_cast<int>(buf[0]) | 41 static_cast<int>(buf[0]) |
42 (static_cast<int>(buf[1]) << 8) | 42 (static_cast<int>(buf[1]) << 8) |
43 (static_cast<int>(buf[2]) << 16); 43 (static_cast<int>(buf[2]) << 16);
44 } 44 }
45 45
46 SkImageDecoder::Result SkASTCImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { 46 SkImageDecoder::Result SkASTCImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
47 SkAutoTUnref<SkData> data(SkCopyStreamToData(stream)); 47 auto data = SkCopyStreamToData(stream);
48 if (!data || !data->size()) { 48 if (!data || !data->size()) {
49 return kFailure; 49 return kFailure;
50 } 50 }
51 51
52 unsigned char* buf = (unsigned char*) data->data(); 52 unsigned char* buf = (unsigned char*) data->data();
53 53
54 // Make sure that the magic header is there... 54 // Make sure that the magic header is there...
55 SkASSERT(SkEndian_SwapLE32(*(reinterpret_cast<uint32_t*>(buf))) == kASTCMagi cNumber); 55 SkASSERT(SkEndian_SwapLE32(*(reinterpret_cast<uint32_t*>(buf))) == kASTCMagi cNumber);
56 56
57 // Advance past the magic header 57 // Advance past the magic header
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 static SkImageDecoder_DecodeReg gReg(sk_libastc_dfactory); 194 static SkImageDecoder_DecodeReg gReg(sk_libastc_dfactory);
195 195
196 static SkImageDecoder::Format get_format_astc(SkStreamRewindable* stream) { 196 static SkImageDecoder::Format get_format_astc(SkStreamRewindable* stream) {
197 if (is_astc(stream)) { 197 if (is_astc(stream)) {
198 return SkImageDecoder::kASTC_Format; 198 return SkImageDecoder::kASTC_Format;
199 } 199 }
200 return SkImageDecoder::kUnknown_Format; 200 return SkImageDecoder::kUnknown_Format;
201 } 201 }
202 202
203 static SkImageDecoder_FormatReg gFormatReg(get_format_astc); 203 static SkImageDecoder_FormatReg gFormatReg(get_format_astc);
OLDNEW
« no previous file with comments | « src/effects/SkColorCubeFilter.cpp ('k') | src/images/SkImageDecoder_ktx.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698