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

Side by Side Diff: content/browser/android/in_process/synchronous_compositor_impl.cc

Issue 266353003: aw: Ubercomp mega patch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/android/in_process/synchronous_compositor_impl.h" 5 #include "content/browser/android/in_process/synchronous_compositor_impl.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "cc/input/input_handler.h" 9 #include "cc/input/input_handler.h"
10 #include "content/browser/android/in_process/synchronous_compositor_factory_impl .h" 10 #include "content/browser/android/in_process/synchronous_compositor_factory_impl .h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 SynchronousCompositorImpl* SynchronousCompositorImpl::FromRoutingID( 60 SynchronousCompositorImpl* SynchronousCompositorImpl::FromRoutingID(
61 int routing_id) { 61 int routing_id) {
62 return FromID(GetInProcessRendererId(), routing_id); 62 return FromID(GetInProcessRendererId(), routing_id);
63 } 63 }
64 64
65 SynchronousCompositorImpl::SynchronousCompositorImpl(WebContents* contents) 65 SynchronousCompositorImpl::SynchronousCompositorImpl(WebContents* contents)
66 : compositor_client_(NULL), 66 : compositor_client_(NULL),
67 output_surface_(NULL), 67 output_surface_(NULL),
68 contents_(contents), 68 contents_(contents),
69 input_handler_(NULL) { 69 input_handler_(NULL),
70 weak_ptr_factory_(this) {
70 DCHECK(contents); 71 DCHECK(contents);
71 } 72 }
72 73
73 SynchronousCompositorImpl::~SynchronousCompositorImpl() { 74 SynchronousCompositorImpl::~SynchronousCompositorImpl() {
74 if (compositor_client_) 75 if (compositor_client_)
75 compositor_client_->DidDestroyCompositor(this); 76 compositor_client_->DidDestroyCompositor(this);
76 SetInputHandler(NULL); 77 SetInputHandler(NULL);
77 } 78 }
78 79
79 void SynchronousCompositorImpl::SetClient( 80 void SynchronousCompositorImpl::SetClient(
(...skipping 28 matching lines...) Expand all
108 DCHECK(output_surface_); 109 DCHECK(output_surface_);
109 output_surface_->ReleaseHwDraw(); 110 output_surface_->ReleaseHwDraw();
110 g_factory.Get().CompositorReleasedHardwareDraw(); 111 g_factory.Get().CompositorReleasedHardwareDraw();
111 } 112 }
112 113
113 bool SynchronousCompositorImpl::DemandDrawHw( 114 bool SynchronousCompositorImpl::DemandDrawHw(
114 gfx::Size surface_size, 115 gfx::Size surface_size,
115 const gfx::Transform& transform, 116 const gfx::Transform& transform,
116 gfx::Rect viewport, 117 gfx::Rect viewport,
117 gfx::Rect clip, 118 gfx::Rect clip,
118 bool stencil_enabled) { 119 bool stencil_enabled,
120 cc::CompositorFrame* frame) {
119 DCHECK(CalledOnValidThread()); 121 DCHECK(CalledOnValidThread());
120 DCHECK(output_surface_); 122 DCHECK(output_surface_);
123 DCHECK(frame);
121 124
122 return output_surface_->DemandDrawHw( 125 bool result = output_surface_->DemandDrawHw(
123 surface_size, transform, viewport, clip, stencil_enabled); 126 surface_size, transform, viewport, clip, stencil_enabled, frame);
127 if (result)
128 UpdateFrameMetaData(frame->metadata);
129 return result;
124 } 130 }
125 131
126 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { 132 bool SynchronousCompositorImpl::DemandDrawDelegated(
133 const gfx::Transform& transform,
134 gfx::Rect viewport,
135 gfx::Rect clip,
136 cc::CompositorFrame* frame) {
127 DCHECK(CalledOnValidThread()); 137 DCHECK(CalledOnValidThread());
128 DCHECK(output_surface_); 138 DCHECK(output_surface_);
139 DCHECK(frame);
129 140
130 return output_surface_->DemandDrawSw(canvas); 141 bool result =
142 output_surface_->DemandDrawDelegated(transform, viewport, clip, frame);
143 if (result)
144 UpdateFrameMetaData(frame->metadata);
145 return result;
146 }
147
148 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas,
149 cc::CompositorFrame* frame) {
150 DCHECK(CalledOnValidThread());
151 DCHECK(output_surface_);
152 DCHECK(frame);
153
154 bool result = output_surface_->DemandDrawSw(canvas, frame);
155 if (result)
156 UpdateFrameMetaData(frame->metadata);
157 return result;
158 }
159
160 void SynchronousCompositorImpl::ReturnResources(
161 const cc::CompositorFrameAck* frame_ack) {
162 output_surface_->ReturnResources(frame_ack);
163 }
164
165 void SynchronousCompositorImpl::UpdateFrameMetaData(
166 const cc::CompositorFrameMetadata& frame_metadata) {
167 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
168 BrowserThread::PostTask(
169 BrowserThread::UI,
170 FROM_HERE,
171 base::Bind(&SynchronousCompositorImpl::UpdateFrameMetaData,
172 weak_ptr_factory_.GetWeakPtr(),
173 frame_metadata));
174 return;
175 }
176 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>(
177 contents_->GetRenderWidgetHostView());
178 if (rwhv)
179 rwhv->SynchronousFrameMetadata(frame_metadata);
131 } 180 }
132 181
133 void SynchronousCompositorImpl::SetMemoryPolicy( 182 void SynchronousCompositorImpl::SetMemoryPolicy(
134 const SynchronousCompositorMemoryPolicy& policy) { 183 const SynchronousCompositorMemoryPolicy& policy) {
135 DCHECK(CalledOnValidThread()); 184 DCHECK(CalledOnValidThread());
136 DCHECK(output_surface_); 185 DCHECK(output_surface_);
137 186
138 output_surface_->SetMemoryPolicy(policy); 187 output_surface_->SetMemoryPolicy(policy);
139 } 188 }
140 189
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 compositor_client_->SetContinuousInvalidate(enable); 249 compositor_client_->SetContinuousInvalidate(enable);
201 } 250 }
202 251
203 InputEventAckState SynchronousCompositorImpl::HandleInputEvent( 252 InputEventAckState SynchronousCompositorImpl::HandleInputEvent(
204 const blink::WebInputEvent& input_event) { 253 const blink::WebInputEvent& input_event) {
205 DCHECK(CalledOnValidThread()); 254 DCHECK(CalledOnValidThread());
206 return g_factory.Get().synchronous_input_event_filter()->HandleInputEvent( 255 return g_factory.Get().synchronous_input_event_filter()->HandleInputEvent(
207 contents_->GetRoutingID(), input_event); 256 contents_->GetRoutingID(), input_event);
208 } 257 }
209 258
210 void SynchronousCompositorImpl::UpdateFrameMetaData(
211 const cc::CompositorFrameMetadata& frame_metadata) {
212 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>(
213 contents_->GetRenderWidgetHostView());
214 if (rwhv)
215 rwhv->SynchronousFrameMetadata(frame_metadata);
216 }
217
218 void SynchronousCompositorImpl::DidActivatePendingTree() { 259 void SynchronousCompositorImpl::DidActivatePendingTree() {
219 if (compositor_client_) 260 if (compositor_client_)
220 compositor_client_->DidUpdateContent(); 261 compositor_client_->DidUpdateContent();
221 } 262 }
222 263
223 gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() { 264 gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() {
224 DCHECK(CalledOnValidThread()); 265 DCHECK(CalledOnValidThread());
225 if (compositor_client_) 266 if (compositor_client_)
226 return compositor_client_->GetTotalRootLayerScrollOffset(); 267 return compositor_client_->GetTotalRootLayerScrollOffset();
227 return gfx::Vector2dF(); 268 return gfx::Vector2dF();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (client) { 308 if (client) {
268 g_factory.Get(); // Ensure it's initialized. 309 g_factory.Get(); // Ensure it's initialized.
269 SynchronousCompositorImpl::CreateForWebContents(contents); 310 SynchronousCompositorImpl::CreateForWebContents(contents);
270 } 311 }
271 if (SynchronousCompositorImpl* instance = 312 if (SynchronousCompositorImpl* instance =
272 SynchronousCompositorImpl::FromWebContents(contents)) { 313 SynchronousCompositorImpl::FromWebContents(contents)) {
273 instance->SetClient(client); 314 instance->SetClient(client);
274 } 315 }
275 } 316 }
276 317
318 // static
319 SynchronousCompositorFactoryImpl* SynchronousCompositor::GetFactory() {
320 return g_factory.Pointer();
321 }
322
277 } // namespace content 323 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698