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

Unified Diff: ui/views/view.cc

Issue 2639203007: Update SetPaintToLayer to accept LayerType (Closed)
Patch Set: remove unnecessary calls Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index d65f4bc25926d324ee7ea48ed5732ec678c93523..efe309e59bb071b8122030acbe90d136bc5fd3d6 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -523,22 +523,28 @@ void View::SetTransform(const gfx::Transform& transform) {
}
} else {
if (!layer())
- CreateLayer();
+ CreateLayer(ui::LAYER_TEXTURED);
layer()->SetTransform(transform);
layer()->ScheduleDraw();
}
}
-void View::SetPaintToLayer(bool paint_to_layer) {
- if (paint_to_layer_ == paint_to_layer)
+void View::SetPaintToLayer(ui::LayerType layer_type) {
+ if (paint_to_layer_)
sky 2017/01/23 17:10:08 Shouldn't this also check the type? By that I mean
return;
- paint_to_layer_ = paint_to_layer;
- if (paint_to_layer_ && !layer()) {
- CreateLayer();
- } else if (!paint_to_layer_ && layer()) {
+ paint_to_layer_ = true;
+ if (!layer())
+ CreateLayer(layer_type);
+}
+
+void View::DetachLayer() {
+ if (!paint_to_layer_)
+ return;
+
+ paint_to_layer_ = false;
+ if (layer())
DestroyLayer();
- }
}
std::unique_ptr<ui::Layer> View::RecreateLayer() {
@@ -2184,7 +2190,7 @@ bool View::ConvertRectFromAncestor(const View* ancestor,
// Accelerated painting --------------------------------------------------------
-void View::CreateLayer() {
+void View::CreateLayer(ui::LayerType layer_type) {
// A new layer is being created for the view. So all the layers of the
// sub-tree can inherit the visibility of the corresponding view.
{
@@ -2193,7 +2199,7 @@ void View::CreateLayer() {
child->UpdateChildLayerVisibility(true);
}
- SetLayer(base::MakeUnique<ui::Layer>());
+ SetLayer(base::MakeUnique<ui::Layer>(layer_type));
layer()->set_delegate(this);
layer()->set_name(GetClassName());
« ui/views/view.h ('K') | « ui/views/view.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698