Commit e337262e authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

[BGPT] Remove a bunch more fields from GraphicsLayer.

This improves BGPT testing, and slims GraphicsLayer a bit.

Bug: 883949
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I77d5108dd2309de33a52ca90e3592c2d22ea28a0
Reviewed-on: https://chromium-review.googlesource.com/1247037
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594837}
parent 2085232e
......@@ -2762,7 +2762,7 @@ Color CompositedLayerMapping::LayoutObjectBackgroundColor() const {
}
void CompositedLayerMapping::UpdateBackgroundColor() {
auto color = LayoutObjectBackgroundColor();
auto color = LayoutObjectBackgroundColor().Rgb();
graphics_layer_->SetBackgroundColor(color);
if (scrolling_contents_layer_)
scrolling_contents_layer_->SetBackgroundColor(color);
......
......@@ -45,8 +45,10 @@ void AddTransformJSONProperties(const GraphicsLayer* layer,
if (!transform.IsIdentity())
json.SetArray("transform", TransformAsJSONArray(transform));
if (!transform.IsIdentityOrTranslation())
json.SetArray("origin", PointAsJSONArray(layer->TransformOrigin()));
if (!transform.IsIdentityOrTranslation()) {
json.SetArray("origin",
PointAsJSONArray(FloatPoint3D(layer->TransformOrigin())));
}
AddFlattenInheritedTransformJSON(layer, json);
......@@ -117,9 +119,9 @@ std::unique_ptr<JSONObject> GraphicsLayerAsJSON(
if (flags & kLayerTreeIncludesDebugInfo)
json->SetString("client", PointerAsString(&layer->Client()));
if (layer->BackgroundColor().Alpha()) {
if (Color(layer->BackgroundColor()).Alpha()) {
json->SetString("backgroundColor",
layer->BackgroundColor().NameForLayoutTreeAsText());
Color(layer->BackgroundColor()).NameForLayoutTreeAsText());
}
if (flags & kOutputAsLayerTree) {
......
......@@ -38,6 +38,7 @@
#include "third_party/blink/renderer/platform/wtf/text/text_stream.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/skia/include/core/SkPoint.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/scroll_offset.h"
namespace blink {
......@@ -119,6 +120,10 @@ FloatPoint::operator gfx::Vector2dF() const {
return gfx::Vector2dF(x_, y_);
}
FloatPoint::operator gfx::Point3F() const {
return gfx::Point3F(x_, y_, 0.f);
}
std::ostream& operator<<(std::ostream& ostream, const FloatPoint& point) {
return ostream << point.ToString();
}
......
......@@ -47,6 +47,7 @@ struct SkPoint;
namespace gfx {
class PointF;
class Point3F;
class ScrollOffset;
class Vector2dF;
}
......@@ -140,6 +141,7 @@ class PLATFORM_EXPORT FloatPoint {
operator gfx::PointF() const;
explicit operator gfx::ScrollOffset() const;
explicit operator gfx::Vector2dF() const;
operator gfx::Point3F() const;
String ToString() const;
......
......@@ -30,6 +30,9 @@
namespace blink {
FloatPoint3D::FloatPoint3D(const gfx::Point3F& point)
: x_(point.x()), y_(point.y()), z_(point.z()) {}
void FloatPoint3D::Normalize() {
float temp_length = length();
......
......@@ -47,6 +47,8 @@ class PLATFORM_EXPORT FloatPoint3D {
constexpr FloatPoint3D(const FloatPoint3D& p)
: x_(p.X()), y_(p.Y()), z_(p.Z()) {}
FloatPoint3D(const gfx::Point3F&);
constexpr float X() const { return x_; }
void SetX(float x) { x_ = x; }
......
......@@ -78,17 +78,9 @@ std::unique_ptr<GraphicsLayer> GraphicsLayer::Create(
GraphicsLayer::GraphicsLayer(GraphicsLayerClient& client)
: client_(client),
background_color_(Color::kTransparent),
opacity_(1),
blend_mode_(BlendMode::kNormal),
has_transform_origin_(false),
contents_opaque_(false),
prevent_contents_opaque_changes_(false),
should_flatten_transform_(true),
backface_visibility_(true),
draws_content_(false),
contents_visible_(true),
is_root_for_isolated_group_(false),
hit_testable_without_draws_content_(false),
needs_check_raster_invalidation_(false),
has_scroll_parent_(false),
......@@ -107,14 +99,14 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient& client)
client.VerifyNotPainting();
#endif
layer_ = cc::PictureLayer::Create(this);
layer_->SetIsDrawable(draws_content_ && contents_visible_);
layer_->SetLayerClient(weak_ptr_factory_.GetWeakPtr());
CcLayer()->SetIsDrawable(draws_content_ && contents_visible_);
CcLayer()->SetLayerClient(weak_ptr_factory_.GetWeakPtr());
UpdateTrackingRasterInvalidations();
}
GraphicsLayer::~GraphicsLayer() {
layer_->SetLayerClient(nullptr);
CcLayer()->SetLayerClient(nullptr);
SetContentsLayer(nullptr);
for (size_t i = 0; i < link_highlights_.size(); ++i)
link_highlights_[i]->ClearCurrentGraphicsLayer();
......@@ -136,17 +128,17 @@ LayoutRect GraphicsLayer::VisualRect() const {
void GraphicsLayer::SetHasWillChangeTransformHint(
bool has_will_change_transform) {
layer_->SetHasWillChangeTransformHint(has_will_change_transform);
CcLayer()->SetHasWillChangeTransformHint(has_will_change_transform);
}
void GraphicsLayer::SetOverscrollBehavior(
const cc::OverscrollBehavior& behavior) {
layer_->SetOverscrollBehavior(behavior);
CcLayer()->SetOverscrollBehavior(behavior);
}
void GraphicsLayer::SetSnapContainerData(
base::Optional<SnapContainerData> data) {
layer_->SetSnapContainerData(std::move(data));
CcLayer()->SetSnapContainerData(std::move(data));
}
void GraphicsLayer::SetIsResizedByBrowserControls(
......@@ -342,7 +334,7 @@ bool GraphicsLayer::Paint(const IntRect* interest_rect,
GetPaintController().AppendDebugDrawingAfterCommit(std::move(record),
layer_state_->state);
// Ensure the compositor will raster the under-invalidation overlay.
layer_->SetNeedsDisplay();
CcLayer()->SetNeedsDisplay();
}
}
......@@ -414,12 +406,12 @@ void GraphicsLayer::UpdateLayerIsDrawable() {
// shouldn't receive the drawsContent flag, so it is only given
// contentsVisible.
layer_->SetIsDrawable(draws_content_ && contents_visible_);
CcLayer()->SetIsDrawable(draws_content_ && contents_visible_);
if (cc::Layer* contents_layer = ContentsLayerIfRegistered())
contents_layer->SetIsDrawable(contents_visible_);
if (draws_content_) {
layer_->SetNeedsDisplay();
CcLayer()->SetNeedsDisplay();
for (size_t i = 0; i < link_highlights_.size(); ++i)
link_highlights_[i]->Invalidate();
}
......@@ -523,7 +515,7 @@ void GraphicsLayer::SetupContentsLayer(cc::Layer* contents_layer) {
// Insert the content layer first. Video elements require this, because they
// have shadow content that must display in front of the video.
layer_->InsertChild(contents_layer_, 0);
CcLayer()->InsertChild(contents_layer_, 0);
cc::PictureLayer* border_cc_layer =
contents_clipping_mask_layer_ ? contents_clipping_mask_layer_->CcLayer()
: nullptr;
......@@ -636,18 +628,18 @@ const gfx::PointF& GraphicsLayer::GetPosition() const {
}
const gfx::Size& GraphicsLayer::Size() const {
return layer_->bounds();
return CcLayer()->bounds();
}
void GraphicsLayer::SetSize(const gfx::Size& size) {
DCHECK(size.width() >= 0 && size.height() >= 0);
if (size == layer_->bounds())
if (size == CcLayer()->bounds())
return;
Invalidate(PaintInvalidationReason::kIncremental); // as DisplayItemClient.
layer_->SetBounds(size);
CcLayer()->SetBounds(size);
// Note that we don't resize m_contentsLayer. It's up the caller to do that.
}
......@@ -656,19 +648,20 @@ void GraphicsLayer::SetTransform(const TransformationMatrix& transform) {
CcLayer()->SetTransform(TransformationMatrix::ToTransform(transform));
}
void GraphicsLayer::SetTransformOrigin(const FloatPoint3D& transform_origin) {
has_transform_origin_ = true;
transform_origin_ = transform_origin;
void GraphicsLayer::SetTransformOrigin(const gfx::Point3F& transform_origin) {
CcLayer()->SetTransformOrigin(transform_origin);
}
void GraphicsLayer::SetShouldFlattenTransform(bool should_flatten) {
if (should_flatten == should_flatten_transform_)
return;
const gfx::Point3F& GraphicsLayer::TransformOrigin() const {
return CcLayer()->transform_origin();
}
should_flatten_transform_ = should_flatten;
bool GraphicsLayer::ShouldFlattenTransform() const {
return CcLayer()->should_flatten_transform();
}
layer_->SetShouldFlattenTransform(should_flatten);
void GraphicsLayer::SetShouldFlattenTransform(bool should_flatten) {
CcLayer()->SetShouldFlattenTransform(should_flatten);
}
void GraphicsLayer::SetRenderingContext(int context) {
......@@ -676,18 +669,18 @@ void GraphicsLayer::SetRenderingContext(int context) {
return;
rendering_context3d_ = context;
layer_->Set3dSortingContextId(context);
CcLayer()->Set3dSortingContextId(context);
if (contents_layer_)
contents_layer_->Set3dSortingContextId(rendering_context3d_);
CcLayer()->Set3dSortingContextId(rendering_context3d_);
}
bool GraphicsLayer::MasksToBounds() const {
return layer_->masks_to_bounds();
return CcLayer()->masks_to_bounds();
}
void GraphicsLayer::SetMasksToBounds(bool masks_to_bounds) {
layer_->SetMasksToBounds(masks_to_bounds);
CcLayer()->SetMasksToBounds(masks_to_bounds);
}
void GraphicsLayer::SetDrawsContent(bool draws_content) {
......@@ -719,25 +712,28 @@ void GraphicsLayer::SetContentsVisible(bool contents_visible) {
void GraphicsLayer::SetClipParent(cc::Layer* parent) {
has_clip_parent_ = !!parent;
layer_->SetClipParent(parent);
CcLayer()->SetClipParent(parent);
}
void GraphicsLayer::SetScrollParent(cc::Layer* parent) {
has_scroll_parent_ = !!parent;
layer_->SetScrollParent(parent);
CcLayer()->SetScrollParent(parent);
}
void GraphicsLayer::SetBackgroundColor(const Color& color) {
if (color == background_color_)
return;
RGBA32 GraphicsLayer::BackgroundColor() const {
return CcLayer()->background_color();
}
background_color_ = color;
layer_->SetBackgroundColor(background_color_.Rgb());
void GraphicsLayer::SetBackgroundColor(RGBA32 color) {
CcLayer()->SetBackgroundColor(color);
}
bool GraphicsLayer::ContentsOpaque() const {
return CcLayer()->contents_opaque();
}
void GraphicsLayer::SetContentsOpaque(bool opaque) {
contents_opaque_ = opaque;
layer_->SetContentsOpaque(contents_opaque_);
CcLayer()->SetContentsOpaque(opaque);
ClearContentsLayerIfUnregistered();
if (contents_layer_ && !prevent_contents_opaque_changes_)
contents_layer_->SetContentsOpaque(opaque);
......@@ -749,7 +745,7 @@ void GraphicsLayer::SetMaskLayer(GraphicsLayer* mask_layer,
return;
mask_layer_ = mask_layer;
layer_->SetMaskLayer(mask_layer_ ? mask_layer_->CcLayer() : nullptr);
CcLayer()->SetMaskLayer(mask_layer_ ? mask_layer_->CcLayer() : nullptr);
if (mask_layer_)
mask_layer_->CcLayer()->set_is_rounded_corner_mask(is_rounded_corner_mask);
}
......@@ -773,28 +769,35 @@ void GraphicsLayer::SetContentsClippingMaskLayer(
UpdateContentsRect();
}
bool GraphicsLayer::BackfaceVisibility() const {
return CcLayer()->double_sided();
}
void GraphicsLayer::SetBackfaceVisibility(bool visible) {
backface_visibility_ = visible;
CcLayer()->SetDoubleSided(backface_visibility_);
CcLayer()->SetDoubleSided(visible);
}
void GraphicsLayer::SetOpacity(float opacity) {
float clamped_opacity = clampTo(opacity, 0.0f, 1.0f);
opacity_ = clamped_opacity;
CcLayer()->SetOpacity(opacity);
}
float GraphicsLayer::Opacity() const {
return CcLayer()->opacity();
}
void GraphicsLayer::SetBlendMode(BlendMode blend_mode) {
if (blend_mode_ == blend_mode)
return;
blend_mode_ = blend_mode;
CcLayer()->SetBlendMode(WebCoreBlendModeToSkBlendMode(blend_mode));
}
BlendMode GraphicsLayer::GetBlendMode() const {
return BlendModeFromSkBlendMode(CcLayer()->blend_mode());
}
bool GraphicsLayer::IsRootForIsolatedGroup() const {
return CcLayer()->is_root_for_isolated_group();
}
void GraphicsLayer::SetIsRootForIsolatedGroup(bool isolated) {
if (is_root_for_isolated_group_ == isolated)
return;
is_root_for_isolated_group_ = isolated;
CcLayer()->SetIsRootForIsolatedGroup(isolated);
}
......@@ -817,7 +820,7 @@ void GraphicsLayer::SetNeedsDisplay() {
if (!DrawsContent())
return;
layer_->SetNeedsDisplay();
CcLayer()->SetNeedsDisplay();
for (size_t i = 0; i < link_highlights_.size(); ++i)
link_highlights_[i]->Invalidate();
......@@ -833,7 +836,7 @@ void GraphicsLayer::SetNeedsDisplay() {
void GraphicsLayer::SetNeedsDisplayInRect(const IntRect& rect) {
DCHECK(DrawsContent());
layer_->SetNeedsDisplayRect(rect);
CcLayer()->SetNeedsDisplayRect(rect);
for (auto* link_highlight : link_highlights_)
link_highlight->Invalidate();
}
......@@ -911,7 +914,7 @@ void GraphicsLayer::SetBackdropFilters(CompositorFilterOperations filters) {
void GraphicsLayer::SetStickyPositionConstraint(
const cc::LayerStickyPositionConstraint& sticky_constraint) {
layer_->SetStickyPositionConstraint(sticky_constraint);
CcLayer()->SetStickyPositionConstraint(sticky_constraint);
}
void GraphicsLayer::SetFilterQuality(SkFilterQuality filter_quality) {
......
......@@ -139,8 +139,8 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient,
const gfx::PointF& GetPosition() const;
void SetPosition(const gfx::PointF&);
const FloatPoint3D& TransformOrigin() const { return transform_origin_; }
void SetTransformOrigin(const FloatPoint3D&);
const gfx::Point3F& TransformOrigin() const;
void SetTransformOrigin(const gfx::Point3F&);
// The size of the layer.
const gfx::Size& Size() const;
......@@ -148,14 +148,14 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient,
const TransformationMatrix& Transform() const { return transform_; }
void SetTransform(const TransformationMatrix&);
bool ShouldFlattenTransform() const;
void SetShouldFlattenTransform(bool);
void SetRenderingContext(int id);
bool MasksToBounds() const;
void SetMasksToBounds(bool);
bool IsRootForIsolatedGroup() const { return is_root_for_isolated_group_; }
bool DrawsContent() const { return draws_content_; }
void SetDrawsContent(bool);
......@@ -168,23 +168,22 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient,
// For special cases, e.g. drawing missing tiles on Android.
// The compositor should never paint this color in normal cases because the
// Layer will paint the background by itself.
Color BackgroundColor() const { return background_color_; }
void SetBackgroundColor(const Color&);
RGBA32 BackgroundColor() const;
void SetBackgroundColor(RGBA32);
// Opaque means that we know the layer contents have no alpha.
bool ContentsOpaque() const { return contents_opaque_; }
bool ContentsOpaque() const;
void SetContentsOpaque(bool);
bool BackfaceVisibility() const { return backface_visibility_; }
bool BackfaceVisibility() const;
void SetBackfaceVisibility(bool visible);
bool ShouldFlattenTransform() const { return should_flatten_transform_; }
float Opacity() const { return opacity_; }
float Opacity() const;
void SetOpacity(float);
BlendMode GetBlendMode() const { return blend_mode_; }
BlendMode GetBlendMode() const;
void SetBlendMode(BlendMode);
bool IsRootForIsolatedGroup() const;
void SetIsRootForIsolatedGroup(bool);
void SetHitTestableWithoutDrawsContent(bool);
......@@ -370,21 +369,10 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient,
IntSize offset_from_layout_object_;
TransformationMatrix transform_;
FloatPoint3D transform_origin_;
Color background_color_;
float opacity_;
BlendMode blend_mode_;
bool has_transform_origin_ : 1;
bool contents_opaque_ : 1;
bool prevent_contents_opaque_changes_ : 1;
bool should_flatten_transform_ : 1;
bool backface_visibility_ : 1;
bool draws_content_ : 1;
bool contents_visible_ : 1;
bool is_root_for_isolated_group_ : 1;
bool hit_testable_without_draws_content_ : 1;
bool needs_check_raster_invalidation_ : 1;
......
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