Commit 3744e27b authored by ccameron@chromium.org's avatar ccameron@chromium.org

Only draw the overhang pattern on overhang areas.

Split the draw gutter quads into two regions -- one to be drawn with
the overhang texture and the other to be drawn with the the background
color.

BUG=314767

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233380 0039d316-1c4b-4281-b951-d872f2087c98
parent d3bed9f5
...@@ -553,8 +553,9 @@ static void AppendQuadsForRenderSurfaceLayer( ...@@ -553,8 +553,9 @@ static void AppendQuadsForRenderSurfaceLayer(
} }
static void AppendQuadsToFillScreen( static void AppendQuadsToFillScreen(
ResourceProvider::ResourceId resource_id, ResourceProvider::ResourceId overhang_resource_id,
gfx::SizeF resource_scaled_size, gfx::SizeF overhang_resource_scaled_size,
gfx::Rect root_scroll_layer_rect,
RenderPass* target_render_pass, RenderPass* target_render_pass,
LayerImpl* root_layer, LayerImpl* root_layer,
SkColor screen_background_color, SkColor screen_background_color,
...@@ -566,6 +567,16 @@ static void AppendQuadsToFillScreen( ...@@ -566,6 +567,16 @@ static void AppendQuadsToFillScreen(
if (fill_region.IsEmpty()) if (fill_region.IsEmpty())
return; return;
// Divide the fill region into the part to be filled with the overhang
// resource and the part to be filled with the background color.
Region screen_background_color_region = fill_region;
Region overhang_region;
if (overhang_resource_id) {
overhang_region = fill_region;
overhang_region.Subtract(root_scroll_layer_rect);
screen_background_color_region.Intersect(root_scroll_layer_rect);
}
bool for_surface = false; bool for_surface = false;
QuadCuller quad_culler(&target_render_pass->quad_list, QuadCuller quad_culler(&target_render_pass->quad_list,
&target_render_pass->shared_quad_state_list, &target_render_pass->shared_quad_state_list,
...@@ -596,38 +607,44 @@ static void AppendQuadsToFillScreen( ...@@ -596,38 +607,44 @@ static void AppendQuadsToFillScreen(
bool did_invert = root_layer->screen_space_transform().GetInverse( bool did_invert = root_layer->screen_space_transform().GetInverse(
&transform_to_layer_space); &transform_to_layer_space);
DCHECK(did_invert); DCHECK(did_invert);
for (Region::Iterator fill_rects(fill_region); for (Region::Iterator fill_rects(screen_background_color_region);
fill_rects.has_rect(); fill_rects.has_rect();
fill_rects.next()) { fill_rects.next()) {
// The root layer transform is composed of translations and scales only, // The root layer transform is composed of translations and scales only,
// no perspective, so mapping is sufficient (as opposed to projecting). // no perspective, so mapping is sufficient (as opposed to projecting).
gfx::Rect layer_rect = gfx::Rect layer_rect =
MathUtil::MapClippedRect(transform_to_layer_space, fill_rects.rect()); MathUtil::MapClippedRect(transform_to_layer_space, fill_rects.rect());
if (resource_id) { // Skip the quad culler and just append the quads directly to avoid
scoped_ptr<TextureDrawQuad> tex_quad = TextureDrawQuad::Create(); // occlusion checks.
const float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f}; scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
tex_quad->SetNew( quad->SetNew(
shared_quad_state, shared_quad_state, layer_rect, screen_background_color, false);
layer_rect, quad_culler.Append(quad.PassAs<DrawQuad>(), &append_quads_data);
layer_rect, }
resource_id, for (Region::Iterator fill_rects(overhang_region);
false, fill_rects.has_rect();
gfx::PointF(layer_rect.x() / resource_scaled_size.width(), fill_rects.next()) {
layer_rect.y() / resource_scaled_size.height()), DCHECK(overhang_resource_id);
gfx::PointF(layer_rect.right() / resource_scaled_size.width(), gfx::Rect layer_rect =
layer_rect.bottom() / resource_scaled_size.height()), MathUtil::MapClippedRect(transform_to_layer_space, fill_rects.rect());
screen_background_color, scoped_ptr<TextureDrawQuad> tex_quad = TextureDrawQuad::Create();
vertex_opacity, const float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f};
false); tex_quad->SetNew(
quad_culler.Append(tex_quad.PassAs<DrawQuad>(), &append_quads_data); shared_quad_state,
} else { layer_rect,
// Skip the quad culler and just append the quads directly to avoid layer_rect,
// occlusion checks. overhang_resource_id,
scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); false,
quad->SetNew( gfx::PointF(layer_rect.x() / overhang_resource_scaled_size.width(),
shared_quad_state, layer_rect, screen_background_color, false); layer_rect.y() / overhang_resource_scaled_size.height()),
quad_culler.Append(quad.PassAs<DrawQuad>(), &append_quads_data); gfx::PointF(layer_rect.right() /
} overhang_resource_scaled_size.width(),
layer_rect.bottom() /
overhang_resource_scaled_size.height()),
screen_background_color,
vertex_opacity,
false);
quad_culler.Append(tex_quad.PassAs<DrawQuad>(), &append_quads_data);
} }
} }
...@@ -827,13 +844,14 @@ bool LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) { ...@@ -827,13 +844,14 @@ bool LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) {
if (!active_tree_->has_transparent_background()) { if (!active_tree_->has_transparent_background()) {
frame->render_passes.back()->has_transparent_background = false; frame->render_passes.back()->has_transparent_background = false;
AppendQuadsToFillScreen(ResourceIdForUIResource(overhang_ui_resource_id_), AppendQuadsToFillScreen(
gfx::ScaleSize(overhang_ui_resource_size_, ResourceIdForUIResource(overhang_ui_resource_id_),
device_scale_factor_), gfx::ScaleSize(overhang_ui_resource_size_, device_scale_factor_),
frame->render_passes.back(), active_tree_->RootScrollLayerDeviceViewportBounds(),
active_tree_->root_layer(), frame->render_passes.back(),
active_tree_->background_color(), active_tree_->root_layer(),
occlusion_tracker); active_tree_->background_color(),
occlusion_tracker);
} }
if (draw_frame) if (draw_frame)
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "cc/animation/keyframed_animation_curve.h" #include "cc/animation/keyframed_animation_curve.h"
#include "cc/animation/scrollbar_animation_controller.h" #include "cc/animation/scrollbar_animation_controller.h"
#include "cc/base/math_util.h"
#include "cc/base/util.h"
#include "cc/debug/traced_value.h" #include "cc/debug/traced_value.h"
#include "cc/layers/heads_up_display_layer_impl.h" #include "cc/layers/heads_up_display_layer_impl.h"
#include "cc/layers/layer.h" #include "cc/layers/layer.h"
...@@ -238,6 +240,15 @@ gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const { ...@@ -238,6 +240,15 @@ gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const {
1.0f / total_page_scale_factor()); 1.0f / total_page_scale_factor());
} }
gfx::Rect LayerTreeImpl::RootScrollLayerDeviceViewportBounds() const {
if (!root_scroll_layer_ || root_scroll_layer_->children().empty())
return gfx::Rect();
LayerImpl* layer = root_scroll_layer_->children()[0];
return MathUtil::MapClippedRect(
layer->screen_space_transform(),
gfx::Rect(layer->content_bounds()));
}
void LayerTreeImpl::UpdateMaxScrollOffset() { void LayerTreeImpl::UpdateMaxScrollOffset() {
LayerImpl* root_scroll = RootScrollLayer(); LayerImpl* root_scroll = RootScrollLayer();
if (!root_scroll || !root_scroll->children().size()) if (!root_scroll || !root_scroll->children().size())
......
...@@ -175,6 +175,8 @@ class CC_EXPORT LayerTreeImpl { ...@@ -175,6 +175,8 @@ class CC_EXPORT LayerTreeImpl {
gfx::Size ScrollableSize() const; gfx::Size ScrollableSize() const;
gfx::SizeF ScrollableViewportSize() const; gfx::SizeF ScrollableViewportSize() const;
gfx::Rect RootScrollLayerDeviceViewportBounds() const;
LayerImpl* LayerById(int id); LayerImpl* LayerById(int id);
// These should be called by LayerImpl's ctor/dtor. // These should be called by LayerImpl's ctor/dtor.
......
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