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

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

Issue 45963003: Move test-only ContextFactory implementations out of production targets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix moar windows Created 7 years, 1 month 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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/compositor/test/default_context_factory.h"
6
7 #include "cc/output/output_surface.h"
8 #include "ui/compositor/reflector.h"
9 #include "ui/gl/gl_implementation.h"
10 #include "ui/gl/gl_surface.h"
11 #include "webkit/common/gpu/context_provider_in_process.h"
12 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
13 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
14
15 namespace ui {
16
17 DefaultContextFactory::DefaultContextFactory() {
18 }
19
20 DefaultContextFactory::~DefaultContextFactory() {
21 }
22
23 bool DefaultContextFactory::Initialize() {
24 if (!gfx::GLSurface::InitializeOneOff() ||
25 gfx::GetGLImplementation() == gfx::kGLImplementationNone) {
26 LOG(ERROR) << "Could not load the GL bindings";
27 return false;
28 }
29 return true;
30 }
31
32 scoped_ptr<cc::OutputSurface> DefaultContextFactory::CreateOutputSurface(
33 Compositor* compositor) {
34 WebKit::WebGraphicsContext3D::Attributes attrs;
35 attrs.depth = false;
36 attrs.stencil = false;
37 attrs.antialias = false;
38 attrs.shareResources = true;
39
40 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
41 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d(
42 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
43 attrs, compositor->widget()));
44 CHECK(context3d);
45
46 using webkit::gpu::ContextProviderInProcess;
47 scoped_refptr<ContextProviderInProcess> context_provider =
48 ContextProviderInProcess::Create(context3d.Pass(),
49 "UICompositor");
50
51 return make_scoped_ptr(new cc::OutputSurface(context_provider));
52 }
53
54 scoped_refptr<Reflector> DefaultContextFactory::CreateReflector(
55 Compositor* mirroed_compositor,
56 Layer* mirroring_layer) {
57 return NULL;
58 }
59
60 void DefaultContextFactory::RemoveReflector(
61 scoped_refptr<Reflector> reflector) {
62 }
63
64 scoped_refptr<cc::ContextProvider>
65 DefaultContextFactory::OffscreenCompositorContextProvider() {
66 if (!offscreen_compositor_contexts_.get() ||
67 !offscreen_compositor_contexts_->DestroyedOnMainThread()) {
68 offscreen_compositor_contexts_ =
69 webkit::gpu::ContextProviderInProcess::CreateOffscreen();
70 }
71 return offscreen_compositor_contexts_;
72 }
73
74 scoped_refptr<cc::ContextProvider>
75 DefaultContextFactory::SharedMainThreadContextProvider() {
76 if (shared_main_thread_contexts_ &&
77 !shared_main_thread_contexts_->DestroyedOnMainThread())
78 return shared_main_thread_contexts_;
79
80 if (ui::Compositor::WasInitializedWithThread()) {
81 shared_main_thread_contexts_ =
82 webkit::gpu::ContextProviderInProcess::CreateOffscreen();
83 } else {
84 shared_main_thread_contexts_ =
85 static_cast<webkit::gpu::ContextProviderInProcess*>(
86 OffscreenCompositorContextProvider().get());
87 }
88 if (shared_main_thread_contexts_ &&
89 !shared_main_thread_contexts_->BindToCurrentThread())
90 shared_main_thread_contexts_ = NULL;
91
92 return shared_main_thread_contexts_;
93 }
94
95 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) {
96 }
97
98 bool DefaultContextFactory::DoesCreateTestContexts() { return false; }
99
100 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698