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

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

Issue 916723002: cc: Add threaded GPU rasterization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update raster skewport setting. Rebase and update test context provider to match latest Skia. Created 5 years, 10 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
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"
11 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "cc/test/test_gles2_interface.h" 13 #include "cc/test/test_gles2_interface.h"
14 #include "cc/test/test_web_graphics_context_3d.h" 14 #include "cc/test/test_web_graphics_context_3d.h"
15 #include "third_party/skia/include/gpu/GrContext.h" 15 #include "third_party/skia/include/gpu/GrContext.h"
16 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" 16 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
17 #include "third_party/skia/include/gpu/gl/SkNullGLContext.h"
17 18
18 namespace cc { 19 namespace cc {
19 20
20 // static 21 // static
21 scoped_refptr<TestContextProvider> TestContextProvider::Create() { 22 scoped_refptr<TestContextProvider> TestContextProvider::Create() {
22 return Create(TestWebGraphicsContext3D::Create().Pass()); 23 return Create(TestWebGraphicsContext3D::Create().Pass());
23 } 24 }
24 25
25 // static 26 // static
26 scoped_refptr<TestContextProvider> TestContextProvider::Create( 27 scoped_refptr<TestContextProvider> TestContextProvider::Create(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 63 }
63 bound_ = true; 64 bound_ = true;
64 65
65 context3d_->set_context_lost_callback( 66 context3d_->set_context_lost_callback(
66 base::Bind(&TestContextProvider::OnLostContext, 67 base::Bind(&TestContextProvider::OnLostContext,
67 base::Unretained(this))); 68 base::Unretained(this)));
68 69
69 return true; 70 return true;
70 } 71 }
71 72
73 void TestContextProvider::DetachFromThread() {
74 context_thread_checker_.DetachFromThread();
75 }
76
72 ContextProvider::Capabilities TestContextProvider::ContextCapabilities() { 77 ContextProvider::Capabilities TestContextProvider::ContextCapabilities() {
73 DCHECK(bound_); 78 DCHECK(bound_);
74 DCHECK(context_thread_checker_.CalledOnValidThread()); 79 DCHECK(context_thread_checker_.CalledOnValidThread());
75 80
76 return context3d_->test_capabilities(); 81 return context3d_->test_capabilities();
77 } 82 }
78 83
79 gpu::gles2::GLES2Interface* TestContextProvider::ContextGL() { 84 gpu::gles2::GLES2Interface* TestContextProvider::ContextGL() {
80 DCHECK(context3d_); 85 DCHECK(context3d_);
81 DCHECK(bound_); 86 DCHECK(bound_);
82 DCHECK(context_thread_checker_.CalledOnValidThread()); 87 DCHECK(context_thread_checker_.CalledOnValidThread());
83 88
84 return context_gl_.get(); 89 return context_gl_.get();
85 } 90 }
86 91
87 gpu::ContextSupport* TestContextProvider::ContextSupport() { 92 gpu::ContextSupport* TestContextProvider::ContextSupport() {
88 return &support_; 93 return &support_;
89 } 94 }
90 95
91 class GrContext* TestContextProvider::GrContext() { 96 class GrContext* TestContextProvider::GrContext() {
92 DCHECK(bound_); 97 DCHECK(bound_);
93 DCHECK(context_thread_checker_.CalledOnValidThread()); 98 DCHECK(context_thread_checker_.CalledOnValidThread());
94 99
95 if (gr_context_) 100 if (gr_context_)
96 return gr_context_.get(); 101 return gr_context_.get();
97 102
98 skia::RefPtr<const GrGLInterface> null_interface = 103 gl_context_ = skia::AdoptRef(SkNullGLContext::Create(kNone_GrGLStandard));
99 skia::AdoptRef(GrGLCreateNullInterface()); 104 gl_context_->makeCurrent();
100 gr_context_ = skia::AdoptRef(GrContext::Create( 105 gr_context_ = skia::AdoptRef(
101 kOpenGL_GrBackend, 106 GrContext::Create(kOpenGL_GrBackend,
102 reinterpret_cast<GrBackendContext>(null_interface.get()))); 107 reinterpret_cast<GrBackendContext>(gl_context_->gl())));
103 return gr_context_.get(); 108 return gr_context_.get();
104 } 109 }
105 110
106 bool TestContextProvider::IsContextLost() { 111 bool TestContextProvider::IsContextLost() {
107 DCHECK(bound_); 112 DCHECK(bound_);
108 DCHECK(context_thread_checker_.CalledOnValidThread()); 113 DCHECK(context_thread_checker_.CalledOnValidThread());
109 114
110 return context3d_->isContextLost(); 115 return context3d_->isContextLost();
111 } 116 }
112 117
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null()); 178 DCHECK(memory_policy_changed_callback_.is_null() || cb.is_null());
174 memory_policy_changed_callback_ = cb; 179 memory_policy_changed_callback_ = cb;
175 } 180 }
176 181
177 void TestContextProvider::SetMaxTransferBufferUsageBytes( 182 void TestContextProvider::SetMaxTransferBufferUsageBytes(
178 size_t max_transfer_buffer_usage_bytes) { 183 size_t max_transfer_buffer_usage_bytes) {
179 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); 184 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes);
180 } 185 }
181 186
182 } // namespace cc 187 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698