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

Side by Side Diff: android_webview/browser/hardware_renderer.cc

Issue 455783002: GPU context creation code duplication cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fix even more build dependencies Created 6 years, 4 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
« no previous file with comments | « android_webview/android_webview.gyp ('k') | cc/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "android_webview/public/browser/draw_gl.h" 11 #include "android_webview/public/browser/draw_gl.h"
12 #include "base/auto_reset.h" 12 #include "base/auto_reset.h"
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "cc/layers/delegated_frame_provider.h" 15 #include "cc/layers/delegated_frame_provider.h"
16 #include "cc/layers/delegated_renderer_layer.h" 16 #include "cc/layers/delegated_renderer_layer.h"
17 #include "cc/layers/layer.h" 17 #include "cc/layers/layer.h"
18 #include "cc/output/compositor_frame.h" 18 #include "cc/output/compositor_frame.h"
19 #include "cc/output/output_surface.h" 19 #include "cc/output/output_surface.h"
20 #include "cc/trees/layer_tree_host.h" 20 #include "cc/trees/layer_tree_host.h"
21 #include "cc/trees/layer_tree_settings.h" 21 #include "cc/trees/layer_tree_settings.h"
22 #include "gpu/command_buffer/client/gl_in_process_context.h" 22 #include "gpu/command_buffer/client/gl_in_process_context.h"
23 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
23 #include "ui/gfx/frame_time.h" 24 #include "ui/gfx/frame_time.h"
24 #include "ui/gfx/geometry/rect_conversions.h" 25 #include "ui/gfx/geometry/rect_conversions.h"
25 #include "ui/gfx/geometry/rect_f.h" 26 #include "ui/gfx/geometry/rect_f.h"
26 #include "ui/gfx/transform.h" 27 #include "ui/gfx/transform.h"
27 #include "ui/gl/gl_bindings.h" 28 #include "ui/gl/gl_bindings.h"
28 #include "webkit/common/gpu/context_provider_in_process.h" 29 #include "webkit/common/gpu/context_provider_in_process.h"
29 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h" 30 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
30 31
31 namespace android_webview { 32 namespace android_webview {
32 33
33 namespace { 34 namespace {
34 35
35 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; 36 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
37 using webkit::gpu::WebGraphicsContext3DImpl;
36 38
37 scoped_refptr<cc::ContextProvider> CreateContext( 39 scoped_refptr<cc::ContextProvider> CreateContext(
38 scoped_refptr<gfx::GLSurface> surface, 40 scoped_refptr<gfx::GLSurface> surface,
39 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, 41 scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
40 gpu::GLInProcessContext* share_context) { 42 gpu::GLInProcessContext* share_context) {
41 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; 43 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
42 44
43 blink::WebGraphicsContext3D::Attributes attributes; 45 blink::WebGraphicsContext3D::Attributes attributes;
44 attributes.antialias = false; 46 attributes.antialias = false;
45 attributes.depth = false; 47 attributes.depth = false;
46 attributes.stencil = false; 48 attributes.stencil = false;
47 attributes.shareResources = true; 49 attributes.shareResources = true;
48 attributes.noAutomaticFlushes = true; 50 attributes.noAutomaticFlushes = true;
49 gpu::GLInProcessContextAttribs in_process_attribs; 51 gpu::gles2::ContextCreationAttribHelper attribs_for_gles2;
50 WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes( 52 WebGraphicsContext3DImpl::ConvertAttributes(
51 attributes, &in_process_attribs); 53 attributes, &attribs_for_gles2);
52 in_process_attribs.lose_context_when_out_of_memory = 1; 54 attribs_for_gles2.lose_context_when_out_of_memory = true;
53 55
54 scoped_ptr<gpu::GLInProcessContext> context( 56 scoped_ptr<gpu::GLInProcessContext> context(
55 gpu::GLInProcessContext::Create(service, 57 gpu::GLInProcessContext::Create(service,
56 surface, 58 surface,
57 surface->IsOffscreen(), 59 surface->IsOffscreen(),
58 gfx::kNullAcceleratedWidget, 60 gfx::kNullAcceleratedWidget,
59 surface->GetSize(), 61 surface->GetSize(),
60 share_context, 62 share_context,
61 false /* share_resources */, 63 false /* share_resources */,
62 in_process_attribs, 64 attribs_for_gles2,
63 gpu_preference)); 65 gpu_preference));
64 DCHECK(context.get()); 66 DCHECK(context.get());
65 67
66 return webkit::gpu::ContextProviderInProcess::Create( 68 return webkit::gpu::ContextProviderInProcess::Create(
67 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( 69 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
68 context.Pass(), attributes), 70 context.Pass(), attributes),
69 "Parent-Compositor"); 71 "Parent-Compositor");
70 } 72 }
71 73
72 } // namespace 74 } // namespace
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 243 }
242 244
243 void HardwareRenderer::UnusedResourcesAreAvailable() { 245 void HardwareRenderer::UnusedResourcesAreAvailable() {
244 cc::ReturnedResourceArray returned_resources; 246 cc::ReturnedResourceArray returned_resources;
245 resource_collection_->TakeUnusedResourcesForChildCompositor( 247 resource_collection_->TakeUnusedResourcesForChildCompositor(
246 &returned_resources); 248 &returned_resources);
247 shared_renderer_state_->InsertReturnedResources(returned_resources); 249 shared_renderer_state_->InsertReturnedResources(returned_resources);
248 } 250 }
249 251
250 } // namespace android_webview 252 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/android_webview.gyp ('k') | cc/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698