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

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

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: Sync with ToT Created 3 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
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_owner_unittest.cc » ('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/layer.h" 5 #include "ui/compositor/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 22 matching lines...) Expand all
33 #include "ui/gfx/canvas.h" 33 #include "ui/gfx/canvas.h"
34 #include "ui/gfx/geometry/dip_util.h" 34 #include "ui/gfx/geometry/dip_util.h"
35 #include "ui/gfx/geometry/point3_f.h" 35 #include "ui/gfx/geometry/point3_f.h"
36 #include "ui/gfx/geometry/point_conversions.h" 36 #include "ui/gfx/geometry/point_conversions.h"
37 #include "ui/gfx/geometry/size_conversions.h" 37 #include "ui/gfx/geometry/size_conversions.h"
38 #include "ui/gfx/interpolated_transform.h" 38 #include "ui/gfx/interpolated_transform.h"
39 39
40 namespace { 40 namespace {
41 41
42 const ui::Layer* GetRoot(const ui::Layer* layer) { 42 const ui::Layer* GetRoot(const ui::Layer* layer) {
43 // Parent walk cannot be done on a layer that is being used as a mask. Get the
44 // layer to which this layer is a mask of.
45 if (layer->layer_mask_back_link())
46 layer = layer->layer_mask_back_link();
43 while (layer->parent()) 47 while (layer->parent())
44 layer = layer->parent(); 48 layer = layer->parent();
45 return layer; 49 return layer;
46 } 50 }
47 51
48 } // namespace 52 } // namespace
49 53
50 namespace ui { 54 namespace ui {
51 55
52 class Layer::LayerMirror : public LayerDelegate, LayerObserver { 56 class Layer::LayerMirror : public LayerDelegate, LayerObserver {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 if (parent == this) 312 if (parent == this)
309 return true; 313 return true;
310 } 314 }
311 return false; 315 return false;
312 } 316 }
313 317
314 void Layer::SetAnimator(LayerAnimator* animator) { 318 void Layer::SetAnimator(LayerAnimator* animator) {
315 Compositor* compositor = GetCompositor(); 319 Compositor* compositor = GetCompositor();
316 320
317 if (animator_) { 321 if (animator_) {
318 if (compositor) 322 if (compositor && !layer_mask_back_link())
319 animator_->DetachLayerAndTimeline(compositor); 323 animator_->DetachLayerAndTimeline(compositor);
320 animator_->SetDelegate(nullptr); 324 animator_->SetDelegate(nullptr);
321 } 325 }
322 326
323 animator_ = animator; 327 animator_ = animator;
324 328
325 if (animator_) { 329 if (animator_) {
326 animator_->SetDelegate(this); 330 animator_->SetDelegate(this);
327 if (compositor) 331 if (compositor && !layer_mask_back_link())
328 animator_->AttachLayerAndTimeline(compositor); 332 animator_->AttachLayerAndTimeline(compositor);
329 } 333 }
330 } 334 }
331 335
332 LayerAnimator* Layer::GetAnimator() { 336 LayerAnimator* Layer::GetAnimator() {
333 if (!animator_) 337 if (!animator_)
334 SetAnimator(LayerAnimator::CreateDefaultAnimator()); 338 SetAnimator(LayerAnimator::CreateDefaultAnimator());
335 return animator_.get(); 339 return animator_.get();
336 } 340 }
337 341
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 940
937 scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList( 941 scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList(
938 ContentLayerClient::PaintingControlSetting painting_control) { 942 ContentLayerClient::PaintingControlSetting painting_control) {
939 TRACE_EVENT1("ui", "Layer::PaintContentsToDisplayList", "name", name_); 943 TRACE_EVENT1("ui", "Layer::PaintContentsToDisplayList", "name", name_);
940 gfx::Rect local_bounds(bounds().size()); 944 gfx::Rect local_bounds(bounds().size());
941 gfx::Rect invalidation( 945 gfx::Rect invalidation(
942 gfx::IntersectRects(paint_region_.bounds(), local_bounds)); 946 gfx::IntersectRects(paint_region_.bounds(), local_bounds));
943 paint_region_.Clear(); 947 paint_region_.Clear();
944 auto display_list = make_scoped_refptr(new cc::DisplayItemList); 948 auto display_list = make_scoped_refptr(new cc::DisplayItemList);
945 if (delegate_) { 949 if (delegate_) {
946 delegate_->OnPaintLayer( 950 delegate_->OnPaintLayer(PaintContext(display_list.get(),
947 PaintContext(display_list.get(), device_scale_factor_, invalidation)); 951 device_scale_factor_, invalidation,
952 GetCompositor()->is_pixel_canvas()));
948 } 953 }
949 display_list->Finalize(); 954 display_list->Finalize();
950 // TODO(domlaskowski): Move mirror invalidation to Layer::SchedulePaint. 955 // TODO(domlaskowski): Move mirror invalidation to Layer::SchedulePaint.
951 for (const auto& mirror : mirrors_) 956 for (const auto& mirror : mirrors_)
952 mirror->dest()->SchedulePaint(invalidation); 957 mirror->dest()->SchedulePaint(invalidation);
953 return display_list; 958 return display_list;
954 } 959 }
955 960
956 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } 961 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; }
957 962
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), 1269 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(),
1265 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { 1270 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) {
1266 return mirror_ptr.get() == mirror; 1271 return mirror_ptr.get() == mirror;
1267 }); 1272 });
1268 1273
1269 DCHECK(it != mirrors_.end()); 1274 DCHECK(it != mirrors_.end());
1270 mirrors_.erase(it); 1275 mirrors_.erase(it);
1271 } 1276 }
1272 1277
1273 } // namespace ui 1278 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_owner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698