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

Side by Side Diff: tests/GpuLayerCacheTest.cpp

Issue 1860593002: One signature for creating unit tests that run on premade GrContexts (Closed) Base URL: https://skia.googlesource.com/skia.git@try_no_native
Patch Set: another guess to fix windows Created 4 years, 8 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/GpuDrawPathTest.cpp ('k') | tests/GrContextAbandonTest.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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 cache->addUse(layer); 101 cache->addUse(layer);
102 102
103 REPORTER_ASSERT(reporter, 1 == TestingAccess::Uses(layer)); 103 REPORTER_ASSERT(reporter, 1 == TestingAccess::Uses(layer));
104 } 104 }
105 105
106 // This test case exercises the public API of the GrLayerCache class. 106 // This test case exercises the public API of the GrLayerCache class.
107 // In particular it checks its interaction with the resource cache (w.r.t. 107 // In particular it checks its interaction with the resource cache (w.r.t.
108 // locking & unlocking textures). 108 // locking & unlocking textures).
109 // TODO: need to add checks on VRAM usage! 109 // TODO: need to add checks on VRAM usage!
110 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GpuLayerCache, reporter, context) { 110 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GpuLayerCache, reporter, ctxInfo) {
111 // Add one more layer than can fit in the atlas 111 // Add one more layer than can fit in the atlas
112 static const int kInitialNumLayers = TestingAccess::NumPlots() + 1; 112 static const int kInitialNumLayers = TestingAccess::NumPlots() + 1;
113 113
114 #if GR_CACHE_STATS 114 #if GR_CACHE_STATS
115 GrResourceCache::Stats stats; 115 GrResourceCache::Stats stats;
116 #endif 116 #endif
117 117
118 sk_sp<SkPicture> picture; 118 sk_sp<SkPicture> picture;
119 119
120 { 120 {
121 SkPictureRecorder recorder; 121 SkPictureRecorder recorder;
122 SkCanvas* c = recorder.beginRecording(1, 1); 122 SkCanvas* c = recorder.beginRecording(1, 1);
123 // Draw something, anything, to prevent an empty-picture optimization, 123 // Draw something, anything, to prevent an empty-picture optimization,
124 // which is a singleton and never purged. 124 // which is a singleton and never purged.
125 c->drawRect(SkRect::MakeWH(1,1), SkPaint()); 125 c->drawRect(SkRect::MakeWH(1,1), SkPaint());
126 picture = recorder.finishRecordingAsPicture(); 126 picture = recorder.finishRecordingAsPicture();
127 } 127 }
128 128
129 GrResourceCache* resourceCache = context->getResourceCache(); 129 GrResourceCache* resourceCache = ctxInfo.fGrContext->getResourceCache();
130 130
131 GrLayerCache cache(context); 131 GrLayerCache cache(ctxInfo.fGrContext);
132 132
133 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); 133 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0);
134 134
135 for (int i = 0; i < kInitialNumLayers; ++i) { 135 for (int i = 0; i < kInitialNumLayers; ++i) {
136 int key[1] = { i + 1 }; 136 int key[1] = { i + 1 };
137 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(), 137 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(),
138 key, 1); 138 key, 1);
139 REPORTER_ASSERT(reporter, layer); 139 REPORTER_ASSERT(reporter, layer);
140 140
141 lock_layer(reporter, &cache, layer); 141 lock_layer(reporter, &cache, layer);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 cache.end(); 360 cache.end();
361 361
362 #if GR_CACHE_STATS 362 #if GR_CACHE_STATS
363 resourceCache->getStats(&stats); 363 resourceCache->getStats(&stats);
364 REPORTER_ASSERT(reporter, 2 == stats.fTotal); 364 REPORTER_ASSERT(reporter, 2 == stats.fTotal);
365 REPORTER_ASSERT(reporter, 2 == stats.fNumPurgeable); 365 REPORTER_ASSERT(reporter, 2 == stats.fNumPurgeable);
366 #endif 366 #endif
367 } 367 }
368 368
369 #endif 369 #endif
OLDNEW
« no previous file with comments | « tests/GpuDrawPathTest.cpp ('k') | tests/GrContextAbandonTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698