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

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: don't access Context3d() in OutputSurface contructors, it's not bound yet 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),
27 surface_id_(surface_id), 28 surface_id_(surface_id),
28 output_surface_map_(output_surface_map), 29 output_surface_map_(output_surface_map),
29 compositor_message_loop_(compositor_message_loop), 30 compositor_message_loop_(compositor_message_loop),
30 compositor_(compositor) { 31 compositor_(compositor) {
31 CommandLine* command_line = CommandLine::ForCurrentProcess(); 32 CommandLine* command_line = CommandLine::ForCurrentProcess();
32 if (command_line->HasSwitch(switches::kUIMaxFramesPending)) { 33 if (command_line->HasSwitch(switches::kUIMaxFramesPending)) {
33 std::string string_value = command_line->GetSwitchValueASCII( 34 std::string string_value = command_line->GetSwitchValueASCII(
34 switches::kUIMaxFramesPending); 35 switches::kUIMaxFramesPending);
35 int int_value; 36 int int_value;
36 if (base::StringToInt(string_value, &int_value)) 37 if (base::StringToInt(string_value, &int_value))
(...skipping 26 matching lines...) Expand all
63 void BrowserCompositorOutputSurface::Reshape(gfx::Size size, 64 void BrowserCompositorOutputSurface::Reshape(gfx::Size size,
64 float scale_factor) { 65 float scale_factor) {
65 OutputSurface::Reshape(size, scale_factor); 66 OutputSurface::Reshape(size, scale_factor);
66 if (reflector_.get()) 67 if (reflector_.get())
67 reflector_->OnReshape(size); 68 reflector_->OnReshape(size);
68 } 69 }
69 70
70 void BrowserCompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { 71 void BrowserCompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
71 DCHECK(frame->gl_frame_data); 72 DCHECK(frame->gl_frame_data);
72 73
73 WebGraphicsContext3DCommandBufferImpl* command_buffer = 74 WebGraphicsContext3DCommandBufferImpl* command_buffer_context =
74 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d()); 75 static_cast<WebGraphicsContext3DCommandBufferImpl*>(
76 context_provider_->Context3d());
75 CommandBufferProxyImpl* command_buffer_proxy = 77 CommandBufferProxyImpl* command_buffer_proxy =
76 command_buffer->GetCommandBufferProxy(); 78 command_buffer_context->GetCommandBufferProxy();
77 DCHECK(command_buffer_proxy); 79 DCHECK(command_buffer_proxy);
78 context3d()->shallowFlushCHROMIUM(); 80 context_provider_->Context3d()->shallowFlushCHROMIUM();
79 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); 81 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info);
80 82
81 if (reflector_.get()) { 83 if (reflector_.get()) {
82 if (frame->gl_frame_data->sub_buffer_rect == 84 if (frame->gl_frame_data->sub_buffer_rect ==
83 gfx::Rect(frame->gl_frame_data->size)) 85 gfx::Rect(frame->gl_frame_data->size))
84 reflector_->OnSwapBuffers(); 86 reflector_->OnSwapBuffers();
85 else 87 else
86 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect); 88 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect);
87 } 89 }
88 90
(...skipping 10 matching lines...) Expand all
99 FROM_HERE, 101 FROM_HERE,
100 base::Bind(&ui::Compositor::OnUpdateVSyncParameters, 102 base::Bind(&ui::Compositor::OnUpdateVSyncParameters,
101 compositor_, timebase, interval)); 103 compositor_, timebase, interval));
102 } 104 }
103 105
104 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { 106 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) {
105 reflector_ = reflector; 107 reflector_ = reflector;
106 } 108 }
107 109
108 } // namespace content 110 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/aura/browser_compositor_output_surface.h ('k') | content/browser/aura/gpu_process_transport_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698