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

Side by Side Diff: webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc

Issue 12217099: Implement the Platform::sharedOffscreenGraphicsContext3D method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no factory member vars Created 7 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 | Annotate | Revision Log
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 "webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h" 5 #include "webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "cc/context_provider.h" 10 #include "cc/context_provider.h"
11 #include "cc/fake_web_graphics_context_3d.h" 11 #include "cc/fake_web_graphics_context_3d.h"
12 #include "cc/input_handler.h" 12 #include "cc/input_handler.h"
13 #include "cc/layer.h" 13 #include "cc/layer.h"
14 #include "cc/layer_tree_host.h" 14 #include "cc/layer_tree_host.h"
15 #include "cc/output_surface.h" 15 #include "cc/output_surface.h"
16 #include "cc/switches.h" 16 #include "cc/switches.h"
17 #include "cc/thread.h" 17 #include "cc/thread.h"
18 #include "cc/thread_impl.h" 18 #include "cc/thread_impl.h"
19 #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" 19 #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h"
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
21 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h" 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h"
22 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
23 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" 23 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h"
24 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewCli ent.h" 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewCli ent.h"
25 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h " 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h "
26 #include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsCo ntext3D.h"
27 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" 26 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
28 #include "webkit/compositor_bindings/web_compositor_support_impl.h" 27 #include "webkit/compositor_bindings/web_compositor_support_impl.h"
29 #include "webkit/compositor_bindings/web_compositor_support_software_output_devi ce.h" 28 #include "webkit/compositor_bindings/web_compositor_support_software_output_devi ce.h"
30 #include "webkit/compositor_bindings/web_layer_impl.h" 29 #include "webkit/compositor_bindings/web_layer_impl.h"
31 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" 30 #include "webkit/compositor_bindings/web_rendering_stats_impl.h"
32 #include "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h" 31 #include "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h"
33 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" 32 #include "webkit/gpu/test_context_provider_factory.h"
33 #include "webkit/support/test_webkit_platform_support.h"
34 34
35 namespace WebKit { 35 namespace WebKit {
36 36
37 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting( 37 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting(
38 RenderingType type, 38 RenderingType type,
39 WebKit::WebLayerTreeViewClient* client) 39 WebKit::WebLayerTreeViewClient* client)
40 : type_(type), client_(client) {} 40 : type_(type),
41 client_(client) {}
41 42
42 WebLayerTreeViewImplForTesting::~WebLayerTreeViewImplForTesting() {} 43 WebLayerTreeViewImplForTesting::~WebLayerTreeViewImplForTesting() {
44 }
43 45
44 bool WebLayerTreeViewImplForTesting::initialize( 46 bool WebLayerTreeViewImplForTesting::initialize(
45 scoped_ptr<cc::Thread> compositor_thread) { 47 scoped_ptr<cc::Thread> compositor_thread) {
46 cc::LayerTreeSettings settings; 48 cc::LayerTreeSettings settings;
47 // Accelerated animations are disabled for layout tests, but enabled for unit 49 // Accelerated animations are disabled for layout tests, but enabled for unit
48 // tests. 50 // tests.
49 settings.acceleratedAnimationEnabled = type_ == FAKE_CONTEXT; 51 settings.acceleratedAnimationEnabled = type_ == FAKE_CONTEXT;
50 layer_tree_host_ = 52 layer_tree_host_ =
51 cc::LayerTreeHost::create(this, settings, compositor_thread.Pass()); 53 cc::LayerTreeHost::create(this, settings, compositor_thread.Pass());
52 if (!layer_tree_host_.get()) 54 if (!layer_tree_host_.get())
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 220
219 void WebLayerTreeViewImplForTesting::didCommitAndDrawFrame() {} 221 void WebLayerTreeViewImplForTesting::didCommitAndDrawFrame() {}
220 222
221 void WebLayerTreeViewImplForTesting::didCompleteSwapBuffers() {} 223 void WebLayerTreeViewImplForTesting::didCompleteSwapBuffers() {}
222 224
223 void WebLayerTreeViewImplForTesting::scheduleComposite() { 225 void WebLayerTreeViewImplForTesting::scheduleComposite() {
224 if (client_) 226 if (client_)
225 client_->scheduleComposite(); 227 client_->scheduleComposite();
226 } 228 }
227 229
228 class WebLayerTreeViewImplForTesting::MainThreadContextProvider :
229 public cc::ContextProvider {
230 public:
231 virtual bool InitializeOnMainThread() OVERRIDE { return true; }
232 virtual bool BindToCurrentThread() OVERRIDE { return true; }
233
234 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
235 return WebSharedGraphicsContext3D::mainThreadContext();
236 }
237 virtual class GrContext* GrContext() OVERRIDE {
238 return WebSharedGraphicsContext3D::mainThreadGrContext();
239 }
240
241 virtual void VerifyContexts() OVERRIDE {}
242
243 protected:
244 virtual ~MainThreadContextProvider() {}
245 };
246
247 scoped_refptr<cc::ContextProvider> 230 scoped_refptr<cc::ContextProvider>
248 WebLayerTreeViewImplForTesting::OffscreenContextProviderForMainThread() { 231 WebLayerTreeViewImplForTesting::OffscreenContextProviderForMainThread() {
249 if (!contexts_main_thread_) 232 return webkit::gpu::TestContextProviderFactory::GetInstance()->
250 contexts_main_thread_ = new MainThreadContextProvider; 233 OffscreenContextProviderForMainThread();
251 return contexts_main_thread_;
252 } 234 }
253 235
254 class WebLayerTreeViewImplForTesting::CompositorThreadContextProvider :
255 public cc::ContextProvider {
256 public:
257 CompositorThreadContextProvider() : destroyed_(false) {}
258
259 virtual bool InitializeOnMainThread() OVERRIDE {
260 return WebSharedGraphicsContext3D::createCompositorThreadContext();
261 }
262 virtual bool BindToCurrentThread() OVERRIDE {
263 return Context3d()->makeContextCurrent();
264 }
265
266 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
267 return WebSharedGraphicsContext3D::compositorThreadContext();
268 }
269 virtual class GrContext* GrContext() OVERRIDE {
270 return WebSharedGraphicsContext3D::compositorThreadGrContext();
271 }
272
273 virtual void VerifyContexts() OVERRIDE {
274 if (Context3d() && !Context3d()->isContextLost())
275 return;
276 base::AutoLock lock(destroyed_lock_);
277 destroyed_ = true;
278 }
279
280 bool DestroyedOnMainThread() {
281 base::AutoLock lock(destroyed_lock_);
282 return destroyed_;
283 }
284
285 protected:
286 virtual ~CompositorThreadContextProvider() {}
287
288 private:
289 base::Lock destroyed_lock_;
290 bool destroyed_;
291 };
292
293 scoped_refptr<cc::ContextProvider> 236 scoped_refptr<cc::ContextProvider>
294 WebLayerTreeViewImplForTesting::OffscreenContextProviderForCompositorThread() { 237 WebLayerTreeViewImplForTesting::OffscreenContextProviderForCompositorThread() {
295 if (!contexts_compositor_thread_ || 238 return webkit::gpu::TestContextProviderFactory::GetInstance()->
296 contexts_compositor_thread_->DestroyedOnMainThread()) 239 OffscreenContextProviderForCompositorThread();
297 contexts_compositor_thread_ = new CompositorThreadContextProvider;
298 return contexts_compositor_thread_;
299 } 240 }
300 241
301 } // namespace WebKit 242 } // namespace WebKit
OLDNEW
« no previous file with comments | « webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h ('k') | webkit/gpu/context_provider_in_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698