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

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

Issue 22935009: Add content::SurfaceCapturer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screencast_stride
Patch Set: 89e2665f Rebase. 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
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/browser_compositor_output_surface_capturer.h"
13 #include "content/browser/aura/reflector_impl.h" 14 #include "content/browser/aura/reflector_impl.h"
14 #include "content/common/gpu/client/context_provider_command_buffer.h" 15 #include "content/common/gpu/client/context_provider_command_buffer.h"
15 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 16 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
16 #include "ui/compositor/compositor.h" 17 #include "ui/compositor/compositor.h"
17 #include "ui/compositor/compositor_switches.h" 18 #include "ui/compositor/compositor_switches.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( 22 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
22 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, 23 const scoped_refptr<ContextProviderCommandBuffer>& context_provider,
23 int surface_id, 24 int surface_id,
24 IDMap<BrowserCompositorOutputSurface>* output_surface_map, 25 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
25 base::MessageLoopProxy* compositor_message_loop, 26 const scoped_refptr<base::MessageLoopProxy>& compositor_message_loop,
26 base::WeakPtr<ui::Compositor> compositor) 27 base::WeakPtr<ui::Compositor> compositor)
27 : OutputSurface(context_provider), 28 : OutputSurface(context_provider),
28 surface_id_(surface_id), 29 surface_id_(surface_id),
29 output_surface_map_(output_surface_map), 30 output_surface_map_(output_surface_map),
30 compositor_message_loop_(compositor_message_loop), 31 compositor_message_loop_(compositor_message_loop),
31 compositor_(compositor) { 32 compositor_(compositor) {
32 CommandLine* command_line = CommandLine::ForCurrentProcess(); 33 CommandLine* command_line = CommandLine::ForCurrentProcess();
33 if (command_line->HasSwitch(switches::kUIMaxFramesPending)) { 34 if (command_line->HasSwitch(switches::kUIMaxFramesPending)) {
34 std::string string_value = command_line->GetSwitchValueASCII( 35 std::string string_value = command_line->GetSwitchValueASCII(
35 switches::kUIMaxFramesPending); 36 switches::kUIMaxFramesPending);
36 int int_value; 37 int int_value;
37 if (base::StringToInt(string_value, &int_value)) 38 if (base::StringToInt(string_value, &int_value))
38 capabilities_.max_frames_pending = int_value; 39 capabilities_.max_frames_pending = int_value;
39 else 40 else
40 LOG(ERROR) << "Trouble parsing --" << switches::kUIMaxFramesPending; 41 LOG(ERROR) << "Trouble parsing --" << switches::kUIMaxFramesPending;
41 } 42 }
42 capabilities_.adjust_deadline_for_parent = false; 43 capabilities_.adjust_deadline_for_parent = false;
43 DetachFromThread(); 44 DetachFromThread();
44 } 45 }
45 46
46 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { 47 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() {
47 DCHECK(CalledOnValidThread()); 48 DCHECK(CalledOnValidThread());
48 if (!HasClient()) 49 if (!HasClient())
49 return; 50 return;
50 output_surface_map_->Remove(surface_id_); 51 output_surface_map_->Remove(surface_id_);
52 // Don't delete the actual object; we don't own it.
53 FOR_EACH_OBSERVER(BrowserCompositorOutputSurfaceCapturer,
54 capturer_list_,
55 DoDestroyOnImplThread());
51 } 56 }
52 57
53 bool BrowserCompositorOutputSurface::BindToClient( 58 bool BrowserCompositorOutputSurface::BindToClient(
54 cc::OutputSurfaceClient* client) { 59 cc::OutputSurfaceClient* client) {
55 DCHECK(CalledOnValidThread()); 60 DCHECK(CalledOnValidThread());
56 61
57 if (!OutputSurface::BindToClient(client)) 62 if (!OutputSurface::BindToClient(client))
58 return false; 63 return false;
59 64
60 output_surface_map_->AddWithID(this, surface_id_); 65 output_surface_map_->AddWithID(this, surface_id_);
(...skipping 12 matching lines...) Expand all
73 78
74 WebGraphicsContext3DCommandBufferImpl* command_buffer_context = 79 WebGraphicsContext3DCommandBufferImpl* command_buffer_context =
75 static_cast<WebGraphicsContext3DCommandBufferImpl*>( 80 static_cast<WebGraphicsContext3DCommandBufferImpl*>(
76 context_provider_->Context3d()); 81 context_provider_->Context3d());
77 CommandBufferProxyImpl* command_buffer_proxy = 82 CommandBufferProxyImpl* command_buffer_proxy =
78 command_buffer_context->GetCommandBufferProxy(); 83 command_buffer_context->GetCommandBufferProxy();
79 DCHECK(command_buffer_proxy); 84 DCHECK(command_buffer_proxy);
80 context_provider_->Context3d()->shallowFlushCHROMIUM(); 85 context_provider_->Context3d()->shallowFlushCHROMIUM();
81 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); 86 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info);
82 87
88 FOR_EACH_OBSERVER(BrowserCompositorOutputSurfaceCapturer,
89 capturer_list_,
90 NotifySwapBuffersOnImplThread());
91
83 if (reflector_.get()) { 92 if (reflector_.get()) {
84 if (frame->gl_frame_data->sub_buffer_rect == 93 if (frame->gl_frame_data->sub_buffer_rect ==
85 gfx::Rect(frame->gl_frame_data->size)) 94 gfx::Rect(frame->gl_frame_data->size))
86 reflector_->OnSwapBuffers(); 95 reflector_->OnSwapBuffers();
87 else 96 else
88 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect); 97 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect);
89 } 98 }
90 99
91 OutputSurface::SwapBuffers(frame); 100 OutputSurface::SwapBuffers(frame);
92 } 101 }
93 102
94 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( 103 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters(
95 base::TimeTicks timebase, 104 base::TimeTicks timebase,
96 base::TimeDelta interval) { 105 base::TimeDelta interval) {
97 DCHECK(CalledOnValidThread()); 106 DCHECK(CalledOnValidThread());
98 DCHECK(HasClient()); 107 DCHECK(HasClient());
99 OnVSyncParametersChanged(timebase, interval); 108 OnVSyncParametersChanged(timebase, interval);
100 compositor_message_loop_->PostTask( 109 compositor_message_loop_->PostTask(
101 FROM_HERE, 110 FROM_HERE,
102 base::Bind(&ui::Compositor::OnUpdateVSyncParameters, 111 base::Bind(&ui::Compositor::OnUpdateVSyncParameters,
103 compositor_, timebase, interval)); 112 compositor_, timebase, interval));
104 } 113 }
105 114
106 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { 115 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) {
107 reflector_ = reflector; 116 reflector_ = reflector;
108 } 117 }
109 118
119 void BrowserCompositorOutputSurface::AddCapturer(
120 BrowserCompositorOutputSurfaceCapturer* capturer) {
121 DCHECK(CalledOnValidThread());
122 capturer_list_.AddObserver(capturer);
123 }
124
125 void BrowserCompositorOutputSurface::RemoveCapturer(
126 BrowserCompositorOutputSurfaceCapturer* capturer) {
127 DCHECK(CalledOnValidThread());
128 capturer_list_.RemoveObserver(capturer);
129 }
130
110 } // namespace content 131 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698