Commit dfc1488d authored by danakj's avatar danakj Committed by Commit bot

Move early outs to the top of View::Paint and OnPaintLayer

This makes the CullSet check into an early out instead of
an if-block wrapping a whole function.

It also moves the |visible_| early out to the same place
from PaintCommon(). This hints at combining Paint() and
PaintCommont().

This also moves the |visible_| early out to the other caller
of PaintCommon() which is OnPaintLayer(), and can early
out before doing the solid color clear.

BUG=466426

Review URL: https://codereview.chromium.org/1037513002

Cr-Commit-Position: refs/heads/master@{#322220}
parent a8a9143d
......@@ -764,9 +764,13 @@ void View::SchedulePaintInRect(const gfx::Rect& rect) {
}
void View::Paint(gfx::Canvas* canvas, const CullSet& cull_set) {
if (!visible_)
return;
// The cull_set may allow us to skip painting without canvas construction or
// even canvas rect intersection.
if (cull_set.ShouldPaint(this)) {
if (!cull_set.ShouldPaint(this))
return;
TRACE_EVENT1("views", "View::Paint", "class", GetClassName());
gfx::ScopedCanvas scoped_canvas(canvas);
......@@ -809,10 +813,9 @@ void View::Paint(gfx::Canvas* canvas, const CullSet& cull_set) {
// Now query our bounds_tree_ for a set of damaged views that intersect
// our canvas bounds.
scoped_ptr<base::hash_set<intptr_t> > damaged_views(
scoped_ptr<base::hash_set<intptr_t>> damaged_views(
new base::hash_set<intptr_t>());
bounds_tree_->AppendIntersectingRecords(
canvas_bounds, damaged_views.get());
bounds_tree_->AppendIntersectingRecords(canvas_bounds, damaged_views.get());
// Construct a CullSet to wrap the damaged views set, it will delete it
// for us on scope exit.
CullSet paint_root_cull_set(damaged_views.Pass());
......@@ -822,7 +825,6 @@ void View::Paint(gfx::Canvas* canvas, const CullSet& cull_set) {
// Not a paint root, so we can proceed as normal.
PaintCommon(canvas, cull_set);
}
}
}
void View::set_background(Background* b) {
......@@ -1464,6 +1466,8 @@ void View::UpdateChildLayerBounds(const gfx::Vector2d& offset) {
void View::OnPaintLayer(gfx::Canvas* canvas) {
if (!layer() || !layer()->fills_bounds_opaquely())
canvas->DrawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
if (!visible_)
return;
PaintCommon(canvas, CullSet());
}
......@@ -1748,9 +1752,6 @@ void View::SchedulePaintBoundsChanged(SchedulePaintType type) {
}
void View::PaintCommon(gfx::Canvas* canvas, const CullSet& cull_set) {
if (!visible_)
return;
{
// If the View we are about to paint requested the canvas to be flipped, we
// should change the transform appropriately.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment