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

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

Issue 57883007: Adding support for VSyncProvider to the software drawing path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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"
13 #include "content/browser/aura/reflector_impl.h" 12 #include "content/browser/aura/reflector_impl.h"
14 #include "content/common/gpu/client/context_provider_command_buffer.h" 13 #include "content/common/gpu/client/context_provider_command_buffer.h"
15 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
16 #include "ui/compositor/compositor.h" 14 #include "ui/compositor/compositor.h"
17 #include "ui/compositor/compositor_switches.h" 15 #include "ui/compositor/compositor_switches.h"
18 16
19 namespace content { 17 namespace content {
20 18
21 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( 19 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
22 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, 20 const scoped_refptr<ContextProviderCommandBuffer>& context_provider,
23 int surface_id, 21 int surface_id,
24 IDMap<BrowserCompositorOutputSurface>* output_surface_map, 22 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
25 base::MessageLoopProxy* compositor_message_loop, 23 base::MessageLoopProxy* compositor_message_loop,
26 base::WeakPtr<ui::Compositor> compositor) 24 base::WeakPtr<ui::Compositor> compositor)
27 : OutputSurface(context_provider), 25 : OutputSurface(context_provider),
28 surface_id_(surface_id), 26 surface_id_(surface_id),
29 output_surface_map_(output_surface_map), 27 output_surface_map_(output_surface_map),
30 compositor_message_loop_(compositor_message_loop), 28 compositor_message_loop_(compositor_message_loop),
31 compositor_(compositor) { 29 compositor_(compositor) {
30 Initialize();
31 DetachFromThread();
32 }
33
34 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
35 scoped_ptr<cc::SoftwareOutputDevice> software_device,
36 int surface_id,
37 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
38 base::MessageLoopProxy* compositor_message_loop,
39 base::WeakPtr<ui::Compositor> compositor)
40 : OutputSurface(software_device.Pass()),
41 surface_id_(surface_id),
42 output_surface_map_(output_surface_map),
43 compositor_message_loop_(compositor_message_loop),
44 compositor_(compositor) {
45 Initialize();
piman 2013/11/07 20:37:16 nit: DetachFromThread here too - if/when software
dnicoara 2013/11/07 21:03:16 Done.
46 }
47
48 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() {
49 DCHECK(CalledOnValidThread());
50 if (!HasClient())
51 return;
52 output_surface_map_->Remove(surface_id_);
53 }
54
55 void BrowserCompositorOutputSurface::Initialize() {
32 CommandLine* command_line = CommandLine::ForCurrentProcess(); 56 CommandLine* command_line = CommandLine::ForCurrentProcess();
33 if (command_line->HasSwitch(switches::kUIMaxFramesPending)) { 57 if (command_line->HasSwitch(switches::kUIMaxFramesPending)) {
34 std::string string_value = command_line->GetSwitchValueASCII( 58 std::string string_value = command_line->GetSwitchValueASCII(
35 switches::kUIMaxFramesPending); 59 switches::kUIMaxFramesPending);
36 int int_value; 60 int int_value;
37 if (base::StringToInt(string_value, &int_value)) 61 if (base::StringToInt(string_value, &int_value))
38 capabilities_.max_frames_pending = int_value; 62 capabilities_.max_frames_pending = int_value;
39 else 63 else
40 LOG(ERROR) << "Trouble parsing --" << switches::kUIMaxFramesPending; 64 LOG(ERROR) << "Trouble parsing --" << switches::kUIMaxFramesPending;
41 } 65 }
42 capabilities_.adjust_deadline_for_parent = false; 66 capabilities_.adjust_deadline_for_parent = false;
43 DetachFromThread();
44 }
45
46 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() {
47 DCHECK(CalledOnValidThread());
48 if (!HasClient())
49 return;
50 output_surface_map_->Remove(surface_id_);
51 } 67 }
52 68
53 bool BrowserCompositorOutputSurface::BindToClient( 69 bool BrowserCompositorOutputSurface::BindToClient(
54 cc::OutputSurfaceClient* client) { 70 cc::OutputSurfaceClient* client) {
55 DCHECK(CalledOnValidThread()); 71 DCHECK(CalledOnValidThread());
56 72
57 if (!OutputSurface::BindToClient(client)) 73 if (!OutputSurface::BindToClient(client))
58 return false; 74 return false;
59 75
60 output_surface_map_->AddWithID(this, surface_id_); 76 output_surface_map_->AddWithID(this, surface_id_);
61 if (reflector_) 77 if (reflector_)
62 reflector_->OnSourceSurfaceReady(surface_id_); 78 reflector_->OnSourceSurfaceReady(surface_id_);
63 return true; 79 return true;
64 } 80 }
65 81
66 void BrowserCompositorOutputSurface::Reshape(gfx::Size size, 82 void BrowserCompositorOutputSurface::Reshape(gfx::Size size,
67 float scale_factor) { 83 float scale_factor) {
68 OutputSurface::Reshape(size, scale_factor); 84 OutputSurface::Reshape(size, scale_factor);
69 if (reflector_.get()) 85 if (reflector_.get())
70 reflector_->OnReshape(size); 86 reflector_->OnReshape(size);
71 } 87 }
72 88
73 void BrowserCompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
74 DCHECK(frame->gl_frame_data);
75
76 WebGraphicsContext3DCommandBufferImpl* command_buffer_context =
77 static_cast<WebGraphicsContext3DCommandBufferImpl*>(
78 context_provider_->Context3d());
79 CommandBufferProxyImpl* command_buffer_proxy =
80 command_buffer_context->GetCommandBufferProxy();
81 DCHECK(command_buffer_proxy);
82 context_provider_->Context3d()->shallowFlushCHROMIUM();
83 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info);
84
85 if (reflector_.get()) {
86 if (frame->gl_frame_data->sub_buffer_rect ==
87 gfx::Rect(frame->gl_frame_data->size))
88 reflector_->OnSwapBuffers();
89 else
90 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect);
91 }
92
93 OutputSurface::SwapBuffers(frame);
94 }
95
96 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( 89 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters(
97 base::TimeTicks timebase, 90 base::TimeTicks timebase,
98 base::TimeDelta interval) { 91 base::TimeDelta interval) {
99 DCHECK(CalledOnValidThread()); 92 DCHECK(CalledOnValidThread());
100 DCHECK(HasClient()); 93 DCHECK(HasClient());
101 OnVSyncParametersChanged(timebase, interval); 94 OnVSyncParametersChanged(timebase, interval);
102 compositor_message_loop_->PostTask( 95 compositor_message_loop_->PostTask(
103 FROM_HERE, 96 FROM_HERE,
104 base::Bind(&ui::Compositor::OnUpdateVSyncParameters, 97 base::Bind(&ui::Compositor::OnUpdateVSyncParameters,
105 compositor_, timebase, interval)); 98 compositor_, timebase, interval));
106 } 99 }
107 100
108 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { 101 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) {
109 reflector_ = reflector; 102 reflector_ = reflector;
110 } 103 }
111 104
112 } // namespace content 105 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698