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

Side by Side Diff: tests/GpuLayerCacheTest.cpp

Issue 398183002: Fix alpha textures in NV ES3 contexts on Windows (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: suppress warning Created 6 years, 5 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/GLProgramsTest.cpp ('k') | tests/GrContextFactoryTest.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 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 #if SK_SUPPORT_GPU 8 #if SK_SUPPORT_GPU
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 REPORTER_ASSERT(reporter, !layers[i]->isAtlased()); 42 REPORTER_ASSERT(reporter, !layers[i]->isAtlased());
43 } 43 }
44 44
45 } 45 }
46 46
47 // This test case exercises the public API of the GrLayerCache class. 47 // This test case exercises the public API of the GrLayerCache class.
48 // In particular it checks its interaction with the resource cache (w.r.t. 48 // In particular it checks its interaction with the resource cache (w.r.t.
49 // locking & unlocking textures). 49 // locking & unlocking textures).
50 // TODO: need to add checks on VRAM usage! 50 // TODO: need to add checks on VRAM usage!
51 DEF_GPUTEST(GpuLayerCache, reporter, factory) { 51 DEF_GPUTEST(GpuLayerCache, reporter, factory) {
52 for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
53 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext Type) i;
52 54
53 GrContext* context = factory->get(GrContextFactory::kNative_GLContextType); 55 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
54 if (NULL == context) { 56 continue;
55 return; 57 }
56 }
57 58
58 SkPictureRecorder recorder; 59 GrContext* context = factory->get(glCtxType);
59 recorder.beginRecording(1, 1);
60 SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
61 60
62 GrLayerCache cache(context); 61 if (NULL == context) {
62 continue;
63 }
63 64
64 create_layers(reporter, &cache, *picture); 65 SkPictureRecorder recorder;
66 recorder.beginRecording(1, 1);
67 SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
65 68
66 // Lock the layers making them all 512x512 69 GrLayerCache cache(context);
67 GrTextureDesc desc;
68 desc.fWidth = 512;
69 desc.fHeight = 512;
70 desc.fConfig = kSkia8888_GrPixelConfig;
71 70
72 for (int i = 0; i < kNumLayers; ++i) { 71 create_layers(reporter, &cache, *picture);
73 GrCachedLayer* layer = cache.findLayer(picture, i);
74 REPORTER_ASSERT(reporter, NULL != layer);
75 72
76 bool foundInCache = cache.lock(layer, desc); 73 // Lock the layers making them all 512x512
77 REPORTER_ASSERT(reporter, !foundInCache); 74 GrTextureDesc desc;
78 foundInCache = cache.lock(layer, desc); 75 desc.fWidth = 512;
79 REPORTER_ASSERT(reporter, foundInCache); 76 desc.fHeight = 512;
77 desc.fConfig = kSkia8888_GrPixelConfig;
80 78
81 REPORTER_ASSERT(reporter, NULL != layer->texture()); 79 for (int i = 0; i < kNumLayers; ++i) {
80 GrCachedLayer* layer = cache.findLayer(picture, i);
81 REPORTER_ASSERT(reporter, NULL != layer);
82
83 bool foundInCache = cache.lock(layer, desc);
84 REPORTER_ASSERT(reporter, !foundInCache);
85 foundInCache = cache.lock(layer, desc);
86 REPORTER_ASSERT(reporter, foundInCache);
87
88 REPORTER_ASSERT(reporter, NULL != layer->texture());
82 #if USE_ATLAS 89 #if USE_ATLAS
83 // The first 4 layers should be in the atlas (and thus have non-empty 90 // The first 4 layers should be in the atlas (and thus have non-empt y
84 // rects) 91 // rects)
85 if (i < 4) { 92 if (i < 4) {
86 REPORTER_ASSERT(reporter, layer->isAtlased()); 93 REPORTER_ASSERT(reporter, layer->isAtlased());
87 } else { 94 } else {
88 #endif 95 #endif
89 REPORTER_ASSERT(reporter, !layer->isAtlased()); 96 REPORTER_ASSERT(reporter, !layer->isAtlased());
90 #if USE_ATLAS 97 #if USE_ATLAS
98 }
99 #endif
91 } 100 }
101
102 // Unlock the textures
103 for (int i = 0; i < kNumLayers; ++i) {
104 GrCachedLayer* layer = cache.findLayer(picture, i);
105 REPORTER_ASSERT(reporter, NULL != layer);
106
107 cache.unlock(layer);
108 }
109
110 for (int i = 0; i < kNumLayers; ++i) {
111 GrCachedLayer* layer = cache.findLayer(picture, i);
112 REPORTER_ASSERT(reporter, NULL != layer);
113
114 #if USE_ATLAS
115 // The first 4 layers should be in the atlas (and thus do not
116 // currently unlock). The final layer should be unlocked.
117 if (i < 4) {
118 REPORTER_ASSERT(reporter, NULL != layer->texture());
119 REPORTER_ASSERT(reporter, layer->isAtlased());
120 } else {
121 #endif
122 REPORTER_ASSERT(reporter, NULL == layer->texture());
123 REPORTER_ASSERT(reporter, !layer->isAtlased());
124 #if USE_ATLAS
125 }
126 #endif
127 }
128
129 // Free them all SkGpuDevice-style. This will not free up the
130 // atlas' texture but will eliminate all the layers.
131 cache.purge(picture);
132
133 REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0);
134 // TODO: add VRAM/resource cache check here
135 #if 0
136 // Re-create the layers
137 create_layers(reporter, &cache, picture);
138
139 // Free them again GrContext-style. This should free up everything.
140 cache.freeAll();
141
142 REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0);
143 // TODO: add VRAM/resource cache check here
92 #endif 144 #endif
93 } 145 }
94
95 // Unlock the textures
96 for (int i = 0; i < kNumLayers; ++i) {
97 GrCachedLayer* layer = cache.findLayer(picture, i);
98 REPORTER_ASSERT(reporter, NULL != layer);
99
100 cache.unlock(layer);
101 }
102
103 for (int i = 0; i < kNumLayers; ++i) {
104 GrCachedLayer* layer = cache.findLayer(picture, i);
105 REPORTER_ASSERT(reporter, NULL != layer);
106
107 #if USE_ATLAS
108 // The first 4 layers should be in the atlas (and thus do not
109 // currently unlock). The final layer should be unlocked.
110 if (i < 4) {
111 REPORTER_ASSERT(reporter, NULL != layer->texture());
112 REPORTER_ASSERT(reporter, layer->isAtlased());
113 } else {
114 #endif
115 REPORTER_ASSERT(reporter, NULL == layer->texture());
116 REPORTER_ASSERT(reporter, !layer->isAtlased());
117 #if USE_ATLAS
118 }
119 #endif
120 }
121
122 // Free them all SkGpuDevice-style. This will not free up the
123 // atlas' texture but will eliminate all the layers.
124 cache.purge(picture);
125
126 REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0);
127 // TODO: add VRAM/resource cache check here
128 #if 0
129 // Re-create the layers
130 create_layers(reporter, &cache, picture);
131
132 // Free them again GrContext-style. This should free up everything.
133 cache.freeAll();
134
135 REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0);
136 // TODO: add VRAM/resource cache check here
137 #endif
138 } 146 }
139 147
140 #endif 148 #endif
OLDNEW
« no previous file with comments | « tests/GLProgramsTest.cpp ('k') | tests/GrContextFactoryTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698