| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/compositor.h" | 5 #include "ui/compositor/compositor.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if (!gfx::GLSurface::InitializeOneOff() || | 102 if (!gfx::GLSurface::InitializeOneOff() || |
| 103 gfx::GetGLImplementation() == gfx::kGLImplementationNone) { | 103 gfx::GetGLImplementation() == gfx::kGLImplementationNone) { |
| 104 LOG(ERROR) << "Could not load the GL bindings"; | 104 LOG(ERROR) << "Could not load the GL bindings"; |
| 105 return false; | 105 return false; |
| 106 } | 106 } |
| 107 return true; | 107 return true; |
| 108 } | 108 } |
| 109 | 109 |
| 110 scoped_ptr<cc::OutputSurface> DefaultContextFactory::CreateOutputSurface( | 110 scoped_ptr<cc::OutputSurface> DefaultContextFactory::CreateOutputSurface( |
| 111 Compositor* compositor) { | 111 Compositor* compositor) { |
| 112 WebKit::WebGraphicsContext3D::Attributes attrs; |
| 113 attrs.depth = false; |
| 114 attrs.stencil = false; |
| 115 attrs.antialias = false; |
| 116 attrs.shareResources = true; |
| 117 |
| 118 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; |
| 119 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( |
| 120 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( |
| 121 attrs, compositor->widget())); |
| 122 CHECK(context3d); |
| 112 | 123 |
| 113 using webkit::gpu::ContextProviderInProcess; | 124 using webkit::gpu::ContextProviderInProcess; |
| 114 scoped_refptr<ContextProviderInProcess> context_provider = | 125 scoped_refptr<ContextProviderInProcess> context_provider = |
| 115 ContextProviderInProcess::Create( | 126 ContextProviderInProcess::Create(context3d.Pass()); |
| 116 base::Bind(&DefaultContextFactory::CreateViewContext, compositor)); | 127 |
| 117 DCHECK(context_provider.get()); | |
| 118 return make_scoped_ptr(new cc::OutputSurface(context_provider)); | 128 return make_scoped_ptr(new cc::OutputSurface(context_provider)); |
| 119 } | 129 } |
| 120 | 130 |
| 121 scoped_refptr<Reflector> DefaultContextFactory::CreateReflector( | 131 scoped_refptr<Reflector> DefaultContextFactory::CreateReflector( |
| 122 Compositor* mirroed_compositor, | 132 Compositor* mirroed_compositor, |
| 123 Layer* mirroring_layer) { | 133 Layer* mirroring_layer) { |
| 124 return NULL; | 134 return NULL; |
| 125 } | 135 } |
| 126 | 136 |
| 127 void DefaultContextFactory::RemoveReflector( | 137 void DefaultContextFactory::RemoveReflector( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 149 webkit::gpu::ContextProviderInProcess::CreateOffscreen(); | 159 webkit::gpu::ContextProviderInProcess::CreateOffscreen(); |
| 150 } | 160 } |
| 151 return offscreen_contexts_compositor_thread_; | 161 return offscreen_contexts_compositor_thread_; |
| 152 } | 162 } |
| 153 | 163 |
| 154 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { | 164 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { |
| 155 } | 165 } |
| 156 | 166 |
| 157 bool DefaultContextFactory::DoesCreateTestContexts() { return false; } | 167 bool DefaultContextFactory::DoesCreateTestContexts() { return false; } |
| 158 | 168 |
| 159 // static | |
| 160 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> | |
| 161 DefaultContextFactory::CreateViewContext(Compositor* compositor) { | |
| 162 WebKit::WebGraphicsContext3D::Attributes attrs; | |
| 163 attrs.depth = false; | |
| 164 attrs.stencil = false; | |
| 165 attrs.antialias = false; | |
| 166 attrs.shareResources = true; | |
| 167 | |
| 168 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; | |
| 169 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context( | |
| 170 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( | |
| 171 attrs, compositor->widget())); | |
| 172 CHECK(context); | |
| 173 return context.Pass(); | |
| 174 } | |
| 175 | |
| 176 TestContextFactory::TestContextFactory() {} | 169 TestContextFactory::TestContextFactory() {} |
| 177 | 170 |
| 178 TestContextFactory::~TestContextFactory() {} | 171 TestContextFactory::~TestContextFactory() {} |
| 179 | 172 |
| 180 scoped_ptr<cc::OutputSurface> TestContextFactory::CreateOutputSurface( | 173 scoped_ptr<cc::OutputSurface> TestContextFactory::CreateOutputSurface( |
| 181 Compositor* compositor) { | 174 Compositor* compositor) { |
| 182 return make_scoped_ptr( | 175 return make_scoped_ptr( |
| 183 new cc::OutputSurface(cc::TestContextProvider::Create())); | 176 new cc::OutputSurface(cc::TestContextProvider::Create())); |
| 184 } | 177 } |
| 185 | 178 |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 } | 764 } |
| 772 | 765 |
| 773 void Compositor::NotifyEnd() { | 766 void Compositor::NotifyEnd() { |
| 774 last_ended_frame_++; | 767 last_ended_frame_++; |
| 775 FOR_EACH_OBSERVER(CompositorObserver, | 768 FOR_EACH_OBSERVER(CompositorObserver, |
| 776 observer_list_, | 769 observer_list_, |
| 777 OnCompositingEnded(this)); | 770 OnCompositingEnded(this)); |
| 778 } | 771 } |
| 779 | 772 |
| 780 } // namespace ui | 773 } // namespace ui |
| OLD | NEW |