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 "gm.h" | 8 #include "gm.h" |
9 #include "SkColorCubeFilter.h" | 9 #include "SkColorCubeFilter.h" |
10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 uint8_t* lut = (uint8_t*)lutMemory.get(); | 78 uint8_t* lut = (uint8_t*)lutMemory.get(); |
79 uint8_t* invLut = (uint8_t*)invLutMemory.get(); | 79 uint8_t* invLut = (uint8_t*)invLutMemory.get(); |
80 const int maxIndex = size - 1; | 80 const int maxIndex = size - 1; |
81 for (int i = 0; i < size; i++) { | 81 for (int i = 0; i < size; i++) { |
82 lut[i] = (i * 255) / maxIndex; | 82 lut[i] = (i * 255) / maxIndex; |
83 invLut[i] = ((maxIndex - i) * 255) / maxIndex; | 83 invLut[i] = ((maxIndex - i) * 255) / maxIndex; |
84 } | 84 } |
85 for (int r = 0; r < size; ++r) { | 85 for (int r = 0; r < size; ++r) { |
86 for (int g = 0; g < size; ++g) { | 86 for (int g = 0; g < size; ++g) { |
87 for (int b = 0; b < size; ++b) { | 87 for (int b = 0; b < size; ++b) { |
88 pixels[(size * ((size * b) + g)) + r] = SkColorSetARGB(0xFF, | 88 pixels[(size * ((size * b) + g)) + r] = sk_tool_utils::color
_to_565( |
| 89 SkColorSetARGB(0xFF, |
89 invR ? invLut[r] : lut[r], | 90 invR ? invLut[r] : lut[r], |
90 invG ? invLut[g] : lut[g], | 91 invG ? invLut[g] : lut[g], |
91 invB ? invLut[b] : lut[b]); | 92 invB ? invLut[b] : lut[b])); |
92 } | 93 } |
93 } | 94 } |
94 } | 95 } |
95 } | 96 } |
96 | 97 |
97 virtual SkISize onISize() { | 98 virtual SkISize onISize() { |
98 return SkISize::Make(500, 100); | 99 return SkISize::Make(500, 100); |
99 } | 100 } |
100 | 101 |
101 virtual void onDraw(SkCanvas* canvas) { | 102 virtual void onDraw(SkCanvas* canvas) { |
(...skipping 30 matching lines...) Expand all Loading... |
132 SkData* f3DLut32; | 133 SkData* f3DLut32; |
133 SkData* f3DLut64; | 134 SkData* f3DLut64; |
134 }; | 135 }; |
135 | 136 |
136 ////////////////////////////////////////////////////////////////////////////// | 137 ////////////////////////////////////////////////////////////////////////////// |
137 | 138 |
138 static GM* MyFactory(void*) { return new ColorCubeGM; } | 139 static GM* MyFactory(void*) { return new ColorCubeGM; } |
139 static GMRegistry reg(MyFactory); | 140 static GMRegistry reg(MyFactory); |
140 | 141 |
141 } | 142 } |
OLD | NEW |