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

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

Issue 1168943002: Remove ContextProvider::IsContextLost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: contextprovider: . Created 5 years, 6 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_gles2_interface.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 <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 context_thread_checker_.CalledOnValidThread()); 48 context_thread_checker_.CalledOnValidThread());
49 } 49 }
50 50
51 bool TestContextProvider::BindToCurrentThread() { 51 bool TestContextProvider::BindToCurrentThread() {
52 // This is called on the thread the context will be used. 52 // This is called on the thread the context will be used.
53 DCHECK(context_thread_checker_.CalledOnValidThread()); 53 DCHECK(context_thread_checker_.CalledOnValidThread());
54 54
55 if (bound_) 55 if (bound_)
56 return true; 56 return true;
57 57
58 if (context3d_->isContextLost()) { 58 if (context_gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {
59 base::AutoLock lock(destroyed_lock_); 59 base::AutoLock lock(destroyed_lock_);
60 destroyed_ = true; 60 destroyed_ = true;
61 return false; 61 return false;
62 } 62 }
63 bound_ = true; 63 bound_ = true;
64 64
65 context3d_->set_context_lost_callback( 65 context3d_->set_context_lost_callback(
66 base::Bind(&TestContextProvider::OnLostContext, 66 base::Bind(&TestContextProvider::OnLostContext,
67 base::Unretained(this))); 67 base::Unretained(this)));
68 68
(...skipping 30 matching lines...) Expand all
99 if (gr_context_) 99 if (gr_context_)
100 return gr_context_.get(); 100 return gr_context_.get();
101 101
102 skia::RefPtr<class SkGLContext> gl_context = 102 skia::RefPtr<class SkGLContext> gl_context =
103 skia::AdoptRef(SkNullGLContext::Create(kNone_GrGLStandard)); 103 skia::AdoptRef(SkNullGLContext::Create(kNone_GrGLStandard));
104 gl_context->makeCurrent(); 104 gl_context->makeCurrent();
105 gr_context_ = skia::AdoptRef(GrContext::Create( 105 gr_context_ = skia::AdoptRef(GrContext::Create(
106 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(gl_context->gl()))); 106 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(gl_context->gl())));
107 107
108 // If GlContext is already lost, also abandon the new GrContext. 108 // If GlContext is already lost, also abandon the new GrContext.
109 if (IsContextLost()) 109 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR)
110 gr_context_->abandonContext(); 110 gr_context_->abandonContext();
111 111
112 return gr_context_.get(); 112 return gr_context_.get();
113 } 113 }
114 114
115 void TestContextProvider::InvalidateGrContext(uint32_t state) { 115 void TestContextProvider::InvalidateGrContext(uint32_t state) {
116 DCHECK(bound_); 116 DCHECK(bound_);
117 DCHECK(context_thread_checker_.CalledOnValidThread()); 117 DCHECK(context_thread_checker_.CalledOnValidThread());
118 118
119 if (gr_context_) 119 if (gr_context_)
120 gr_context_.get()->resetContext(state); 120 gr_context_.get()->resetContext(state);
121 } 121 }
122 122
123 void TestContextProvider::SetupLock() { 123 void TestContextProvider::SetupLock() {
124 } 124 }
125 125
126 base::Lock* TestContextProvider::GetLock() { 126 base::Lock* TestContextProvider::GetLock() {
127 return &context_lock_; 127 return &context_lock_;
128 } 128 }
129 129
130 bool TestContextProvider::IsContextLost() {
131 DCHECK(bound_);
132 DCHECK(context_thread_checker_.CalledOnValidThread());
133
134 return context3d_->isContextLost();
135 }
136
137 void TestContextProvider::VerifyContexts() { 130 void TestContextProvider::VerifyContexts() {
138 DCHECK(bound_); 131 DCHECK(bound_);
139 DCHECK(context_thread_checker_.CalledOnValidThread()); 132 DCHECK(context_thread_checker_.CalledOnValidThread());
140 133
141 if (context3d_->isContextLost()) { 134 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {
142 base::AutoLock lock(destroyed_lock_); 135 base::AutoLock lock(destroyed_lock_);
143 destroyed_ = true; 136 destroyed_ = true;
144 } 137 }
145 } 138 }
146 139
147 void TestContextProvider::DeleteCachedResources() { 140 void TestContextProvider::DeleteCachedResources() {
148 } 141 }
149 142
150 bool TestContextProvider::DestroyedOnMainThread() { 143 bool TestContextProvider::DestroyedOnMainThread() {
151 DCHECK(main_thread_checker_.CalledOnValidThread()); 144 DCHECK(main_thread_checker_.CalledOnValidThread());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null()); 192 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null());
200 memory_policy_changed_callback_ = cb; 193 memory_policy_changed_callback_ = cb;
201 } 194 }
202 195
203 void TestContextProvider::SetMaxTransferBufferUsageBytes( 196 void TestContextProvider::SetMaxTransferBufferUsageBytes(
204 size_t max_transfer_buffer_usage_bytes) { 197 size_t max_transfer_buffer_usage_bytes) {
205 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); 198 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes);
206 } 199 }
207 200
208 } // namespace cc 201 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_context_provider.h ('k') | cc/test/test_gles2_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698