Index: cc/layers/painted_scrollbar_layer.cc |
diff --git a/cc/layers/painted_scrollbar_layer.cc b/cc/layers/painted_scrollbar_layer.cc |
index 36c9f82f5a810e0bb424d64258462d313e49b6ee..8f4d675bdb0a3ca49a76335faef2bfba10b7fde4 100644 |
--- a/cc/layers/painted_scrollbar_layer.cc |
+++ b/cc/layers/painted_scrollbar_layer.cc |
@@ -4,12 +4,9 @@ |
#include "cc/layers/painted_scrollbar_layer.h" |
-#include <algorithm> |
- |
#include "base/auto_reset.h" |
#include "base/basictypes.h" |
#include "base/trace_event/trace_event.h" |
-#include "cc/base/math_util.h" |
#include "cc/layers/painted_scrollbar_layer_impl.h" |
#include "cc/resources/ui_resource_bitmap.h" |
#include "cc/trees/layer_tree_host.h" |
@@ -19,7 +16,6 @@ |
#include "third_party/skia/include/core/SkBitmap.h" |
#include "third_party/skia/include/core/SkCanvas.h" |
#include "third_party/skia/include/core/SkSize.h" |
-#include "ui/gfx/geometry/size_conversions.h" |
#include "ui/gfx/skia_util.h" |
namespace cc { |
@@ -42,7 +38,6 @@ |
: scrollbar_(scrollbar.Pass()), |
scroll_layer_id_(scroll_layer_id), |
clip_layer_id_(Layer::INVALID_ID), |
- internal_contents_scale_(0.f), |
thumb_thickness_(scrollbar_->ThumbThickness()), |
thumb_length_(scrollbar_->ThumbLength()), |
is_overlay_(scrollbar_->IsOverlay()), |
@@ -87,10 +82,10 @@ |
} |
float PaintedScrollbarLayer::ClampScaleToMaxTextureSize(float scale) { |
- // If the scaled bounds() is bigger than the max texture size of the |
- // device, we need to clamp it by rescaling, since this is used |
+ // If the scaled content_bounds() is bigger than the max texture size of the |
+ // device, we need to clamp it by rescaling, since content_bounds() is used |
// below to set the texture size. |
- gfx::Size scaled_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale)); |
+ gfx::Size scaled_bounds = ComputeContentBoundsForScale(scale, scale); |
if (scaled_bounds.width() > MaxTextureSize() || |
scaled_bounds.height() > MaxTextureSize()) { |
if (scaled_bounds.width() > scaled_bounds.height()) |
@@ -101,16 +96,25 @@ |
return scale; |
} |
+void PaintedScrollbarLayer::CalculateContentsScale( |
+ float ideal_contents_scale, |
+ float* contents_scale_x, |
+ float* contents_scale_y, |
+ gfx::Size* content_bounds) { |
+ ContentsScalingLayer::CalculateContentsScale( |
+ ClampScaleToMaxTextureSize(ideal_contents_scale), |
+ contents_scale_x, |
+ contents_scale_y, |
+ content_bounds); |
+} |
+ |
void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { |
- Layer::PushPropertiesTo(layer); |
+ ContentsScalingLayer::PushPropertiesTo(layer); |
PushScrollClipPropertiesTo(layer); |
PaintedScrollbarLayerImpl* scrollbar_layer = |
static_cast<PaintedScrollbarLayerImpl*>(layer); |
- |
- scrollbar_layer->set_internal_contents_scale_and_bounds( |
- internal_contents_scale_, internal_content_bounds_); |
scrollbar_layer->SetThumbThickness(thumb_thickness_); |
scrollbar_layer->SetThumbLength(thumb_length_); |
@@ -156,7 +160,7 @@ |
thumb_resource_ = nullptr; |
} |
- Layer::SetLayerTreeHost(host); |
+ ContentsScalingLayer::SetLayerTreeHost(host); |
} |
gfx::Rect PaintedScrollbarLayer::ScrollbarLayerRectToContentRect( |
@@ -164,10 +168,10 @@ |
// Don't intersect with the bounds as in LayerRectToContentRect() because |
// layer_rect here might be in coordinates of the containing layer. |
gfx::Rect expanded_rect = gfx::ScaleToEnclosingRect( |
- layer_rect, internal_contents_scale_, internal_contents_scale_); |
- // We should never return a rect bigger than the content bounds. |
+ layer_rect, contents_scale_x(), contents_scale_y()); |
+ // We should never return a rect bigger than the content_bounds(). |
gfx::Size clamped_size = expanded_rect.size(); |
- clamped_size.SetToMin(internal_content_bounds_); |
+ clamped_size.SetToMin(content_bounds()); |
expanded_rect.set_size(clamped_size); |
return expanded_rect; |
} |
@@ -198,36 +202,8 @@ |
} |
} |
-void PaintedScrollbarLayer::UpdateInternalContentScale() { |
- float scale = layer_tree_host()->device_scale_factor(); |
- if (layer_tree_host() |
- ->settings() |
- .layer_transforms_should_scale_layer_contents) { |
- gfx::Vector2dF transform_scales = |
- MathUtil::ComputeTransform2dScaleComponents(draw_transform(), scale); |
- scale = std::max(transform_scales.x(), transform_scales.y()); |
- } |
- bool changed = false; |
- changed |= UpdateProperty(ClampScaleToMaxTextureSize(scale), |
- &internal_contents_scale_); |
- changed |= UpdateProperty( |
- gfx::ToCeiledSize(gfx::ScaleSize(bounds(), internal_contents_scale_)), |
- &internal_content_bounds_); |
- if (changed) { |
- // If the content scale or bounds change, repaint. |
- SetNeedsDisplay(); |
- } |
-} |
- |
bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue, |
const OcclusionTracker<Layer>* occlusion) { |
- { |
- base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, |
- true); |
- Layer::Update(queue, occlusion); |
- UpdateInternalContentScale(); |
- } |
- |
UpdateThumbAndTrackGeometry(); |
gfx::Rect track_layer_rect = gfx::Rect(location_, bounds()); |
@@ -249,7 +225,12 @@ |
if (!has_thumb_ && thumb_resource_) { |
thumb_resource_ = nullptr; |
SetNeedsPushProperties(); |
- updated = true; |
+ } |
+ |
+ { |
+ base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, |
+ true); |
+ ContentsScalingLayer::Update(queue, occlusion); |
} |
if (update_rect_.IsEmpty() && track_resource_) |