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

Side by Side Diff: cc/test/test_context_provider.cc

Issue 2278283003: Refactor client visibility handling (Closed)
Patch Set: more fixes Created 4 years, 3 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 | « cc/test/test_context_provider.h ('k') | cc/test/test_context_support.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/test/test_context_provider.h" 5 #include "cc/test/test_context_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback_helpers.h" 14 #include "base/callback_helpers.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "cc/output/context_cache_controller.h"
17 #include "cc/test/test_gles2_interface.h" 18 #include "cc/test/test_gles2_interface.h"
18 #include "cc/test/test_web_graphics_context_3d.h" 19 #include "cc/test/test_web_graphics_context_3d.h"
19 #include "third_party/skia/include/gpu/GrContext.h" 20 #include "third_party/skia/include/gpu/GrContext.h"
20 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" 21 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
21 22
22 namespace cc { 23 namespace cc {
23 24
24 // static 25 // static
25 scoped_refptr<TestContextProvider> TestContextProvider::Create() { 26 scoped_refptr<TestContextProvider> TestContextProvider::Create() {
26 return new TestContextProvider(base::MakeUnique<TestContextSupport>(), 27 return new TestContextProvider(base::MakeUnique<TestContextSupport>(),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 : support_(std::move(support)), 77 : support_(std::move(support)),
77 context3d_(std::move(context)), 78 context3d_(std::move(context)),
78 context_gl_(std::move(gl)), 79 context_gl_(std::move(gl)),
79 weak_ptr_factory_(this) { 80 weak_ptr_factory_(this) {
80 DCHECK(main_thread_checker_.CalledOnValidThread()); 81 DCHECK(main_thread_checker_.CalledOnValidThread());
81 DCHECK(context3d_); 82 DCHECK(context3d_);
82 DCHECK(context_gl_); 83 DCHECK(context_gl_);
83 context_thread_checker_.DetachFromThread(); 84 context_thread_checker_.DetachFromThread();
84 context_gl_->set_test_context(context3d_.get()); 85 context_gl_->set_test_context(context3d_.get());
85 context3d_->set_test_support(support_.get()); 86 context3d_->set_test_support(support_.get());
87 cache_controller_.reset(new ContextCacheController(support_.get()));
86 } 88 }
87 89
88 TestContextProvider::~TestContextProvider() { 90 TestContextProvider::~TestContextProvider() {
89 DCHECK(main_thread_checker_.CalledOnValidThread() || 91 DCHECK(main_thread_checker_.CalledOnValidThread() ||
90 context_thread_checker_.CalledOnValidThread()); 92 context_thread_checker_.CalledOnValidThread());
91 } 93 }
92 94
93 bool TestContextProvider::BindToCurrentThread() { 95 bool TestContextProvider::BindToCurrentThread() {
94 // This is called on the thread the context will be used. 96 // This is called on the thread the context will be used.
95 DCHECK(context_thread_checker_.CalledOnValidThread()); 97 DCHECK(context_thread_checker_.CalledOnValidThread());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 DCHECK(context_thread_checker_.CalledOnValidThread()); 138 DCHECK(context_thread_checker_.CalledOnValidThread());
137 139
138 if (gr_context_) 140 if (gr_context_)
139 return gr_context_.get(); 141 return gr_context_.get();
140 142
141 sk_sp<const GrGLInterface> gl_interface(GrGLCreateNullInterface()); 143 sk_sp<const GrGLInterface> gl_interface(GrGLCreateNullInterface());
142 gr_context_ = sk_sp<::GrContext>(GrContext::Create( 144 gr_context_ = sk_sp<::GrContext>(GrContext::Create(
143 kOpenGL_GrBackend, 145 kOpenGL_GrBackend,
144 reinterpret_cast<GrBackendContext>(gl_interface.get()))); 146 reinterpret_cast<GrBackendContext>(gl_interface.get())));
145 147
148 cache_controller_->SetGrContext(gr_context_.get());
149
146 // If GlContext is already lost, also abandon the new GrContext. 150 // If GlContext is already lost, also abandon the new GrContext.
147 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) 151 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR)
148 gr_context_->abandonContext(); 152 gr_context_->abandonContext();
149 153
150 return gr_context_.get(); 154 return gr_context_.get();
151 } 155 }
152 156
157 ContextCacheController* TestContextProvider::CacheController() {
158 DCHECK(context_thread_checker_.CalledOnValidThread());
159 return cache_controller_.get();
160 }
161
153 void TestContextProvider::InvalidateGrContext(uint32_t state) { 162 void TestContextProvider::InvalidateGrContext(uint32_t state) {
154 DCHECK(bound_); 163 DCHECK(bound_);
155 DCHECK(context_thread_checker_.CalledOnValidThread()); 164 DCHECK(context_thread_checker_.CalledOnValidThread());
156 165
157 if (gr_context_) 166 if (gr_context_)
158 gr_context_.get()->resetContext(state); 167 gr_context_.get()->resetContext(state);
159 } 168 }
160 169
161 base::Lock* TestContextProvider::GetLock() { 170 base::Lock* TestContextProvider::GetLock() {
162 return &context_lock_; 171 return &context_lock_;
163 } 172 }
164 173
165 void TestContextProvider::DeleteCachedResources() {
166 }
167
168 void TestContextProvider::OnLostContext() { 174 void TestContextProvider::OnLostContext() {
169 DCHECK(context_thread_checker_.CalledOnValidThread()); 175 DCHECK(context_thread_checker_.CalledOnValidThread());
170 if (!lost_context_callback_.is_null()) 176 if (!lost_context_callback_.is_null())
171 lost_context_callback_.Run(); 177 lost_context_callback_.Run();
172 if (gr_context_) 178 if (gr_context_)
173 gr_context_->abandonContext(); 179 gr_context_->abandonContext();
174 } 180 }
175 181
176 TestWebGraphicsContext3D* TestContextProvider::TestContext3d() { 182 TestWebGraphicsContext3D* TestContextProvider::TestContext3d() {
177 DCHECK(bound_); 183 DCHECK(bound_);
178 DCHECK(context_thread_checker_.CalledOnValidThread()); 184 DCHECK(context_thread_checker_.CalledOnValidThread());
179 185
180 return context3d_.get(); 186 return context3d_.get();
181 } 187 }
182 188
183 TestWebGraphicsContext3D* TestContextProvider::UnboundTestContext3d() { 189 TestWebGraphicsContext3D* TestContextProvider::UnboundTestContext3d() {
184 return context3d_.get(); 190 return context3d_.get();
185 } 191 }
186 192
187 void TestContextProvider::SetLostContextCallback( 193 void TestContextProvider::SetLostContextCallback(
188 const LostContextCallback& cb) { 194 const LostContextCallback& cb) {
189 DCHECK(context_thread_checker_.CalledOnValidThread()); 195 DCHECK(context_thread_checker_.CalledOnValidThread());
190 DCHECK(lost_context_callback_.is_null() || cb.is_null()); 196 DCHECK(lost_context_callback_.is_null() || cb.is_null());
191 lost_context_callback_ = cb; 197 lost_context_callback_ = cb;
192 } 198 }
193 199
194 } // namespace cc 200 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_context_provider.h ('k') | cc/test/test_context_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698