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

Side by Side Diff: ui/compositor/compositor.cc

Issue 10689108: Aura: Have ui::Layer implement WebKit::WebExternalTextureLayerClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable the test compositor instead. Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/compositor/compositor.h" 5 #include "ui/compositor/compositor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 settings.perTilePainting = 155 settings.perTilePainting =
156 command_line->HasSwitch(switches::kUIEnablePerTilePainting); 156 command_line->HasSwitch(switches::kUIEnablePerTilePainting);
157 #endif 157 #endif
158 158
159 host_.initialize(this, root_web_layer_, settings); 159 host_.initialize(this, root_web_layer_, settings);
160 host_.setSurfaceReady(); 160 host_.setSurfaceReady();
161 root_web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); 161 root_web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
162 } 162 }
163 163
164 Compositor::~Compositor() { 164 Compositor::~Compositor() {
165 // Clear out any pending callbacks.
166 didCommit();
piman 2012/07/12 17:42:27 Is this still needed? I figure by the time we get
jonathan.backer 2012/07/13 13:26:24 You're right. There's nothing special. We'll leave
167
165 // Don't call |CompositorDelegate::ScheduleDraw| from this point. 168 // Don't call |CompositorDelegate::ScheduleDraw| from this point.
166 delegate_ = NULL; 169 delegate_ = NULL;
167 // There's a cycle between |root_web_layer_| and |host_|, which results in 170 // There's a cycle between |root_web_layer_| and |host_|, which results in
168 // leaking and/or crashing. Explicitly set the root layer to NULL so the cycle 171 // leaking and/or crashing. Explicitly set the root layer to NULL so the cycle
169 // is broken. 172 // is broken.
170 host_.setRootLayer(NULL); 173 host_.setRootLayer(NULL);
171 if (root_layer_) 174 if (root_layer_)
172 root_layer_->SetCompositor(NULL); 175 root_layer_->SetCompositor(NULL);
176
177 // Stop all outstanding draws before telling the ContextFactory to tear
178 // down any contexts that the |host_| may rely upon.
179 host_.reset();
180
173 if (!test_compositor_enabled) 181 if (!test_compositor_enabled)
174 ContextFactory::GetInstance()->RemoveCompositor(this); 182 ContextFactory::GetInstance()->RemoveCompositor(this);
175 } 183 }
176 184
177 void Compositor::Initialize(bool use_thread) { 185 void Compositor::Initialize(bool use_thread) {
178 #if defined(WEBCOMPOSITOR_OWNS_SETTINGS) 186 #if defined(WEBCOMPOSITOR_OWNS_SETTINGS)
179 CommandLine* command_line = CommandLine::ForCurrentProcess(); 187 CommandLine* command_line = CommandLine::ForCurrentProcess();
180 // These settings must be applied before we initialize the compositor. 188 // These settings must be applied before we initialize the compositor.
181 WebKit::WebCompositor::setPartialSwapEnabled( 189 WebKit::WebCompositor::setPartialSwapEnabled(
182 command_line->HasSwitch(switches::kUIEnablePartialSwap)); 190 command_line->HasSwitch(switches::kUIEnablePartialSwap));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 293 }
286 294
287 void Compositor::RemoveObserver(CompositorObserver* observer) { 295 void Compositor::RemoveObserver(CompositorObserver* observer) {
288 observer_list_.RemoveObserver(observer); 296 observer_list_.RemoveObserver(observer);
289 } 297 }
290 298
291 bool Compositor::HasObserver(CompositorObserver* observer) { 299 bool Compositor::HasObserver(CompositorObserver* observer) {
292 return observer_list_.HasObserver(observer); 300 return observer_list_.HasObserver(observer);
293 } 301 }
294 302
303 bool Compositor::IsThreaded() const {
304 return g_compositor_thread != NULL;
305 }
306
295 void Compositor::OnSwapBuffersPosted() { 307 void Compositor::OnSwapBuffersPosted() {
296 swap_posted_ = true; 308 swap_posted_ = true;
297 } 309 }
298 310
299 void Compositor::OnSwapBuffersComplete() { 311 void Compositor::OnSwapBuffersComplete() {
300 DCHECK(swap_posted_); 312 DCHECK(swap_posted_);
301 swap_posted_ = false; 313 swap_posted_ = false;
302 NotifyEnd(); 314 NotifyEnd();
303 } 315 }
304 316
(...skipping 30 matching lines...) Expand all
335 test_context->Initialize(); 347 test_context->Initialize();
336 return test_context; 348 return test_context;
337 } else { 349 } else {
338 return ContextFactory::GetInstance()->CreateContext(this); 350 return ContextFactory::GetInstance()->CreateContext(this);
339 } 351 }
340 } 352 }
341 353
342 void Compositor::didRebindGraphicsContext(bool success) { 354 void Compositor::didRebindGraphicsContext(bool success) {
343 } 355 }
344 356
357 // Called once per draw in single-threaded compositor mode and potentially
358 // many times between draws in the multi-threaded compositor mode.
359 void Compositor::didCommit() {
360 FOR_EACH_OBSERVER(CompositorObserver,
361 observer_list_,
362 OnCompositingDidCommit(this));
363 }
364
345 void Compositor::didCommitAndDrawFrame() { 365 void Compositor::didCommitAndDrawFrame() {
346 // TODO(backer): Plumb through an earlier impl side will start. 366 // TODO(backer): Plumb through an earlier impl side will start.
347 if (g_compositor_thread) 367 if (g_compositor_thread)
348 FOR_EACH_OBSERVER(CompositorObserver, 368 FOR_EACH_OBSERVER(CompositorObserver,
349 observer_list_, 369 observer_list_,
350 OnCompositingWillStart(this)); 370 OnCompositingWillStart(this));
351 371
352 FOR_EACH_OBSERVER(CompositorObserver, 372 FOR_EACH_OBSERVER(CompositorObserver,
353 observer_list_, 373 observer_list_,
354 OnCompositingStarted(this)); 374 OnCompositingStarted(this));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 428
409 COMPOSITOR_EXPORT void DisableTestCompositor() { 429 COMPOSITOR_EXPORT void DisableTestCompositor() {
410 test_compositor_enabled = false; 430 test_compositor_enabled = false;
411 } 431 }
412 432
413 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { 433 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() {
414 return test_compositor_enabled; 434 return test_compositor_enabled;
415 } 435 }
416 436
417 } // namespace ui 437 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698