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

Side by Side Diff: content/browser/aura/browser_compositor_output_surface.cc

Issue 20185002: ContextProvider in OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: contextprovider: android Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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/aura/browser_compositor_output_surface.h" 5 #include "content/browser/aura/browser_compositor_output_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "cc/output/compositor_frame.h" 12 #include "cc/output/compositor_frame.h"
13 #include "content/browser/aura/reflector_impl.h" 13 #include "content/browser/aura/reflector_impl.h"
14 #include "content/common/gpu/client/context_provider_command_buffer.h"
14 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 15 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
15 #include "ui/compositor/compositor.h" 16 #include "ui/compositor/compositor.h"
16 #include "ui/compositor/compositor_switches.h" 17 #include "ui/compositor/compositor_switches.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( 21 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
21 scoped_ptr<WebKit::WebGraphicsContext3D> context, 22 const scoped_refptr<ContextProviderCommandBuffer>& context_provider,
22 int surface_id, 23 int surface_id,
23 IDMap<BrowserCompositorOutputSurface>* output_surface_map, 24 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
24 base::MessageLoopProxy* compositor_message_loop, 25 base::MessageLoopProxy* compositor_message_loop,
25 base::WeakPtr<ui::Compositor> compositor) 26 base::WeakPtr<ui::Compositor> compositor)
26 : OutputSurface(context.Pass()), 27 : OutputSurface(context_provider),
28 command_buffer_context_(context_provider->Context3d()),
27 surface_id_(surface_id), 29 surface_id_(surface_id),
28 output_surface_map_(output_surface_map), 30 output_surface_map_(output_surface_map),
29 compositor_message_loop_(compositor_message_loop), 31 compositor_message_loop_(compositor_message_loop),
30 compositor_(compositor) { 32 compositor_(compositor) {
31 CommandLine* command_line = CommandLine::ForCurrentProcess(); 33 CommandLine* command_line = CommandLine::ForCurrentProcess();
32 if (command_line->HasSwitch(switches::kUIMaxFramesPending)) { 34 if (command_line->HasSwitch(switches::kUIMaxFramesPending)) {
33 std::string string_value = command_line->GetSwitchValueASCII( 35 std::string string_value = command_line->GetSwitchValueASCII(
34 switches::kUIMaxFramesPending); 36 switches::kUIMaxFramesPending);
35 int int_value; 37 int int_value;
36 if (base::StringToInt(string_value, &int_value)) 38 if (base::StringToInt(string_value, &int_value))
(...skipping 26 matching lines...) Expand all
63 void BrowserCompositorOutputSurface::Reshape(gfx::Size size, 65 void BrowserCompositorOutputSurface::Reshape(gfx::Size size,
64 float scale_factor) { 66 float scale_factor) {
65 OutputSurface::Reshape(size, scale_factor); 67 OutputSurface::Reshape(size, scale_factor);
66 if (reflector_.get()) 68 if (reflector_.get())
67 reflector_->OnReshape(size); 69 reflector_->OnReshape(size);
68 } 70 }
69 71
70 void BrowserCompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { 72 void BrowserCompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
71 DCHECK(frame->gl_frame_data); 73 DCHECK(frame->gl_frame_data);
72 74
73 WebGraphicsContext3DCommandBufferImpl* command_buffer =
74 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d());
75 CommandBufferProxyImpl* command_buffer_proxy = 75 CommandBufferProxyImpl* command_buffer_proxy =
76 command_buffer->GetCommandBufferProxy(); 76 command_buffer_context_->GetCommandBufferProxy();
77 DCHECK(command_buffer_proxy); 77 DCHECK(command_buffer_proxy);
78 context3d()->shallowFlushCHROMIUM(); 78 context_provider_->Context3d()->shallowFlushCHROMIUM();
79 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); 79 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info);
80 80
81 if (reflector_.get()) { 81 if (reflector_.get()) {
82 if (frame->gl_frame_data->sub_buffer_rect == 82 if (frame->gl_frame_data->sub_buffer_rect ==
83 gfx::Rect(frame->gl_frame_data->size)) 83 gfx::Rect(frame->gl_frame_data->size))
84 reflector_->OnSwapBuffers(); 84 reflector_->OnSwapBuffers();
85 else 85 else
86 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect); 86 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect);
87 } 87 }
88 88
(...skipping 10 matching lines...) Expand all
99 FROM_HERE, 99 FROM_HERE,
100 base::Bind(&ui::Compositor::OnUpdateVSyncParameters, 100 base::Bind(&ui::Compositor::OnUpdateVSyncParameters,
101 compositor_, timebase, interval)); 101 compositor_, timebase, interval));
102 } 102 }
103 103
104 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { 104 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) {
105 reflector_ = reflector; 105 reflector_ = reflector;
106 } 106 }
107 107
108 } // namespace content 108 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698