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

Side by Side Diff: tests/ReadWriteAlphaTest.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine 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/ResourceCacheTest.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.
11 #if SK_SUPPORT_GPU && !defined(SK_BUILD_FOR_ANDROID) 11 #if SK_SUPPORT_GPU && !defined(SK_BUILD_FOR_ANDROID)
12 12
13 #include "GrContextFactory.h" 13 #include "GrContextFactory.h"
14 #include "SkGpuDevice.h" 14 #include "SkGpuDevice.h"
15 15
16 static const int X_SIZE = 12; 16 static const int X_SIZE = 12;
17 static const int Y_SIZE = 12; 17 static const int Y_SIZE = 12;
18 18
19 #if 0
19 DEF_GPUTEST(ReadWriteAlpha, reporter, factory) { 20 DEF_GPUTEST(ReadWriteAlpha, reporter, factory) {
20 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { 21 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
21 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); 22 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type);
22 if (!GrContextFactory::IsRenderingGLContext(glType)) { 23 if (!GrContextFactory::IsRenderingGLContext(glType)) {
23 continue; 24 continue;
24 } 25 }
25 GrContext* context = factory->get(glType); 26 GrContext* context = factory->get(glType);
26 if (nullptr == context) { 27 if (nullptr == context) {
27 continue; 28 continue;
28 } 29 }
(...skipping 10 matching lines...) Expand all
39 desc.fConfig = kAlpha_8_GrPixelConfig; 40 desc.fConfig = kAlpha_8_GrPixelConfig;
40 desc.fWidth = X_SIZE; 41 desc.fWidth = X_SIZE;
41 desc.fHeight = Y_SIZE; 42 desc.fHeight = Y_SIZE;
42 43
43 // We are initializing the texture with zeros here 44 // We are initializing the texture with zeros here
44 GrTexture* texture = context->textureProvider()->createTexture(desc, fal se, textureData, 0); 45 GrTexture* texture = context->textureProvider()->createTexture(desc, fal se, textureData, 0);
45 if (!texture) { 46 if (!texture) {
46 return; 47 return;
47 } 48 }
48 49
50 // TODO: this should be okay
51 texture->setFromRawPixels(false);
52
49 SkAutoTUnref<GrTexture> au(texture); 53 SkAutoTUnref<GrTexture> au(texture);
50 54
55 SkAutoTUnref<GrDrawContext> dc(context->drawContext(texture->asRenderTar get()));
56 if (!dc) {
57 return;
58 }
59
51 // create a distinctive texture 60 // create a distinctive texture
52 for (int y = 0; y < Y_SIZE; ++y) { 61 for (int y = 0; y < Y_SIZE; ++y) {
53 for (int x = 0; x < X_SIZE; ++x) { 62 for (int x = 0; x < X_SIZE; ++x) {
54 textureData[x][y] = x*Y_SIZE+y; 63 textureData[x][y] = x*Y_SIZE+y;
55 } 64 }
56 } 65 }
57 66
58 // upload the texture 67 // upload the texture
59 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, 68 texture->writePixels(dc, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
60 textureData, 0); 69 textureData, 0);
61 70
62 unsigned char readback[X_SIZE][Y_SIZE]; 71 unsigned char readback[X_SIZE][Y_SIZE];
63 72
64 // clear readback to something non-zero so we can detect readback failur es 73 // clear readback to something non-zero so we can detect readback failur es
65 memset(readback, 0x1, X_SIZE * Y_SIZE); 74 memset(readback, 0x1, X_SIZE * Y_SIZE);
66 75
67 // read the texture back 76 // read the texture back
68 texture->readPixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, 77 texture->readPixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
69 readback, 0); 78 readback, 0);
70 79
71 // make sure the original & read back versions match 80 // make sure the original & read back versions match
72 bool match = true; 81 bool match = true;
73 82
74 for (int y = 0; y < Y_SIZE; ++y) { 83 for (int y = 0; y < Y_SIZE; ++y) {
75 for (int x = 0; x < X_SIZE; ++x) { 84 for (int x = 0; x < X_SIZE; ++x) {
76 if (textureData[x][y] != readback[x][y]) { 85 if (textureData[x][y] != readback[x][y]) {
77 match = false; 86 match = false;
78 } 87 }
79 } 88 }
80 } 89 }
81 90
91 // What on earth is this doing?
92 texture->setFromRawPixels(false);
93 texture->setDC1(NULL);
94 texture->setDT(NULL);
95
82 REPORTER_ASSERT(reporter, match); 96 REPORTER_ASSERT(reporter, match);
83 97
84 // Now try writing on the single channel texture 98 // Now try writing on the single channel texture
85 SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); 99 SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
86 SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(texture->asRenderT arget(), &props, 100 SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(texture->asRenderT arget(), &props,
87 SkGpuDevice::kUnin it_InitContents)); 101 SkGpuDevice::kUnin it_InitContents));
88 SkCanvas canvas(device); 102 SkCanvas canvas(device);
89 103
90 SkPaint paint; 104 SkPaint paint;
91 105
(...skipping 12 matching lines...) Expand all
104 for (int x = 0; x < X_SIZE; ++x) { 118 for (int x = 0; x < X_SIZE; ++x) {
105 if (0xFF != readback[x][y]) { 119 if (0xFF != readback[x][y]) {
106 match = false; 120 match = false;
107 } 121 }
108 } 122 }
109 } 123 }
110 124
111 REPORTER_ASSERT(reporter, match); 125 REPORTER_ASSERT(reporter, match);
112 } 126 }
113 } 127 }
128 #endif
114 129
115 #endif 130 #endif
OLDNEW
« no previous file with comments | « tests/ReadPixelsTest.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698