| OLD | NEW |
| 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 "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "cc/output/begin_frame_args.h" | 9 #include "cc/output/begin_frame_args.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
| 24 #include "ui/gl/gl_surface.h" | 24 #include "ui/gl/gl_surface.h" |
| 25 #include "webkit/common/gpu/context_provider_in_process.h" | 25 #include "webkit/common/gpu/context_provider_in_process.h" |
| 26 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 26 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> | 32 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> |
| 33 CreateWebGraphicsContext3D(scoped_refptr<gfx::GLSurface> surface) { | 33 CreateWebGraphicsContext3D( |
| 34 scoped_refptr<gfx::GLSurface> surface, |
| 35 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
| 34 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; | 36 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; |
| 35 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 37 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| 36 | 38 |
| 37 blink::WebGraphicsContext3D::Attributes attributes; | 39 blink::WebGraphicsContext3D::Attributes attributes; |
| 38 attributes.antialias = false; | 40 attributes.antialias = false; |
| 39 attributes.shareResources = true; | 41 attributes.shareResources = true; |
| 40 attributes.noAutomaticFlushes = true; | 42 attributes.noAutomaticFlushes = true; |
| 41 | 43 |
| 42 gpu::GLInProcessContextAttribs in_process_attribs; | 44 gpu::GLInProcessContextAttribs in_process_attribs; |
| 43 WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes( | 45 WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes( |
| 44 attributes, &in_process_attribs); | 46 attributes, &in_process_attribs); |
| 45 scoped_ptr<gpu::GLInProcessContext> context( | 47 scoped_ptr<gpu::GLInProcessContext> context( |
| 46 gpu::GLInProcessContext::CreateWithSurface(surface, | 48 gpu::GLInProcessContext::CreateWithSurface(surface, |
| 49 service, |
| 47 attributes.shareResources, | 50 attributes.shareResources, |
| 48 in_process_attribs, | 51 in_process_attribs, |
| 49 gpu_preference)); | 52 gpu_preference)); |
| 50 | 53 |
| 51 if (!context.get()) | 54 if (!context.get()) |
| 52 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(); | 55 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(); |
| 53 | 56 |
| 54 return WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( | 57 return WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( |
| 55 context.Pass(), attributes).Pass(); | 58 context.Pass(), attributes).Pass(); |
| 56 } | 59 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 187 |
| 185 namespace { | 188 namespace { |
| 186 void AdjustTransform(gfx::Transform* transform, gfx::Rect viewport) { | 189 void AdjustTransform(gfx::Transform* transform, gfx::Rect viewport) { |
| 187 // CC's draw origin starts at the viewport. | 190 // CC's draw origin starts at the viewport. |
| 188 transform->matrix().postTranslate(-viewport.x(), -viewport.y(), 0); | 191 transform->matrix().postTranslate(-viewport.x(), -viewport.y(), 0); |
| 189 } | 192 } |
| 190 } // namespace | 193 } // namespace |
| 191 | 194 |
| 192 bool SynchronousCompositorOutputSurface::InitializeHwDraw( | 195 bool SynchronousCompositorOutputSurface::InitializeHwDraw( |
| 193 scoped_refptr<gfx::GLSurface> surface, | 196 scoped_refptr<gfx::GLSurface> surface, |
| 197 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
| 194 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { | 198 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { |
| 195 DCHECK(CalledOnValidThread()); | 199 DCHECK(CalledOnValidThread()); |
| 196 DCHECK(HasClient()); | 200 DCHECK(HasClient()); |
| 197 DCHECK(!context_provider_); | 201 DCHECK(!context_provider_); |
| 198 DCHECK(surface); | 202 DCHECK(surface); |
| 199 | 203 |
| 200 scoped_refptr<cc::ContextProvider> onscreen_context_provider = | 204 scoped_refptr<cc::ContextProvider> onscreen_context_provider = |
| 201 webkit::gpu::ContextProviderInProcess::Create( | 205 webkit::gpu::ContextProviderInProcess::Create( |
| 202 CreateWebGraphicsContext3D(surface), "SynchronousCompositor"); | 206 CreateWebGraphicsContext3D(surface, service), "SynchronousCompositor")
; |
| 203 return InitializeAndSetContext3d(onscreen_context_provider, | 207 return InitializeAndSetContext3d(onscreen_context_provider, |
| 204 offscreen_context_provider); | 208 offscreen_context_provider); |
| 205 } | 209 } |
| 206 | 210 |
| 207 void SynchronousCompositorOutputSurface::ReleaseHwDraw() { | 211 void SynchronousCompositorOutputSurface::ReleaseHwDraw() { |
| 208 DCHECK(CalledOnValidThread()); | 212 DCHECK(CalledOnValidThread()); |
| 209 cc::OutputSurface::ReleaseGL(); | 213 cc::OutputSurface::ReleaseGL(); |
| 210 } | 214 } |
| 211 | 215 |
| 212 bool SynchronousCompositorOutputSurface::DemandDrawHw( | 216 bool SynchronousCompositorOutputSurface::DemandDrawHw( |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 308 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
| 305 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 309 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 306 } | 310 } |
| 307 | 311 |
| 308 SynchronousCompositorOutputSurfaceDelegate* | 312 SynchronousCompositorOutputSurfaceDelegate* |
| 309 SynchronousCompositorOutputSurface::GetDelegate() { | 313 SynchronousCompositorOutputSurface::GetDelegate() { |
| 310 return SynchronousCompositorImpl::FromRoutingID(routing_id_); | 314 return SynchronousCompositorImpl::FromRoutingID(routing_id_); |
| 311 } | 315 } |
| 312 | 316 |
| 313 } // namespace content | 317 } // namespace content |
| OLD | NEW |