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

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

Issue 2575503003: Getting rid of frame_size_in_dip in Layer::SetShowSurface (Closed)
Patch Set: up Created 4 years 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
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 14 matching lines...) Expand all
25 #include "cc/playback/display_item_list_settings.h" 25 #include "cc/playback/display_item_list_settings.h"
26 #include "cc/resources/transferable_resource.h" 26 #include "cc/resources/transferable_resource.h"
27 #include "cc/trees/layer_tree_settings.h" 27 #include "cc/trees/layer_tree_settings.h"
28 #include "ui/compositor/compositor_switches.h" 28 #include "ui/compositor/compositor_switches.h"
29 #include "ui/compositor/dip_util.h" 29 #include "ui/compositor/dip_util.h"
30 #include "ui/compositor/layer_animator.h" 30 #include "ui/compositor/layer_animator.h"
31 #include "ui/compositor/layer_observer.h" 31 #include "ui/compositor/layer_observer.h"
32 #include "ui/compositor/paint_context.h" 32 #include "ui/compositor/paint_context.h"
33 #include "ui/gfx/animation/animation.h" 33 #include "ui/gfx/animation/animation.h"
34 #include "ui/gfx/canvas.h" 34 #include "ui/gfx/canvas.h"
35 #include "ui/gfx/geometry/dip_util.h"
35 #include "ui/gfx/geometry/point3_f.h" 36 #include "ui/gfx/geometry/point3_f.h"
36 #include "ui/gfx/geometry/point_conversions.h" 37 #include "ui/gfx/geometry/point_conversions.h"
37 #include "ui/gfx/geometry/size_conversions.h" 38 #include "ui/gfx/geometry/size_conversions.h"
38 #include "ui/gfx/interpolated_transform.h" 39 #include "ui/gfx/interpolated_transform.h"
39 40
40 namespace { 41 namespace {
41 42
42 const ui::Layer* GetRoot(const ui::Layer* layer) { 43 const ui::Layer* GetRoot(const ui::Layer* layer) {
43 while (layer->parent()) 44 while (layer->parent())
44 layer = layer->parent(); 45 layer = layer->parent();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 clone->SetLayerSaturation(layer_saturation_); 177 clone->SetLayerSaturation(layer_saturation_);
177 clone->SetLayerBrightness(GetTargetBrightness()); 178 clone->SetLayerBrightness(GetTargetBrightness());
178 clone->SetLayerGrayscale(GetTargetGrayscale()); 179 clone->SetLayerGrayscale(GetTargetGrayscale());
179 clone->SetLayerInverted(layer_inverted_); 180 clone->SetLayerInverted(layer_inverted_);
180 if (alpha_shape_) 181 if (alpha_shape_)
181 clone->SetAlphaShape(base::MakeUnique<SkRegion>(*alpha_shape_)); 182 clone->SetAlphaShape(base::MakeUnique<SkRegion>(*alpha_shape_));
182 183
183 // cc::Layer state. 184 // cc::Layer state.
184 if (surface_layer_ && surface_layer_->surface_id().is_valid()) { 185 if (surface_layer_ && surface_layer_->surface_id().is_valid()) {
185 clone->SetShowSurface( 186 clone->SetShowSurface(
186 surface_layer_->surface_id(), 187 surface_layer_->surface_id(), surface_layer_->satisfy_callback(),
187 surface_layer_->satisfy_callback(), 188 surface_layer_->require_callback(), surface_layer_->surface_size(),
188 surface_layer_->require_callback(), 189 surface_layer_->surface_scale());
189 surface_layer_->surface_size(),
190 surface_layer_->surface_scale(),
191 frame_size_in_dip_);
192 } else if (type_ == LAYER_SOLID_COLOR) { 190 } else if (type_ == LAYER_SOLID_COLOR) {
193 clone->SetColor(GetTargetColor()); 191 clone->SetColor(GetTargetColor());
194 } 192 }
195 return clone; 193 return clone;
196 } 194 }
197 195
198 std::unique_ptr<Layer> Layer::Mirror() { 196 std::unique_ptr<Layer> Layer::Mirror() {
199 auto mirror = Clone(); 197 auto mirror = Clone();
200 mirrors_.emplace_back(base::MakeUnique<LayerMirror>(this, mirror.get())); 198 mirrors_.emplace_back(base::MakeUnique<LayerMirror>(this, mirror.get()));
201 return mirror; 199 return mirror;
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 bool Layer::TextureFlipped() const { 653 bool Layer::TextureFlipped() const {
656 DCHECK(texture_layer_.get()); 654 DCHECK(texture_layer_.get());
657 return texture_layer_->flipped(); 655 return texture_layer_->flipped();
658 } 656 }
659 657
660 void Layer::SetShowSurface( 658 void Layer::SetShowSurface(
661 const cc::SurfaceId& surface_id, 659 const cc::SurfaceId& surface_id,
662 const cc::SurfaceLayer::SatisfyCallback& satisfy_callback, 660 const cc::SurfaceLayer::SatisfyCallback& satisfy_callback,
663 const cc::SurfaceLayer::RequireCallback& require_callback, 661 const cc::SurfaceLayer::RequireCallback& require_callback,
664 gfx::Size surface_size, 662 gfx::Size surface_size,
665 float scale, 663 float scale) {
666 gfx::Size frame_size_in_dip) {
667 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); 664 DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR);
668 665
669 scoped_refptr<cc::SurfaceLayer> new_layer = 666 scoped_refptr<cc::SurfaceLayer> new_layer =
670 cc::SurfaceLayer::Create(satisfy_callback, require_callback); 667 cc::SurfaceLayer::Create(satisfy_callback, require_callback);
671 new_layer->SetSurfaceId(surface_id, scale, surface_size); 668 new_layer->SetSurfaceId(surface_id, scale, surface_size);
672 SwitchToLayer(new_layer); 669 SwitchToLayer(new_layer);
673 surface_layer_ = new_layer; 670 surface_layer_ = new_layer;
674 671
675 frame_size_in_dip_ = frame_size_in_dip; 672 frame_size_in_dip_ = gfx::ConvertSizeToDIP(scale, surface_size);
676 RecomputeDrawsContentAndUVRect(); 673 RecomputeDrawsContentAndUVRect();
677 674
678 for (const auto& mirror : mirrors_) { 675 for (const auto& mirror : mirrors_) {
679 mirror->dest()->SetShowSurface( 676 mirror->dest()->SetShowSurface(surface_id, satisfy_callback,
680 surface_id, satisfy_callback, require_callback, 677 require_callback, surface_size, scale);
681 surface_size, scale, frame_size_in_dip);
682 } 678 }
683 } 679 }
684 680
685 void Layer::SetShowSolidColorContent() { 681 void Layer::SetShowSolidColorContent() {
686 DCHECK_EQ(type_, LAYER_SOLID_COLOR); 682 DCHECK_EQ(type_, LAYER_SOLID_COLOR);
687 683
688 if (solid_color_layer_.get()) 684 if (solid_color_layer_.get())
689 return; 685 return;
690 686
691 scoped_refptr<cc::SolidColorLayer> new_layer = cc::SolidColorLayer::Create(); 687 scoped_refptr<cc::SolidColorLayer> new_layer = cc::SolidColorLayer::Create();
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), 1171 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(),
1176 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { 1172 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) {
1177 return mirror_ptr.get() == mirror; 1173 return mirror_ptr.get() == mirror;
1178 }); 1174 });
1179 1175
1180 DCHECK(it != mirrors_.end()); 1176 DCHECK(it != mirrors_.end());
1181 mirrors_.erase(it); 1177 mirrors_.erase(it);
1182 } 1178 }
1183 1179
1184 } // namespace ui 1180 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698