Chromium Code Reviews| 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..4cf381e7d7fe08275debe816a965a28d0ef02118 100644 |
| --- a/cc/layers/nine_patch_layer_impl.cc |
| +++ b/cc/layers/nine_patch_layer_impl.cc |
| @@ -77,6 +77,26 @@ void NinePatchLayerImpl::SetLayout(const gfx::Rect& aperture, |
| NoteLayerPropertyChanged(); |
| } |
| +bool NinePatchLayerImpl::CanUseOcclusion() { |
| + if (layer_occlusion_.IsEmpty()) |
| + return false; |
| + |
| + if (fill_center_) |
| + return false; |
| + |
| + if (border_.x() == 0 || border_.y() == 0 || |
|
aelias_OOO_until_Jul13
2016/05/05 04:17:57
All this state is known to the client-side code in
llandwerlin-old
2016/05/06 16:26:48
Done.
|
| + (border_.width() - border_.x()) == 0 || |
| + (border_.height() - border_.y()) == 0) |
| + return false; |
| + |
| + if (layer_occlusion_.x() == 0 || layer_occlusion_.y() == 0 || |
| + layer_occlusion_.right() == bounds().width() || |
| + layer_occlusion_.bottom() == bounds().height()) |
| + return false; |
| + |
| + return true; |
| +} |
| + |
| void NinePatchLayerImpl::CheckGeometryLimitations() { |
| // |border| is in layer space. It cannot exceed the bounds of the layer. |
| DCHECK_GE(bounds().width(), border_.width()); |
| @@ -178,14 +198,23 @@ NinePatchLayerImpl::ComputeQuadsWithOcclusion() const { |
| 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()))); |
| + int layer_border_right = border_.width() - border_.x(); |
| + int layer_border_bottom = border_.height() - border_.y(); |
| + int image_aperture_right = image_width - image_aperture_.right(); |
| + int image_aperture_bottom = image_height - image_aperture_.bottom(); |
| + int layer_occlusion_right = layer_width - layer_occlusion_.right(); |
| + int layer_occlusion_bottom = layer_height - layer_occlusion_.bottom(); |
| + gfx::Rect image_occlusion(BoundsToRect( |
| + layer_occlusion_.x() * image_aperture_.x() / border_.x(), |
| + layer_occlusion_.y() * image_aperture_.y() / border_.y(), |
| + image_width - |
| + layer_occlusion_right * image_aperture_right / layer_border_right, |
| + image_height - |
| + 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); |
| @@ -297,7 +326,7 @@ void NinePatchLayerImpl::AppendQuads( |
| std::vector<Patch> patches; |
| - if (!layer_occlusion_.IsEmpty() && border_.IsEmpty() && !fill_center_) |
| + if (CanUseOcclusion()) |
| patches = ComputeQuadsWithOcclusion(); |
| else |
| patches = ComputeQuadsWithoutOcclusion(); |