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

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

Issue 10453117: Tighter sync and faster ACK on SwapBuffers/PostSubBuffers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 6 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoin t.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoin t.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 Texture::~Texture() { 124 Texture::~Texture() {
125 } 125 }
126 126
127 Compositor::Compositor(CompositorDelegate* delegate, 127 Compositor::Compositor(CompositorDelegate* delegate,
128 gfx::AcceleratedWidget widget) 128 gfx::AcceleratedWidget widget)
129 : delegate_(delegate), 129 : delegate_(delegate),
130 root_layer_(NULL), 130 root_layer_(NULL),
131 widget_(widget), 131 widget_(widget),
132 root_web_layer_(WebKit::WebLayer::create()), 132 root_web_layer_(WebKit::WebLayer::create()),
133 swap_posted_(false), 133 swap_posted_(false),
134 device_scale_factor_(0.0f) { 134 device_scale_factor_(0.0f),
135 last_started_id_(0),
136 last_will_end_id_(0),
137 last_ended_id_(0) {
135 WebKit::WebLayerTreeView::Settings settings; 138 WebKit::WebLayerTreeView::Settings settings;
136 CommandLine* command_line = CommandLine::ForCurrentProcess(); 139 CommandLine* command_line = CommandLine::ForCurrentProcess();
137 settings.showFPSCounter = 140 settings.showFPSCounter =
138 command_line->HasSwitch(switches::kUIShowFPSCounter); 141 command_line->HasSwitch(switches::kUIShowFPSCounter);
139 settings.showPlatformLayerTree = 142 settings.showPlatformLayerTree =
140 command_line->HasSwitch(switches::kUIShowLayerTree); 143 command_line->HasSwitch(switches::kUIShowLayerTree);
141 settings.refreshRate = test_compositor_enabled ? 144 settings.refreshRate = test_compositor_enabled ?
142 kTestRefreshRate : kDefaultRefreshRate; 145 kTestRefreshRate : kDefaultRefreshRate;
143 settings.partialSwapEnabled = 146 settings.partialSwapEnabled =
144 command_line->HasSwitch(switches::kUIEnablePartialSwap); 147 command_line->HasSwitch(switches::kUIEnablePartialSwap);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 root_layer_->SetCompositor(this); 200 root_layer_->SetCompositor(this);
198 root_web_layer_.removeAllChildren(); 201 root_web_layer_.removeAllChildren();
199 if (root_layer_) 202 if (root_layer_)
200 root_web_layer_.addChild(root_layer_->web_layer()); 203 root_web_layer_.addChild(root_layer_->web_layer());
201 } 204 }
202 205
203 void Compositor::Draw(bool force_clear) { 206 void Compositor::Draw(bool force_clear) {
204 if (!root_layer_) 207 if (!root_layer_)
205 return; 208 return;
206 209
210 last_started_id_++;
211
207 // TODO(nduca): Temporary while compositor calls 212 // TODO(nduca): Temporary while compositor calls
208 // compositeImmediately() directly. 213 // compositeImmediately() directly.
209 layout(); 214 layout();
210 host_.composite(); 215 host_.composite();
216
217 last_will_end_id_++;
218 FOR_EACH_OBSERVER(CompositorObserver,
219 observer_list_,
220 OnCompositingWillEnd(this));
221
211 if (!g_compositor_thread && !swap_posted_) 222 if (!g_compositor_thread && !swap_posted_)
212 NotifyEnd(); 223 NotifyEnd();
213 } 224 }
214 225
215 void Compositor::ScheduleFullDraw() { 226 void Compositor::ScheduleFullDraw() {
216 host_.setNeedsRedraw(); 227 host_.setNeedsRedraw();
217 } 228 }
218 229
219 bool Compositor::ReadPixels(SkBitmap* bitmap, 230 bool Compositor::ReadPixels(SkBitmap* bitmap,
220 const gfx::Rect& bounds_in_pixel) { 231 const gfx::Rect& bounds_in_pixel) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 memcpy(&pixels[row * row_size], 351 memcpy(&pixels[row * row_size],
341 &pixels[bitmap_size - (row + 1) * row_size], 352 &pixels[bitmap_size - (row + 1) * row_size],
342 row_size); 353 row_size);
343 memcpy(&pixels[bitmap_size - (row + 1) * row_size], 354 memcpy(&pixels[bitmap_size - (row + 1) * row_size],
344 tmp_row.get(), 355 tmp_row.get(),
345 row_size); 356 row_size);
346 } 357 }
347 } 358 }
348 359
349 void Compositor::NotifyEnd() { 360 void Compositor::NotifyEnd() {
361 last_ended_id_++;
350 FOR_EACH_OBSERVER(CompositorObserver, 362 FOR_EACH_OBSERVER(CompositorObserver,
351 observer_list_, 363 observer_list_,
352 OnCompositingEnded(this)); 364 OnCompositingEnded(this));
353 } 365 }
354 366
355 COMPOSITOR_EXPORT void SetupTestCompositor() { 367 COMPOSITOR_EXPORT void SetupTestCompositor() {
356 if (!CommandLine::ForCurrentProcess()->HasSwitch( 368 if (!CommandLine::ForCurrentProcess()->HasSwitch(
357 switches::kDisableTestCompositor)) { 369 switches::kDisableTestCompositor)) {
358 test_compositor_enabled = true; 370 test_compositor_enabled = true;
359 } 371 }
360 #if defined(OS_CHROMEOS) 372 #if defined(OS_CHROMEOS)
361 // If the test is running on the chromeos envrionment (such as 373 // If the test is running on the chromeos envrionment (such as
362 // device or vm bots), use the real compositor. 374 // device or vm bots), use the real compositor.
363 if (base::chromeos::IsRunningOnChromeOS()) 375 if (base::chromeos::IsRunningOnChromeOS())
364 test_compositor_enabled = false; 376 test_compositor_enabled = false;
365 #endif 377 #endif
366 } 378 }
367 379
368 COMPOSITOR_EXPORT void DisableTestCompositor() { 380 COMPOSITOR_EXPORT void DisableTestCompositor() {
369 test_compositor_enabled = false; 381 test_compositor_enabled = false;
370 } 382 }
371 383
372 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { 384 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() {
373 return test_compositor_enabled; 385 return test_compositor_enabled;
374 } 386 }
375 387
376 } // namespace ui 388 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698