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

Side by Side Diff: tests/ReadWriteAlphaTest.cpp

Issue 1966013002: Turn ContextInfos returned by GrContextFactory into structs. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Address comment Created 4 years, 7 months 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 | « tests/ReadPixelsTest.cpp ('k') | tests/RecordReplaceDrawTest.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 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 "Test.h" 8 #include "Test.h"
9 9
10 // This test is specific to the GPU backend. 10 // This test is specific to the GPU backend.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // let Skia know we will be using this texture as a render target 46 // let Skia know we will be using this texture as a render target
47 desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlag s; 47 desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlag s;
48 // it is a single channel texture 48 // it is a single channel texture
49 desc.fConfig = kAlpha_8_GrPixelConfig; 49 desc.fConfig = kAlpha_8_GrPixelConfig;
50 desc.fWidth = X_SIZE; 50 desc.fWidth = X_SIZE;
51 desc.fHeight = Y_SIZE; 51 desc.fHeight = Y_SIZE;
52 52
53 // We are initializing the texture with zeros here 53 // We are initializing the texture with zeros here
54 memset(alphaData, 0, X_SIZE * Y_SIZE); 54 memset(alphaData, 0, X_SIZE * Y_SIZE);
55 SkAutoTUnref<GrTexture> texture( 55 SkAutoTUnref<GrTexture> texture(
56 ctxInfo.fGrContext->textureProvider()->createTexture(desc, SkBudgete d::kNo , alphaData, 56 ctxInfo.grContext()->textureProvider()->createTexture(desc, SkBudget ed::kNo, alphaData,
57 0)); 57 0));
58 if (!texture) { 58 if (!texture) {
59 if (!rt) { 59 if (!rt) {
60 ERRORF(reporter, "Could not create alpha texture."); 60 ERRORF(reporter, "Could not create alpha texture.");
61 } 61 }
62 continue; 62 continue;
63 } 63 }
64 64
65 // create a distinctive texture 65 // create a distinctive texture
66 for (int y = 0; y < Y_SIZE; ++y) { 66 for (int y = 0; y < Y_SIZE; ++y) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 desc.fHeight = Y_SIZE; 148 desc.fHeight = Y_SIZE;
149 149
150 uint32_t rgbaData[X_SIZE * Y_SIZE]; 150 uint32_t rgbaData[X_SIZE * Y_SIZE];
151 // Make the alpha channel of the rgba texture come from alphaData. 151 // Make the alpha channel of the rgba texture come from alphaData.
152 for (int y = 0; y < Y_SIZE; ++y) { 152 for (int y = 0; y < Y_SIZE; ++y) {
153 for (int x = 0; x < X_SIZE; ++x) { 153 for (int x = 0; x < X_SIZE; ++x) {
154 rgbaData[y * X_SIZE + x] = GrColorPackRGBA(6, 7, 8, alphaDat a[y * X_SIZE + x]); 154 rgbaData[y * X_SIZE + x] = GrColorPackRGBA(6, 7, 8, alphaDat a[y * X_SIZE + x]);
155 } 155 }
156 } 156 }
157 SkAutoTUnref<GrTexture> texture( 157 SkAutoTUnref<GrTexture> texture(
158 ctxInfo.fGrContext->textureProvider()->createTexture(desc, SkBud geted::kNo, 158 ctxInfo.grContext()->textureProvider()->createTexture(desc, SkBu dgeted::kNo,
159 rgbaData, 0 )); 159 rgbaData, 0));
160 if (!texture) { 160 if (!texture) {
161 // We always expect to be able to create a RGBA texture 161 // We always expect to be able to create a RGBA texture
162 if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) { 162 if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) {
163 ERRORF(reporter, "Failed to create RGBA texture."); 163 ERRORF(reporter, "Failed to create RGBA texture.");
164 } 164 }
165 continue; 165 continue;
166 } 166 }
167 167
168 for (auto rowBytes : kRowBytes) { 168 for (auto rowBytes : kRowBytes) {
169 size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE; 169 size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE;
(...skipping 12 matching lines...) Expand all
182 SkString msg; 182 SkString msg;
183 msg.printf("rt:%d, rb:%d 8888", rt, SkToU32(rowBytes)); 183 msg.printf("rt:%d, rb:%d 8888", rt, SkToU32(rowBytes));
184 validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), no nZeroRowBytes, 184 validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), no nZeroRowBytes,
185 alphaData, msg); 185 alphaData, msg);
186 } 186 }
187 } 187 }
188 } 188 }
189 } 189 }
190 190
191 #endif 191 #endif
OLDNEW
« no previous file with comments | « tests/ReadPixelsTest.cpp ('k') | tests/RecordReplaceDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698