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

Side by Side Diff: ui/compositor/test/in_process_context_factory.cc

Issue 145293007: ui: No more TestCompositor. Use NullDraw contexts in unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: testsnulldraw: Created 6 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 | 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 "ui/compositor/test/default_context_factory.h" 5 #include "ui/compositor/test/in_process_context_factory.h"
6 6
7 #include "cc/output/output_surface.h" 7 #include "cc/output/output_surface.h"
8 #include "ui/compositor/reflector.h" 8 #include "ui/compositor/reflector.h"
9 #include "ui/gl/gl_implementation.h" 9 #include "ui/gl/gl_implementation.h"
10 #include "ui/gl/gl_surface.h" 10 #include "ui/gl/gl_surface.h"
11 #include "webkit/common/gpu/context_provider_in_process.h" 11 #include "webkit/common/gpu/context_provider_in_process.h"
12 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" 12 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
13 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h" 13 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
14 14
15 namespace ui { 15 namespace ui {
16 16
17 DefaultContextFactory::DefaultContextFactory() { 17 InProcessContextFactory::InProcessContextFactory() {
18 DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone); 18 DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone);
19 } 19 }
20 20
21 DefaultContextFactory::~DefaultContextFactory() { 21 InProcessContextFactory::~InProcessContextFactory() {}
22 }
23 22
24 scoped_ptr<cc::OutputSurface> DefaultContextFactory::CreateOutputSurface( 23 scoped_ptr<cc::OutputSurface> InProcessContextFactory::CreateOutputSurface(
25 Compositor* compositor, bool software_fallback) { 24 Compositor* compositor,
25 bool software_fallback) {
26 DCHECK(!software_fallback); 26 DCHECK(!software_fallback);
27 blink::WebGraphicsContext3D::Attributes attrs; 27 blink::WebGraphicsContext3D::Attributes attrs;
28 attrs.depth = false; 28 attrs.depth = false;
29 attrs.stencil = false; 29 attrs.stencil = false;
30 attrs.antialias = false; 30 attrs.antialias = false;
31 attrs.shareResources = true; 31 attrs.shareResources = true;
32 32
33 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; 33 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
34 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( 34 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d(
35 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( 35 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
36 attrs, compositor->widget())); 36 attrs, compositor->widget()));
37 CHECK(context3d); 37 CHECK(context3d);
38 38
39 using webkit::gpu::ContextProviderInProcess; 39 using webkit::gpu::ContextProviderInProcess;
40 scoped_refptr<ContextProviderInProcess> context_provider = 40 scoped_refptr<ContextProviderInProcess> context_provider =
41 ContextProviderInProcess::Create(context3d.Pass(), 41 ContextProviderInProcess::Create(context3d.Pass(), "UICompositor");
42 "UICompositor");
43 42
44 return make_scoped_ptr(new cc::OutputSurface(context_provider)); 43 return make_scoped_ptr(new cc::OutputSurface(context_provider));
45 } 44 }
46 45
47 scoped_refptr<Reflector> DefaultContextFactory::CreateReflector( 46 scoped_refptr<Reflector> InProcessContextFactory::CreateReflector(
48 Compositor* mirroed_compositor, 47 Compositor* mirroed_compositor,
49 Layer* mirroring_layer) { 48 Layer* mirroring_layer) {
50 return NULL; 49 return NULL;
51 } 50 }
52 51
53 void DefaultContextFactory::RemoveReflector( 52 void InProcessContextFactory::RemoveReflector(
54 scoped_refptr<Reflector> reflector) { 53 scoped_refptr<Reflector> reflector) {}
55 }
56 54
57 scoped_refptr<cc::ContextProvider> 55 scoped_refptr<cc::ContextProvider>
58 DefaultContextFactory::OffscreenCompositorContextProvider() { 56 InProcessContextFactory::OffscreenCompositorContextProvider() {
59 if (!offscreen_compositor_contexts_.get() || 57 if (!offscreen_compositor_contexts_.get() ||
60 !offscreen_compositor_contexts_->DestroyedOnMainThread()) { 58 !offscreen_compositor_contexts_->DestroyedOnMainThread()) {
61 offscreen_compositor_contexts_ = 59 offscreen_compositor_contexts_ =
62 webkit::gpu::ContextProviderInProcess::CreateOffscreen(); 60 webkit::gpu::ContextProviderInProcess::CreateOffscreen();
63 } 61 }
64 return offscreen_compositor_contexts_; 62 return offscreen_compositor_contexts_;
65 } 63 }
66 64
67 scoped_refptr<cc::ContextProvider> 65 scoped_refptr<cc::ContextProvider>
68 DefaultContextFactory::SharedMainThreadContextProvider() { 66 InProcessContextFactory::SharedMainThreadContextProvider() {
69 if (shared_main_thread_contexts_ && 67 if (shared_main_thread_contexts_ &&
70 !shared_main_thread_contexts_->DestroyedOnMainThread()) 68 !shared_main_thread_contexts_->DestroyedOnMainThread())
71 return shared_main_thread_contexts_; 69 return shared_main_thread_contexts_;
72 70
73 if (ui::Compositor::WasInitializedWithThread()) { 71 if (ui::Compositor::WasInitializedWithThread()) {
74 shared_main_thread_contexts_ = 72 shared_main_thread_contexts_ =
75 webkit::gpu::ContextProviderInProcess::CreateOffscreen(); 73 webkit::gpu::ContextProviderInProcess::CreateOffscreen();
76 } else { 74 } else {
77 shared_main_thread_contexts_ = 75 shared_main_thread_contexts_ =
78 static_cast<webkit::gpu::ContextProviderInProcess*>( 76 static_cast<webkit::gpu::ContextProviderInProcess*>(
79 OffscreenCompositorContextProvider().get()); 77 OffscreenCompositorContextProvider().get());
80 } 78 }
81 if (shared_main_thread_contexts_ && 79 if (shared_main_thread_contexts_ &&
82 !shared_main_thread_contexts_->BindToCurrentThread()) 80 !shared_main_thread_contexts_->BindToCurrentThread())
83 shared_main_thread_contexts_ = NULL; 81 shared_main_thread_contexts_ = NULL;
84 82
85 return shared_main_thread_contexts_; 83 return shared_main_thread_contexts_;
86 } 84 }
87 85
88 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { 86 void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {}
89 }
90 87
91 bool DefaultContextFactory::DoesCreateTestContexts() { return false; } 88 bool InProcessContextFactory::DoesCreateTestContexts() { return false; }
92 89
93 } // namespace ui 90 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698