| Index: cc/layers/nine_patch_layer_impl.cc
|
| diff --git a/cc/layers/nine_patch_layer_impl.cc b/cc/layers/nine_patch_layer_impl.cc
|
| index 1fac38552fe0249f9775cac9e63e436bde77731f..09a47747474db9d45322698d07919b09dc03f4cd 100644
|
| --- a/cc/layers/nine_patch_layer_impl.cc
|
| +++ b/cc/layers/nine_patch_layer_impl.cc
|
| @@ -93,6 +93,15 @@ void NinePatchLayerImpl::CheckGeometryLimitations() {
|
| DCHECK(gfx::Rect(image_bounds_).Contains(image_aperture_))
|
| << "image_bounds_ " << gfx::Rect(image_bounds_).ToString()
|
| << " image_aperture_ " << image_aperture_.ToString();
|
| +
|
| + // Sanity check on |layer_occlusion_|. It should always be within the
|
| + // border.
|
| + gfx::Rect border_rect(border_.x(), border_.y(),
|
| + bounds().width() - border_.width(),
|
| + bounds().height() - border_.height());
|
| + DCHECK(layer_occlusion_.IsEmpty() || layer_occlusion_.Contains(border_rect))
|
| + << "border_rect " << border_rect.ToString() << " layer_occlusion_ "
|
| + << layer_occlusion_.ToString();
|
| }
|
|
|
| std::vector<NinePatchLayerImpl::Patch>
|
| @@ -174,18 +183,29 @@ NinePatchLayerImpl::ComputeQuadsWithoutOcclusion() const {
|
|
|
| std::vector<NinePatchLayerImpl::Patch>
|
| NinePatchLayerImpl::ComputeQuadsWithOcclusion() const {
|
| - float image_width = image_bounds_.width();
|
| - float image_height = image_bounds_.height();
|
| - int layer_width = bounds().width();
|
| - int layer_height = bounds().height();
|
| - gfx::Rect image_occlusion(
|
| - BoundsToRect(layer_occlusion_.x(), layer_occlusion_.y(),
|
| - image_width - (layer_width - layer_occlusion_.right()),
|
| - image_height - (layer_height - layer_occlusion_.bottom())));
|
| - gfx::Rect layer_aperture(
|
| - BoundsToRect(image_aperture_.x(), image_aperture_.y(),
|
| - layer_width - (image_width - image_aperture_.right()),
|
| - layer_height - (image_height - image_aperture_.bottom())));
|
| + float image_width = image_bounds_.width(),
|
| + image_height = image_bounds_.height();
|
| + int layer_width = bounds().width(), layer_height = bounds().height();
|
| + int layer_border_right = border_.width() - border_.x(),
|
| + layer_border_bottom = border_.height() - border_.y();
|
| + int image_aperture_right = image_width - image_aperture_.right(),
|
| + image_aperture_bottom = image_height - image_aperture_.bottom();
|
| + int layer_occlusion_right = layer_width - layer_occlusion_.right(),
|
| + layer_occlusion_bottom = layer_height - layer_occlusion_.bottom();
|
| + gfx::Rect image_occlusion(BoundsToRect(
|
| + border_.x() == 0 ? 0 : (layer_occlusion_.x() * image_aperture_.x() /
|
| + border_.x()),
|
| + border_.y() == 0 ? 0 : (layer_occlusion_.y() * image_aperture_.y() /
|
| + border_.y()),
|
| + image_width - (layer_border_right == 0 ? 0 : layer_occlusion_right *
|
| + image_aperture_right /
|
| + layer_border_right),
|
| + image_height - (layer_border_bottom == 0 ? 0 : layer_occlusion_bottom *
|
| + image_aperture_bottom /
|
| + layer_border_bottom)));
|
| + gfx::Rect layer_aperture(border_.x(), border_.y(),
|
| + layer_width - border_.width(),
|
| + layer_height - border_.height());
|
|
|
| std::vector<Patch> patches;
|
| patches.reserve(kMaxOcclusionPatches);
|
| @@ -222,14 +242,14 @@ NinePatchLayerImpl::ComputeQuadsWithOcclusion() const {
|
| BoundsToRect(layer_occlusion_.right(), 0, layer_width,
|
| layer_aperture.y())));
|
|
|
| - // Right-center.
|
| + // Left-center.
|
| patches.push_back(
|
| Patch(BoundsToRect(0, image_aperture_.y(), image_occlusion.x(),
|
| image_aperture_.bottom()),
|
| BoundsToRect(0, layer_aperture.y(), layer_occlusion_.x(),
|
| layer_aperture.bottom())));
|
|
|
| - // Left-center.
|
| + // Right-center.
|
| patches.push_back(
|
| Patch(BoundsToRect(image_occlusion.right(), image_aperture_.y(),
|
| image_width, image_aperture_.bottom()),
|
| @@ -297,10 +317,10 @@ void NinePatchLayerImpl::AppendQuads(
|
|
|
| std::vector<Patch> patches;
|
|
|
| - if (!layer_occlusion_.IsEmpty() && border_.IsEmpty() && !fill_center_)
|
| - patches = ComputeQuadsWithOcclusion();
|
| - else
|
| + if (layer_occlusion_.IsEmpty() || fill_center_)
|
| patches = ComputeQuadsWithoutOcclusion();
|
| + else
|
| + patches = ComputeQuadsWithOcclusion();
|
|
|
| const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
|
| const bool opaque = layer_tree_impl()->IsUIResourceOpaque(ui_resource_id_);
|
|
|