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

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

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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/layer_tree_test.cc ('k') | cc/test/test_web_graphics_context_3d.cc » ('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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 DCHECK(context_thread_checker_.CalledOnValidThread()); 97 DCHECK(context_thread_checker_.CalledOnValidThread());
98 98
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
108 // If GlContext is already lost, also abandon the new GrContext.
109 if (IsContextLost())
110 gr_context_->abandonContext();
111
107 return gr_context_.get(); 112 return gr_context_.get();
108 } 113 }
109 114
110 void TestContextProvider::SetupLock() { 115 void TestContextProvider::SetupLock() {
111 } 116 }
112 117
113 base::Lock* TestContextProvider::GetLock() { 118 base::Lock* TestContextProvider::GetLock() {
114 return &context_lock_; 119 return &context_lock_;
115 } 120 }
116 121
(...skipping 27 matching lines...) Expand all
144 void TestContextProvider::OnLostContext() { 149 void TestContextProvider::OnLostContext() {
145 DCHECK(context_thread_checker_.CalledOnValidThread()); 150 DCHECK(context_thread_checker_.CalledOnValidThread());
146 { 151 {
147 base::AutoLock lock(destroyed_lock_); 152 base::AutoLock lock(destroyed_lock_);
148 if (destroyed_) 153 if (destroyed_)
149 return; 154 return;
150 destroyed_ = true; 155 destroyed_ = true;
151 } 156 }
152 if (!lost_context_callback_.is_null()) 157 if (!lost_context_callback_.is_null())
153 base::ResetAndReturn(&lost_context_callback_).Run(); 158 base::ResetAndReturn(&lost_context_callback_).Run();
159 if (gr_context_)
160 gr_context_->abandonContext();
154 } 161 }
155 162
156 TestWebGraphicsContext3D* TestContextProvider::TestContext3d() { 163 TestWebGraphicsContext3D* TestContextProvider::TestContext3d() {
157 DCHECK(bound_); 164 DCHECK(bound_);
158 DCHECK(context_thread_checker_.CalledOnValidThread()); 165 DCHECK(context_thread_checker_.CalledOnValidThread());
159 166
160 return context3d_.get(); 167 return context3d_.get();
161 } 168 }
162 169
163 TestWebGraphicsContext3D* TestContextProvider::UnboundTestContext3d() { 170 TestWebGraphicsContext3D* TestContextProvider::UnboundTestContext3d() {
(...skipping 20 matching lines...) Expand all
184 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null()); 191 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null());
185 memory_policy_changed_callback_ = cb; 192 memory_policy_changed_callback_ = cb;
186 } 193 }
187 194
188 void TestContextProvider::SetMaxTransferBufferUsageBytes( 195 void TestContextProvider::SetMaxTransferBufferUsageBytes(
189 size_t max_transfer_buffer_usage_bytes) { 196 size_t max_transfer_buffer_usage_bytes) {
190 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); 197 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes);
191 } 198 }
192 199
193 } // namespace cc 200 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.cc ('k') | cc/test/test_web_graphics_context_3d.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698