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

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

Issue 10873073: Remove transitional WEBLAYERTREEVIEW_IS_PURE_VIRTUAL guarded code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 3 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
« no previous file with comments | « ui/compositor/compositor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 WebKit::WebLayerTreeView::Settings settings; 147 WebKit::WebLayerTreeView::Settings settings;
148 CommandLine* command_line = CommandLine::ForCurrentProcess(); 148 CommandLine* command_line = CommandLine::ForCurrentProcess();
149 settings.showFPSCounter = 149 settings.showFPSCounter =
150 command_line->HasSwitch(switches::kUIShowFPSCounter); 150 command_line->HasSwitch(switches::kUIShowFPSCounter);
151 settings.showPlatformLayerTree = 151 settings.showPlatformLayerTree =
152 command_line->HasSwitch(switches::kUIShowLayerTree); 152 command_line->HasSwitch(switches::kUIShowLayerTree);
153 settings.refreshRate = 153 settings.refreshRate =
154 test_compositor_enabled ? kTestRefreshRate : kDefaultRefreshRate; 154 test_compositor_enabled ? kTestRefreshRate : kDefaultRefreshRate;
155 155
156 root_web_layer_->setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); 156 root_web_layer_->setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
157 #if defined(WEBLAYERTREEVIEW_IS_PURE_VIRTUAL)
158 host_.reset(WebKit::WebLayerTreeView::create(this, *root_web_layer_, 157 host_.reset(WebKit::WebLayerTreeView::create(this, *root_web_layer_,
159 settings)); 158 settings));
160 host_->setSurfaceReady(); 159 host_->setSurfaceReady();
161 #else
162 host_.initialize(this, *root_web_layer_, settings);
163 host_.setSurfaceReady();
164 #endif
165 } 160 }
166 161
167 Compositor::~Compositor() { 162 Compositor::~Compositor() {
168 // Don't call |CompositorDelegate::ScheduleDraw| from this point. 163 // Don't call |CompositorDelegate::ScheduleDraw| from this point.
169 delegate_ = NULL; 164 delegate_ = NULL;
170 if (root_layer_) 165 if (root_layer_)
171 root_layer_->SetCompositor(NULL); 166 root_layer_->SetCompositor(NULL);
172 167
173 // Stop all outstanding draws before telling the ContextFactory to tear 168 // Stop all outstanding draws before telling the ContextFactory to tear
174 // down any contexts that the |host_| may rely upon. 169 // down any contexts that the |host_| may rely upon.
(...skipping 21 matching lines...) Expand all
196 delete g_compositor_thread; 191 delete g_compositor_thread;
197 g_compositor_thread = NULL; 192 g_compositor_thread = NULL;
198 } 193 }
199 } 194 }
200 195
201 void Compositor::ScheduleDraw() { 196 void Compositor::ScheduleDraw() {
202 if (g_compositor_thread) { 197 if (g_compositor_thread) {
203 // TODO(nduca): Temporary while compositor calls 198 // TODO(nduca): Temporary while compositor calls
204 // compositeImmediately() directly. 199 // compositeImmediately() directly.
205 layout(); 200 layout();
206 #if defined(WEBLAYERTREEVIEW_IS_PURE_VIRTUAL)
207 host_->composite(); 201 host_->composite();
208 #else
209 host_.composite();
210 #endif
211 } else if (delegate_) { 202 } else if (delegate_) {
212 delegate_->ScheduleDraw(); 203 delegate_->ScheduleDraw();
213 } 204 }
214 } 205 }
215 206
216 void Compositor::SetRootLayer(Layer* root_layer) { 207 void Compositor::SetRootLayer(Layer* root_layer) {
217 if (root_layer_ == root_layer) 208 if (root_layer_ == root_layer)
218 return; 209 return;
219 if (root_layer_) 210 if (root_layer_)
220 root_layer_->SetCompositor(NULL); 211 root_layer_->SetCompositor(NULL);
(...skipping 11 matching lines...) Expand all
232 223
233 last_started_frame_++; 224 last_started_frame_++;
234 if (!g_compositor_thread) 225 if (!g_compositor_thread)
235 FOR_EACH_OBSERVER(CompositorObserver, 226 FOR_EACH_OBSERVER(CompositorObserver,
236 observer_list_, 227 observer_list_,
237 OnCompositingWillStart(this)); 228 OnCompositingWillStart(this));
238 229
239 // TODO(nduca): Temporary while compositor calls 230 // TODO(nduca): Temporary while compositor calls
240 // compositeImmediately() directly. 231 // compositeImmediately() directly.
241 layout(); 232 layout();
242 #if defined(WEBLAYERTREEVIEW_IS_PURE_VIRTUAL)
243 host_->composite(); 233 host_->composite();
244 #else
245 host_.composite();
246 #endif
247 if (!g_compositor_thread && !swap_posted_) 234 if (!g_compositor_thread && !swap_posted_)
248 NotifyEnd(); 235 NotifyEnd();
249 } 236 }
250 237
251 void Compositor::ScheduleFullDraw() { 238 void Compositor::ScheduleFullDraw() {
252 #if defined(WEBLAYERTREEVIEW_IS_PURE_VIRTUAL)
253 host_->setNeedsRedraw(); 239 host_->setNeedsRedraw();
254 #else
255 host_.setNeedsRedraw();
256 #endif
257 } 240 }
258 241
259 bool Compositor::ReadPixels(SkBitmap* bitmap, 242 bool Compositor::ReadPixels(SkBitmap* bitmap,
260 const gfx::Rect& bounds_in_pixel) { 243 const gfx::Rect& bounds_in_pixel) {
261 if (bounds_in_pixel.right() > size().width() || 244 if (bounds_in_pixel.right() > size().width() ||
262 bounds_in_pixel.bottom() > size().height()) 245 bounds_in_pixel.bottom() > size().height())
263 return false; 246 return false;
264 // Convert to OpenGL coordinates. 247 // Convert to OpenGL coordinates.
265 gfx::Point new_origin( 248 gfx::Point new_origin(
266 bounds_in_pixel.x(), 249 bounds_in_pixel.x(),
267 size().height() - bounds_in_pixel.height() - bounds_in_pixel.y()); 250 size().height() - bounds_in_pixel.height() - bounds_in_pixel.y());
268 251
269 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 252 bitmap->setConfig(SkBitmap::kARGB_8888_Config,
270 bounds_in_pixel.width(), bounds_in_pixel.height()); 253 bounds_in_pixel.width(), bounds_in_pixel.height());
271 bitmap->allocPixels(); 254 bitmap->allocPixels();
272 SkAutoLockPixels lock_image(*bitmap); 255 SkAutoLockPixels lock_image(*bitmap);
273 unsigned char* pixels = static_cast<unsigned char*>(bitmap->getPixels()); 256 unsigned char* pixels = static_cast<unsigned char*>(bitmap->getPixels());
274 #if defined(WEBLAYERTREEVIEW_IS_PURE_VIRTUAL)
275 if (host_->compositeAndReadback( 257 if (host_->compositeAndReadback(
276 #else
277 if (host_.compositeAndReadback(
278 #endif
279 pixels, gfx::Rect(new_origin, bounds_in_pixel.size()))) { 258 pixels, gfx::Rect(new_origin, bounds_in_pixel.size()))) {
280 SwizzleRGBAToBGRAAndFlip(pixels, bounds_in_pixel.size()); 259 SwizzleRGBAToBGRAAndFlip(pixels, bounds_in_pixel.size());
281 return true; 260 return true;
282 } 261 }
283 return false; 262 return false;
284 } 263 }
285 264
286 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { 265 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) {
287 DCHECK_GT(scale, 0); 266 DCHECK_GT(scale, 0);
288 if (size_in_pixel.IsEmpty() || scale <= 0) 267 if (size_in_pixel.IsEmpty() || scale <= 0)
289 return; 268 return;
290 size_ = size_in_pixel; 269 size_ = size_in_pixel;
291 #if defined(WEBLAYERTREEVIEW_IS_PURE_VIRTUAL)
292 host_->setViewportSize(size_in_pixel); 270 host_->setViewportSize(size_in_pixel);
293 #else
294 host_.setViewportSize(size_in_pixel);
295 #endif
296 root_web_layer_->setBounds(size_in_pixel); 271 root_web_layer_->setBounds(size_in_pixel);
297 272
298 if (device_scale_factor_ != scale) { 273 if (device_scale_factor_ != scale) {
299 device_scale_factor_ = scale; 274 device_scale_factor_ = scale;
300 if (root_layer_) 275 if (root_layer_)
301 root_layer_->OnDeviceScaleFactorChanged(scale); 276 root_layer_->OnDeviceScaleFactorChanged(scale);
302 } 277 }
303 } 278 }
304 279
305 void Compositor::AddObserver(CompositorObserver* observer) { 280 void Compositor::AddObserver(CompositorObserver* observer) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 460
486 COMPOSITOR_EXPORT void DisableTestCompositor() { 461 COMPOSITOR_EXPORT void DisableTestCompositor() {
487 test_compositor_enabled = false; 462 test_compositor_enabled = false;
488 } 463 }
489 464
490 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { 465 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() {
491 return test_compositor_enabled; 466 return test_compositor_enabled;
492 } 467 }
493 468
494 } // namespace ui 469 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698