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

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

Issue 10831396: Remove transitional WEBLAYER_IS_PURE_VIRTUAL code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/layer.h » ('j') | 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 disable_schedule_composite_(false) { 143 disable_schedule_composite_(false) {
144 WebKit::WebLayerTreeView::Settings settings; 144 WebKit::WebLayerTreeView::Settings settings;
145 CommandLine* command_line = CommandLine::ForCurrentProcess(); 145 CommandLine* command_line = CommandLine::ForCurrentProcess();
146 settings.showFPSCounter = 146 settings.showFPSCounter =
147 command_line->HasSwitch(switches::kUIShowFPSCounter); 147 command_line->HasSwitch(switches::kUIShowFPSCounter);
148 settings.showPlatformLayerTree = 148 settings.showPlatformLayerTree =
149 command_line->HasSwitch(switches::kUIShowLayerTree); 149 command_line->HasSwitch(switches::kUIShowLayerTree);
150 settings.refreshRate = 150 settings.refreshRate =
151 test_compositor_enabled ? kTestRefreshRate : kDefaultRefreshRate; 151 test_compositor_enabled ? kTestRefreshRate : kDefaultRefreshRate;
152 152
153 #if defined(WEBLAYER_IS_PURE_VIRTUAL)
154 host_.initialize(this, *root_web_layer_, settings); 153 host_.initialize(this, *root_web_layer_, settings);
155 root_web_layer_->setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); 154 root_web_layer_->setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
156 #else
157 host_.initialize(this, root_web_layer_, settings);
158 root_web_layer_.setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
159 #endif
160 host_.setSurfaceReady(); 155 host_.setSurfaceReady();
161 } 156 }
162 157
163 Compositor::~Compositor() { 158 Compositor::~Compositor() {
164 // Don't call |CompositorDelegate::ScheduleDraw| from this point. 159 // Don't call |CompositorDelegate::ScheduleDraw| from this point.
165 delegate_ = NULL; 160 delegate_ = NULL;
166 #if !defined(WEBLAYER_IS_PURE_VIRTUAL)
167 // 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
169 // is broken.
170 host_.setRootLayer(NULL);
171 #endif
172 if (root_layer_) 161 if (root_layer_)
173 root_layer_->SetCompositor(NULL); 162 root_layer_->SetCompositor(NULL);
174 163
175 // Stop all outstanding draws before telling the ContextFactory to tear 164 // Stop all outstanding draws before telling the ContextFactory to tear
176 // down any contexts that the |host_| may rely upon. 165 // down any contexts that the |host_| may rely upon.
177 host_.reset(); 166 host_.reset();
178 167
179 if (!test_compositor_enabled) 168 if (!test_compositor_enabled)
180 ContextFactory::GetInstance()->RemoveCompositor(this); 169 ContextFactory::GetInstance()->RemoveCompositor(this);
181 } 170 }
(...skipping 30 matching lines...) Expand all
212 } 201 }
213 202
214 void Compositor::SetRootLayer(Layer* root_layer) { 203 void Compositor::SetRootLayer(Layer* root_layer) {
215 if (root_layer_ == root_layer) 204 if (root_layer_ == root_layer)
216 return; 205 return;
217 if (root_layer_) 206 if (root_layer_)
218 root_layer_->SetCompositor(NULL); 207 root_layer_->SetCompositor(NULL);
219 root_layer_ = root_layer; 208 root_layer_ = root_layer;
220 if (root_layer_ && !root_layer_->GetCompositor()) 209 if (root_layer_ && !root_layer_->GetCompositor())
221 root_layer_->SetCompositor(this); 210 root_layer_->SetCompositor(this);
222 #if defined(WEBLAYER_IS_PURE_VIRTUAL)
223 root_web_layer_->removeAllChildren(); 211 root_web_layer_->removeAllChildren();
224 if (root_layer_) 212 if (root_layer_)
225 root_web_layer_->addChild(root_layer_->web_layer()); 213 root_web_layer_->addChild(root_layer_->web_layer());
226 #else
227 root_web_layer_.removeAllChildren();
228 if (root_layer_)
229 root_web_layer_.addChild(root_layer_->web_layer());
230 #endif
231 } 214 }
232 215
233 void Compositor::Draw(bool force_clear) { 216 void Compositor::Draw(bool force_clear) {
234 if (!root_layer_) 217 if (!root_layer_)
235 return; 218 return;
236 219
237 last_started_frame_++; 220 last_started_frame_++;
238 if (!g_compositor_thread) 221 if (!g_compositor_thread)
239 FOR_EACH_OBSERVER(CompositorObserver, 222 FOR_EACH_OBSERVER(CompositorObserver,
240 observer_list_, 223 observer_list_,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 257 }
275 return false; 258 return false;
276 } 259 }
277 260
278 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { 261 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) {
279 DCHECK_GT(scale, 0); 262 DCHECK_GT(scale, 0);
280 if (size_in_pixel.IsEmpty() || scale <= 0) 263 if (size_in_pixel.IsEmpty() || scale <= 0)
281 return; 264 return;
282 size_ = size_in_pixel; 265 size_ = size_in_pixel;
283 host_.setViewportSize(size_in_pixel); 266 host_.setViewportSize(size_in_pixel);
284 #if defined(WEBLAYER_IS_PURE_VIRTUAL)
285 root_web_layer_->setBounds(size_in_pixel); 267 root_web_layer_->setBounds(size_in_pixel);
286 #else
287 root_web_layer_.setBounds(size_in_pixel);
288 #endif
289 268
290 if (device_scale_factor_ != scale) { 269 if (device_scale_factor_ != scale) {
291 device_scale_factor_ = scale; 270 device_scale_factor_ = scale;
292 if (root_layer_) 271 if (root_layer_)
293 root_layer_->OnDeviceScaleFactorChanged(scale); 272 root_layer_->OnDeviceScaleFactorChanged(scale);
294 } 273 }
295 } 274 }
296 275
297 void Compositor::AddObserver(CompositorObserver* observer) { 276 void Compositor::AddObserver(CompositorObserver* observer) {
298 observer_list_.AddObserver(observer); 277 observer_list_.AddObserver(observer);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 456
478 COMPOSITOR_EXPORT void DisableTestCompositor() { 457 COMPOSITOR_EXPORT void DisableTestCompositor() {
479 test_compositor_enabled = false; 458 test_compositor_enabled = false;
480 } 459 }
481 460
482 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { 461 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() {
483 return test_compositor_enabled; 462 return test_compositor_enabled;
484 } 463 }
485 464
486 } // namespace ui 465 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698