OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkShader.h" | 10 #include "SkShader.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 * Create a red & green stripes on black texture | 40 * Create a red & green stripes on black texture |
41 */ | 41 */ |
42 void createTexture() { | 42 void createTexture() { |
43 if (fTextureCreated) { | 43 if (fTextureCreated) { |
44 return; | 44 return; |
45 } | 45 } |
46 | 46 |
47 static const int xSize = 16; | 47 static const int xSize = 16; |
48 static const int ySize = 16; | 48 static const int ySize = 16; |
49 | 49 |
50 fTexture.setConfig(SkBitmap::kARGB_8888_Config, | 50 fTexture.allocN32Pixels(xSize, ySize); |
51 xSize, | |
52 ySize, | |
53 xSize*sizeof(SkColor)); | |
54 | |
55 fTexture.allocPixels(); | |
56 fTexture.lockPixels(); | |
57 SkPMColor* addr = fTexture.getAddr32(0, 0); | 51 SkPMColor* addr = fTexture.getAddr32(0, 0); |
58 | 52 |
59 for (int y = 0; y < ySize; ++y) { | 53 for (int y = 0; y < ySize; ++y) { |
60 for (int x = 0; x < xSize; ++x) { | 54 for (int x = 0; x < xSize; ++x) { |
61 addr[y*xSize+x] = SkPreMultiplyColor(SK_ColorBLACK); | 55 addr[y*xSize+x] = SkPreMultiplyColor(SK_ColorBLACK); |
62 | 56 |
63 if ((y % 5) == 0) { | 57 if ((y % 5) == 0) { |
64 addr[y*xSize+x] = SkPreMultiplyColor(SK_ColorRED); | 58 addr[y*xSize+x] = SkPreMultiplyColor(SK_ColorRED); |
65 } | 59 } |
66 if ((x % 7) == 0) { | 60 if ((x % 7) == 0) { |
67 addr[y*xSize+x] = SkPreMultiplyColor(SK_ColorGREEN); | 61 addr[y*xSize+x] = SkPreMultiplyColor(SK_ColorGREEN); |
68 } | 62 } |
69 } | 63 } |
70 } | 64 } |
71 | 65 |
72 fTexture.unlockPixels(); | |
73 | |
74 fTextureCreated = true; | 66 fTextureCreated = true; |
75 } | 67 } |
76 | 68 |
77 void createShader() { | 69 void createShader() { |
78 if (NULL != fShader.get()) { | 70 if (NULL != fShader.get()) { |
79 return; | 71 return; |
80 } | 72 } |
81 | 73 |
82 createTexture(); | 74 createTexture(); |
83 | 75 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 143 |
152 typedef GM INHERITED; | 144 typedef GM INHERITED; |
153 }; | 145 }; |
154 | 146 |
155 ////////////////////////////////////////////////////////////////////////////// | 147 ////////////////////////////////////////////////////////////////////////////// |
156 | 148 |
157 static GM* MyFactory(void*) { return new SamplerStressGM; } | 149 static GM* MyFactory(void*) { return new SamplerStressGM; } |
158 static GMRegistry reg(MyFactory); | 150 static GMRegistry reg(MyFactory); |
159 | 151 |
160 } | 152 } |
OLD | NEW |