Commit 91cea234 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Remove malloc of HitTestingTransformState, and instead allocate on the stack.

To do this, use the base::Optional pattern instead of a scoped_refptr.

Bug: 459810

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I64ada0722e1e04b1f0402c6d3e9d2ed4879164dd
Reviewed-on: https://chromium-review.googlesource.com/1226072
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591445}
parent b3cb7ce6
......@@ -26,13 +26,11 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_HIT_TESTING_TRANSFORM_STATE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_HIT_TESTING_TRANSFORM_STATE_H_
#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/platform/geometry/float_point.h"
#include "third_party/blink/renderer/platform/geometry/float_quad.h"
#include "third_party/blink/renderer/platform/geometry/int_size.h"
#include "third_party/blink/renderer/platform/transforms/affine_transform.h"
#include "third_party/blink/renderer/platform/transforms/transformation_matrix.h"
#include "third_party/blink/renderer/platform/wtf/ref_counted.h"
namespace blink {
......@@ -42,18 +40,22 @@ namespace blink {
// removed and replaced with TransformState. There are some minor differences
// (like the way translate() works slightly differently than move()) so care has
// to be taken when this is done.
class HitTestingTransformState : public RefCounted<HitTestingTransformState> {
class HitTestingTransformState {
public:
static scoped_refptr<HitTestingTransformState> Create(const FloatPoint& p,
const FloatQuad& quad,
const FloatQuad& area) {
return base::AdoptRef(new HitTestingTransformState(p, quad, area));
}
HitTestingTransformState(const FloatPoint& p,
const FloatQuad& quad,
const FloatQuad& area)
: last_planar_point_(p),
last_planar_quad_(quad),
last_planar_area_(area),
accumulating_transform_(false) {}
static scoped_refptr<HitTestingTransformState> Create(
const HitTestingTransformState& other) {
return base::AdoptRef(new HitTestingTransformState(other));
}
HitTestingTransformState(const HitTestingTransformState& other)
: last_planar_point_(other.last_planar_point_),
last_planar_quad_(other.last_planar_quad_),
last_planar_area_(other.last_planar_area_),
accumulated_transform_(other.accumulated_transform_),
accumulating_transform_(other.accumulating_transform_) {}
enum TransformAccumulation { kFlattenTransform, kAccumulateTransform };
void Translate(int x, int y, TransformAccumulation);
......@@ -73,21 +75,6 @@ class HitTestingTransformState : public RefCounted<HitTestingTransformState> {
bool accumulating_transform_;
private:
HitTestingTransformState(const FloatPoint& p,
const FloatQuad& quad,
const FloatQuad& area)
: last_planar_point_(p),
last_planar_quad_(quad),
last_planar_area_(area),
accumulating_transform_(false) {}
HitTestingTransformState(const HitTestingTransformState& other)
: RefCounted<HitTestingTransformState>(),
last_planar_point_(other.last_planar_point_),
last_planar_quad_(other.last_planar_quad_),
last_planar_area_(other.last_planar_area_),
accumulated_transform_(other.accumulated_transform_),
accumulating_transform_(other.accumulating_transform_) {}
void FlattenWithTransform(const TransformationMatrix&);
};
......
......@@ -49,6 +49,7 @@
#include "base/auto_reset.h"
#include "base/macros.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/hit_testing_transform_state.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/paint/clip_rects_cache.h"
#include "third_party/blink/renderer/core/paint/paint_layer_clipper.h"
......@@ -1131,14 +1132,14 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
HitTestResult&,
const HitTestRecursionData& recursion_data,
bool applied_transform,
const HitTestingTransformState* = nullptr,
HitTestingTransformState* = nullptr,
double* z_offset = nullptr);
PaintLayer* HitTestLayerByApplyingTransform(
PaintLayer* root_layer,
PaintLayer* container_layer,
HitTestResult&,
const HitTestRecursionData& recursion_data,
const HitTestingTransformState* = nullptr,
HitTestingTransformState* = nullptr,
double* z_offset = nullptr,
const LayoutPoint& translation_offset = LayoutPoint());
PaintLayer* HitTestChildren(
......@@ -1146,13 +1147,13 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
PaintLayer* root_layer,
HitTestResult&,
const HitTestRecursionData& recursion_data,
const HitTestingTransformState*,
HitTestingTransformState*,
double* z_offset_for_descendants,
double* z_offset,
const HitTestingTransformState* unflattened_transform_state,
HitTestingTransformState* unflattened_transform_state,
bool depth_sort_descendants);
scoped_refptr<HitTestingTransformState> CreateLocalTransformState(
HitTestingTransformState CreateLocalTransformState(
PaintLayer* root_layer,
PaintLayer* container_layer,
const HitTestRecursionData& recursion_data,
......@@ -1169,14 +1170,13 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
const HitTestLocation&,
HitTestFilter,
bool& inside_clip_rect) const;
PaintLayer* HitTestTransformedLayerInFragments(
PaintLayer* root_layer,
PaintLayer* container_layer,
HitTestResult&,
const HitTestRecursionData&,
const HitTestingTransformState*,
double* z_offset,
ShouldRespectOverflowClipType);
PaintLayer* HitTestTransformedLayerInFragments(PaintLayer* root_layer,
PaintLayer* container_layer,
HitTestResult&,
const HitTestRecursionData&,
HitTestingTransformState*,
double* z_offset,
ShouldRespectOverflowClipType);
bool HitTestClippedOutByClipPath(PaintLayer* root_layer,
const HitTestLocation&) const;
......
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