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

Side by Side Diff: ui/views/view.cc

Issue 1461673002: Moved parent_->SchedulePaint() to Views::SetFillsBoundsOpaquely() and Views::SchedulePaint(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed View to schedule a parent paint only when paint to layer, or fills bounds opaquely changed. Created 5 years, 1 month 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/views/view.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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "ui/views/view.h" 7 #include "ui/views/view.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 454 }
455 } 455 }
456 456
457 void View::SetPaintToLayer(bool paint_to_layer) { 457 void View::SetPaintToLayer(bool paint_to_layer) {
458 if (paint_to_layer_ == paint_to_layer) 458 if (paint_to_layer_ == paint_to_layer)
459 return; 459 return;
460 460
461 paint_to_layer_ = paint_to_layer; 461 paint_to_layer_ = paint_to_layer;
462 if (paint_to_layer_ && !layer()) { 462 if (paint_to_layer_ && !layer()) {
463 CreateLayer(); 463 CreateLayer();
464 SchedulePaintOnParent();
sky 2015/11/19 22:31:48 Why does this case necessitate a paint on the pare
bruthig 2015/12/22 22:32:40 Done.
464 } else if (!paint_to_layer_ && layer()) { 465 } else if (!paint_to_layer_ && layer()) {
465 DestroyLayer(); 466 DestroyLayer();
466 } 467 }
467 } 468 }
468 469
469 // RTL positioning ------------------------------------------------------------- 470 // RTL positioning -------------------------------------------------------------
470 471
471 gfx::Rect View::GetMirroredBounds() const { 472 gfx::Rect View::GetMirroredBounds() const {
472 gfx::Rect bounds(bounds_); 473 gfx::Rect bounds(bounds_);
473 bounds.set_x(GetMirroredX()); 474 bounds.set_x(GetMirroredX());
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 "width", canvas->sk_canvas()->getDevice()->width(), 1378 "width", canvas->sk_canvas()->getDevice()->width(),
1378 "height", canvas->sk_canvas()->getDevice()->height()); 1379 "height", canvas->sk_canvas()->getDevice()->height());
1379 border_->Paint(*this, canvas); 1380 border_->Paint(*this, canvas);
1380 } 1381 }
1381 } 1382 }
1382 1383
1383 // Accelerated Painting -------------------------------------------------------- 1384 // Accelerated Painting --------------------------------------------------------
1384 1385
1385 void View::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) { 1386 void View::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) {
1386 // This method should not have the side-effect of creating the layer. 1387 // This method should not have the side-effect of creating the layer.
1387 if (layer()) 1388 if (layer()) {
1389 bool schedule_paint_on_parent =
sky 2015/11/19 22:31:48 Please add an early return to make this code easie
bruthig 2015/12/22 22:32:40 Done.
1390 !fills_bounds_opaquely && layer()->fills_bounds_opaquely();
1388 layer()->SetFillsBoundsOpaquely(fills_bounds_opaquely); 1391 layer()->SetFillsBoundsOpaquely(fills_bounds_opaquely);
1392 if (schedule_paint_on_parent)
1393 SchedulePaintOnParent();
1394 }
1389 } 1395 }
1390 1396
1391 gfx::Vector2d View::CalculateOffsetToAncestorWithLayer( 1397 gfx::Vector2d View::CalculateOffsetToAncestorWithLayer(
1392 ui::Layer** layer_parent) { 1398 ui::Layer** layer_parent) {
1393 if (layer()) { 1399 if (layer()) {
1394 if (layer_parent) 1400 if (layer_parent)
1395 *layer_parent = layer(); 1401 *layer_parent = layer();
1396 return gfx::Vector2d(); 1402 return gfx::Vector2d();
1397 } 1403 }
1398 if (!parent_) 1404 if (!parent_)
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 SchedulePaint(); 1732 SchedulePaint();
1727 } else if (parent_ && type == SCHEDULE_PAINT_SIZE_SAME) { 1733 } else if (parent_ && type == SCHEDULE_PAINT_SIZE_SAME) {
1728 // The compositor doesn't Draw() until something on screen changes, so 1734 // The compositor doesn't Draw() until something on screen changes, so
1729 // if our position changes but nothing is being animated on screen, then 1735 // if our position changes but nothing is being animated on screen, then
1730 // tell the compositor to redraw the scene. We know layer() exists due to 1736 // tell the compositor to redraw the scene. We know layer() exists due to
1731 // the above if clause. 1737 // the above if clause.
1732 layer()->ScheduleDraw(); 1738 layer()->ScheduleDraw();
1733 } 1739 }
1734 } 1740 }
1735 1741
1742 void View::SchedulePaintOnParent() {
1743 if (parent_) {
1744 // Translate the requested paint rect to the parent's coordinate system
1745 // then pass this notification up to the parent.
1746 parent_->SchedulePaintInRect(ConvertRectToParent(bounds_));
1747 }
1748 }
1749
1736 // Tree operations ------------------------------------------------------------- 1750 // Tree operations -------------------------------------------------------------
1737 1751
1738 void View::DoRemoveChildView(View* view, 1752 void View::DoRemoveChildView(View* view,
1739 bool update_focus_cycle, 1753 bool update_focus_cycle,
1740 bool update_tool_tip, 1754 bool update_tool_tip,
1741 bool delete_removed_view, 1755 bool delete_removed_view,
1742 View* new_parent) { 1756 View* new_parent) {
1743 DCHECK(view); 1757 DCHECK(view);
1744 1758
1745 const Views::iterator i(std::find(children_.begin(), children_.end(), view)); 1759 const Views::iterator i(std::find(children_.begin(), children_.end(), view));
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 // Message the RootView to do the drag and drop. That way if we're removed 2368 // Message the RootView to do the drag and drop. That way if we're removed
2355 // the RootView can detect it and avoid calling us back. 2369 // the RootView can detect it and avoid calling us back.
2356 gfx::Point widget_location(event.location()); 2370 gfx::Point widget_location(event.location());
2357 ConvertPointToWidget(this, &widget_location); 2371 ConvertPointToWidget(this, &widget_location);
2358 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2372 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2359 // WARNING: we may have been deleted. 2373 // WARNING: we may have been deleted.
2360 return true; 2374 return true;
2361 } 2375 }
2362 2376
2363 } // namespace views 2377 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698