OLD | NEW |
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 "SkScaledBitmapSampler.h" | 10 #include "SkScaledBitmapSampler.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // Setup the sampler... | 50 // Setup the sampler... |
51 SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); | 51 SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); |
52 | 52 |
53 // Set the config... | 53 // Set the config... |
54 bm->setInfo(SkImageInfo::MakeN32(sampler.scaledWidth(), sampler.scaledHeight
(), | 54 bm->setInfo(SkImageInfo::MakeN32(sampler.scaledWidth(), sampler.scaledHeight
(), |
55 kOpaque_SkAlphaType)); | 55 kOpaque_SkAlphaType)); |
56 if (SkImageDecoder::kDecodeBounds_Mode == mode) { | 56 if (SkImageDecoder::kDecodeBounds_Mode == mode) { |
57 return kSuccess; | 57 return kSuccess; |
58 } | 58 } |
59 | 59 |
60 if (!this->allocPixelRef(bm, NULL)) { | 60 if (!this->allocPixelRef(bm, nullptr)) { |
61 return kFailure; | 61 return kFailure; |
62 } | 62 } |
63 | 63 |
64 // Lock the pixels, since we're about to write to them... | 64 // Lock the pixels, since we're about to write to them... |
65 SkAutoLockPixels alp(*bm); | 65 SkAutoLockPixels alp(*bm); |
66 | 66 |
67 if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, *this)) { | 67 if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, *this)) { |
68 return kFailure; | 68 return kFailure; |
69 } | 69 } |
70 | 70 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 return false; | 106 return false; |
107 } | 107 } |
108 | 108 |
109 return SkToBool(etc1_pkm_is_valid(buf)); | 109 return SkToBool(etc1_pkm_is_valid(buf)); |
110 } | 110 } |
111 | 111 |
112 static SkImageDecoder* sk_libpkm_dfactory(SkStreamRewindable* stream) { | 112 static SkImageDecoder* sk_libpkm_dfactory(SkStreamRewindable* stream) { |
113 if (is_pkm(stream)) { | 113 if (is_pkm(stream)) { |
114 return new SkPKMImageDecoder; | 114 return new SkPKMImageDecoder; |
115 } | 115 } |
116 return NULL; | 116 return nullptr; |
117 } | 117 } |
118 | 118 |
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); |
OLD | NEW |