OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "android_webview/browser/hardware_renderer.h" | 5 #include "android_webview/browser/hardware_renderer.h" |
6 | 6 |
7 #include "android_webview/browser/aw_gl_surface.h" | 7 #include "android_webview/browser/aw_gl_surface.h" |
8 #include "android_webview/browser/deferred_gpu_command_service.h" | 8 #include "android_webview/browser/deferred_gpu_command_service.h" |
9 #include "android_webview/browser/parent_output_surface.h" | 9 #include "android_webview/browser/parent_output_surface.h" |
10 #include "android_webview/browser/shared_renderer_state.h" | 10 #include "android_webview/browser/shared_renderer_state.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 namespace android_webview { | 32 namespace android_webview { |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; | 36 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; |
37 using webkit::gpu::WebGraphicsContext3DImpl; | 37 using webkit::gpu::WebGraphicsContext3DImpl; |
38 | 38 |
39 scoped_refptr<cc::ContextProvider> CreateContext( | 39 scoped_refptr<cc::ContextProvider> CreateContext( |
40 scoped_refptr<gfx::GLSurface> surface, | 40 scoped_refptr<gfx::GLSurface> surface, |
41 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 41 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
42 gpu::GLInProcessContext* share_context) { | |
43 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 42 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
44 | 43 |
45 blink::WebGraphicsContext3D::Attributes attributes; | 44 blink::WebGraphicsContext3D::Attributes attributes; |
46 attributes.antialias = false; | 45 attributes.antialias = false; |
47 attributes.depth = false; | 46 attributes.depth = false; |
48 attributes.stencil = false; | 47 attributes.stencil = false; |
49 attributes.shareResources = true; | 48 attributes.shareResources = true; |
50 attributes.noAutomaticFlushes = true; | 49 attributes.noAutomaticFlushes = true; |
51 gpu::gles2::ContextCreationAttribHelper attribs_for_gles2; | 50 gpu::gles2::ContextCreationAttribHelper attribs_for_gles2; |
52 WebGraphicsContext3DImpl::ConvertAttributes( | 51 WebGraphicsContext3DImpl::ConvertAttributes( |
53 attributes, &attribs_for_gles2); | 52 attributes, &attribs_for_gles2); |
54 attribs_for_gles2.lose_context_when_out_of_memory = true; | 53 attribs_for_gles2.lose_context_when_out_of_memory = true; |
55 | 54 |
56 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( | 55 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( |
57 service, | 56 service, |
58 surface, | 57 surface, |
59 surface->IsOffscreen(), | 58 surface->IsOffscreen(), |
60 gfx::kNullAcceleratedWidget, | 59 gfx::kNullAcceleratedWidget, |
61 surface->GetSize(), | 60 surface->GetSize(), |
62 share_context, | 61 NULL /* share_context */, |
63 false /* share_resources */, | 62 false /* share_resources */, |
64 attribs_for_gles2, | 63 attribs_for_gles2, |
65 gpu_preference, | 64 gpu_preference, |
66 gpu::GLInProcessContextSharedMemoryLimits())); | 65 gpu::GLInProcessContextSharedMemoryLimits())); |
67 DCHECK(context.get()); | 66 DCHECK(context.get()); |
68 | 67 |
69 return webkit::gpu::ContextProviderInProcess::Create( | 68 return webkit::gpu::ContextProviderInProcess::Create( |
70 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( | 69 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( |
71 context.Pass(), attributes), | 70 context.Pass(), attributes), |
72 "Parent-Compositor"); | 71 "Parent-Compositor"); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 234 } |
236 gl_surface_->ResetBackingFrameBufferObject(); | 235 gl_surface_->ResetBackingFrameBufferObject(); |
237 } | 236 } |
238 | 237 |
239 scoped_ptr<cc::OutputSurface> HardwareRenderer::CreateOutputSurface( | 238 scoped_ptr<cc::OutputSurface> HardwareRenderer::CreateOutputSurface( |
240 bool fallback) { | 239 bool fallback) { |
241 // Android webview does not support losing output surface. | 240 // Android webview does not support losing output surface. |
242 DCHECK(!fallback); | 241 DCHECK(!fallback); |
243 scoped_refptr<cc::ContextProvider> context_provider = | 242 scoped_refptr<cc::ContextProvider> context_provider = |
244 CreateContext(gl_surface_, | 243 CreateContext(gl_surface_, |
245 DeferredGpuCommandService::GetInstance(), | 244 DeferredGpuCommandService::GetInstance()); |
246 shared_renderer_state_->GetSharedContext()); | |
247 scoped_ptr<ParentOutputSurface> output_surface_holder( | 245 scoped_ptr<ParentOutputSurface> output_surface_holder( |
248 new ParentOutputSurface(context_provider)); | 246 new ParentOutputSurface(context_provider)); |
249 output_surface_ = output_surface_holder.get(); | 247 output_surface_ = output_surface_holder.get(); |
250 return output_surface_holder.PassAs<cc::OutputSurface>(); | 248 return output_surface_holder.PassAs<cc::OutputSurface>(); |
251 } | 249 } |
252 | 250 |
253 void HardwareRenderer::UnusedResourcesAreAvailable() { | 251 void HardwareRenderer::UnusedResourcesAreAvailable() { |
254 cc::ReturnedResourceArray returned_resources; | 252 cc::ReturnedResourceArray returned_resources; |
255 resource_collection_->TakeUnusedResourcesForChildCompositor( | 253 resource_collection_->TakeUnusedResourcesForChildCompositor( |
256 &returned_resources); | 254 &returned_resources); |
257 shared_renderer_state_->InsertReturnedResources(returned_resources); | 255 shared_renderer_state_->InsertReturnedResources(returned_resources); |
258 } | 256 } |
259 | 257 |
260 } // namespace android_webview | 258 } // namespace android_webview |
OLD | NEW |