OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "SampleCode.h" | 7 #include "SampleCode.h" |
8 #include "SkAlphaThresholdFilter.h" | 8 #include "SkAlphaThresholdFilter.h" |
9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 make_checkerboard_bitmap(bitmap[1]); | 208 make_checkerboard_bitmap(bitmap[1]); |
209 initialized = true; | 209 initialized = true; |
210 } | 210 } |
211 return bitmap[R(2)]; | 211 return bitmap[R(2)]; |
212 } | 212 } |
213 | 213 |
214 static SkData* make_3Dlut(int* cubeDimension, bool invR, bool invG, bool invB) { | 214 static SkData* make_3Dlut(int* cubeDimension, bool invR, bool invG, bool invB) { |
215 int size = 4 << R(5); | 215 int size = 4 << R(5); |
216 SkData* data = SkData::NewUninitialized(sizeof(SkColor) * size * size * size ); | 216 SkData* data = SkData::NewUninitialized(sizeof(SkColor) * size * size * size ); |
217 SkColor* pixels = (SkColor*)(data->writable_data()); | 217 SkColor* pixels = (SkColor*)(data->writable_data()); |
218 SkAutoMalloc lutMemory(size); | 218 SkAutoTMalloc<uint8_t> lutMemory(size); |
scroggo
2015/12/10 16:26:45
This caused the build errors in patch set 1...
| |
219 SkAutoMalloc invLutMemory(size); | 219 SkAutoTMalloc<uint8_t> invLutMemory(size); |
220 uint8_t* lut = (uint8_t*)lutMemory.get(); | 220 uint8_t* lut = lutMemory.get(); |
221 uint8_t* invLut = (uint8_t*)invLutMemory.get(); | 221 uint8_t* invLut = invLutMemory.get(); |
222 const int maxIndex = size - 1; | 222 const int maxIndex = size - 1; |
223 for (int i = 0; i < size; i++) { | 223 for (int i = 0; i < size; i++) { |
224 lut[i] = (i * 255) / maxIndex; | 224 lut[i] = (i * 255) / maxIndex; |
225 invLut[i] = ((maxIndex - i) * 255) / maxIndex; | 225 invLut[i] = ((maxIndex - i) * 255) / maxIndex; |
226 } | 226 } |
227 for (int r = 0; r < size; ++r) { | 227 for (int r = 0; r < size; ++r) { |
228 for (int g = 0; g < size; ++g) { | 228 for (int g = 0; g < size; ++g) { |
229 for (int b = 0; b < size; ++b) { | 229 for (int b = 0; b < size; ++b) { |
230 pixels[(size * ((size * b) + g)) + r] = SkColorSetARGB(0xFF, | 230 pixels[(size * ((size * b) + g)) + r] = SkColorSetARGB(0xFF, |
231 invR ? invLut[r] : lut[r], | 231 invR ? invLut[r] : lut[r], |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 } | 517 } |
518 | 518 |
519 private: | 519 private: |
520 typedef SkView INHERITED; | 520 typedef SkView INHERITED; |
521 }; | 521 }; |
522 | 522 |
523 ////////////////////////////////////////////////////////////////////////////// | 523 ////////////////////////////////////////////////////////////////////////////// |
524 | 524 |
525 static SkView* MyFactory() { return new ImageFilterFuzzView; } | 525 static SkView* MyFactory() { return new ImageFilterFuzzView; } |
526 static SkViewRegister reg(MyFactory); | 526 static SkViewRegister reg(MyFactory); |
OLD | NEW |