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

Side by Side Diff: samplecode/SampleFilterFuzz.cpp

Issue 1516833003: Switch SkAutoMalloc to SkAutoTMalloc to avoid cast (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Go back to patch set 3 Created 5 years 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 | « samplecode/SampleApp.cpp ('k') | src/codec/SkCodec_libpng.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 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
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);
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
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);
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | src/codec/SkCodec_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698