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(
}
static void AppendQuadsToFillScreen(
ResourceProvider::ResourceId resource_id,
gfx::SizeF resource_scaled_size,
ResourceProvider::ResourceId overhang_resource_id,
gfx::SizeF overhang_resource_scaled_size,
gfx::Rect root_scroll_layer_rect,
RenderPass* target_render_pass,
LayerImpl* root_layer,
SkColor screen_background_color,
......@@ -566,6 +567,16 @@ static void AppendQuadsToFillScreen(
if (fill_region.IsEmpty())
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;
QuadCuller quad_culler(&target_render_pass->quad_list,
&target_render_pass->shared_quad_state_list,
......@@ -596,38 +607,44 @@ static void AppendQuadsToFillScreen(
bool did_invert = root_layer->screen_space_transform().GetInverse(
&transform_to_layer_space);
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.next()) {
// The root layer transform is composed of translations and scales only,
// no perspective, so mapping is sufficient (as opposed to projecting).
gfx::Rect layer_rect =
MathUtil::MapClippedRect(transform_to_layer_space, fill_rects.rect());
if (resource_id) {
scoped_ptr<TextureDrawQuad> tex_quad = TextureDrawQuad::Create();
const float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f};
tex_quad->SetNew(
shared_quad_state,
layer_rect,
layer_rect,
resource_id,
false,
gfx::PointF(layer_rect.x() / resource_scaled_size.width(),
layer_rect.y() / resource_scaled_size.height()),
gfx::PointF(layer_rect.right() / resource_scaled_size.width(),
layer_rect.bottom() / resource_scaled_size.height()),
screen_background_color,
vertex_opacity,
false);
quad_culler.Append(tex_quad.PassAs<DrawQuad>(), &append_quads_data);
} else {
// Skip the quad culler and just append the quads directly to avoid
// occlusion checks.
scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
quad->SetNew(
shared_quad_state, layer_rect, screen_background_color, false);
quad_culler.Append(quad.PassAs<DrawQuad>(), &append_quads_data);
}
// Skip the quad culler and just append the quads directly to avoid
// occlusion checks.
scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
quad->SetNew(
shared_quad_state, layer_rect, screen_background_color, false);
quad_culler.Append(quad.PassAs<DrawQuad>(), &append_quads_data);
}
for (Region::Iterator fill_rects(overhang_region);
fill_rects.has_rect();
fill_rects.next()) {
DCHECK(overhang_resource_id);
gfx::Rect layer_rect =
MathUtil::MapClippedRect(transform_to_layer_space, fill_rects.rect());
scoped_ptr<TextureDrawQuad> tex_quad = TextureDrawQuad::Create();
const float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f};
tex_quad->SetNew(
shared_quad_state,
layer_rect,
layer_rect,
overhang_resource_id,
false,
gfx::PointF(layer_rect.x() / overhang_resource_scaled_size.width(),
layer_rect.y() / overhang_resource_scaled_size.height()),
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) {
if (!active_tree_->has_transparent_background()) {
frame->render_passes.back()->has_transparent_background = false;
AppendQuadsToFillScreen(ResourceIdForUIResource(overhang_ui_resource_id_),
gfx::ScaleSize(overhang_ui_resource_size_,
device_scale_factor_),
frame->render_passes.back(),
active_tree_->root_layer(),
active_tree_->background_color(),
occlusion_tracker);
AppendQuadsToFillScreen(
ResourceIdForUIResource(overhang_ui_resource_id_),
gfx::ScaleSize(overhang_ui_resource_size_, device_scale_factor_),
active_tree_->RootScrollLayerDeviceViewportBounds(),
frame->render_passes.back(),
active_tree_->root_layer(),
active_tree_->background_color(),
occlusion_tracker);
}
if (draw_frame)
......
......@@ -7,6 +7,8 @@
#include "base/debug/trace_event.h"
#include "cc/animation/keyframed_animation_curve.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/layers/heads_up_display_layer_impl.h"
#include "cc/layers/layer.h"
......@@ -238,6 +240,15 @@ gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const {
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() {
LayerImpl* root_scroll = RootScrollLayer();
if (!root_scroll || !root_scroll->children().size())
......
......@@ -175,6 +175,8 @@ class CC_EXPORT LayerTreeImpl {
gfx::Size ScrollableSize() const;
gfx::SizeF ScrollableViewportSize() const;
gfx::Rect RootScrollLayerDeviceViewportBounds() const;
LayerImpl* LayerById(int id);
// 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