chromium/third_party/blink/renderer/platform/testing/paint_property_test_helpers.h

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_PAINT_PROPERTY_TEST_HELPERS_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_PAINT_PROPERTY_TEST_HELPERS_H_

#include "third_party/blink/renderer/platform/graphics/paint/clip_paint_property_node.h"
#include "third_party/blink/renderer/platform/graphics/paint/effect_paint_property_node.h"
#include "third_party/blink/renderer/platform/graphics/paint/property_tree_state.h"
#include "third_party/blink/renderer/platform/graphics/paint/scroll_paint_property_node.h"
#include "third_party/blink/renderer/platform/graphics/paint/transform_paint_property_node.h"
#include "ui/gfx/geometry/transform.h"

namespace blink {

inline gfx::Transform MakeScaleMatrix(double tx, double ty, double tz = 1) {}

inline gfx::Transform MakeScaleMatrix(double s) {}

inline gfx::Transform MakeTranslationMatrix(double tx,
                                            double ty,
                                            double tz = 0) {}

inline gfx::Transform MakeRotationMatrix(double degrees) {}

inline gfx::Transform MakeRotationMatrix(double degrees_x,
                                         double degrees_y,
                                         double degrees_z) {}

// Convenient shorthands.
inline const TransformPaintPropertyNode& t0() {}
inline const ClipPaintPropertyNode& c0() {}
inline const EffectPaintPropertyNode& e0() {}
inline const ScrollPaintPropertyNode& s0() {}

constexpr int c0_id =;
constexpr int e0_id =;
constexpr int t0_id =;

inline EffectPaintPropertyNode* CreateOpacityEffect(
    const EffectPaintPropertyNodeOrAlias& parent,
    const TransformPaintPropertyNodeOrAlias& local_transform_space,
    const ClipPaintPropertyNodeOrAlias* output_clip,
    float opacity,
    CompositingReasons compositing_reasons = CompositingReason::kNone) {}

inline EffectPaintPropertyNode* CreateOpacityEffect(
    const EffectPaintPropertyNodeOrAlias& parent,
    float opacity,
    CompositingReasons compositing_reasons = CompositingReason::kNone) {}

inline EffectPaintPropertyNode* CreateAnimatingOpacityEffect(
    const EffectPaintPropertyNodeOrAlias& parent,
    float opacity = 1.f,
    const ClipPaintPropertyNodeOrAlias* output_clip = nullptr) {}

inline EffectPaintPropertyNode* CreateFilterEffect(
    const EffectPaintPropertyNodeOrAlias& parent,
    const TransformPaintPropertyNodeOrAlias& local_transform_space,
    const ClipPaintPropertyNodeOrAlias* output_clip,
    CompositorFilterOperations filter,
    CompositingReasons compositing_reasons = CompositingReason::kNone) {}

inline EffectPaintPropertyNode* CreateFilterEffect(
    const EffectPaintPropertyNodeOrAlias& parent,
    CompositorFilterOperations filter,
    CompositingReasons compositing_reasons = CompositingReason::kNone) {}

inline EffectPaintPropertyNode* CreateAnimatingFilterEffect(
    const EffectPaintPropertyNodeOrAlias& parent,
    CompositorFilterOperations filter = CompositorFilterOperations(),
    const ClipPaintPropertyNodeOrAlias* output_clip = nullptr) {}

inline EffectPaintPropertyNode* CreateBackdropFilterEffect(
    const EffectPaintPropertyNodeOrAlias& parent,
    const TransformPaintPropertyNodeOrAlias& local_transform_space,
    const ClipPaintPropertyNodeOrAlias* output_clip,
    CompositorFilterOperations backdrop_filter,
    float opacity = 1.0f,
    CompositingReasons compositing_reasons =
        CompositingReason::kBackdropFilter) {}

inline EffectPaintPropertyNode* CreateBackdropFilterEffect(
    const EffectPaintPropertyNodeOrAlias& parent,
    CompositorFilterOperations backdrop_filter,
    CompositingReasons compositing_reasons =
        CompositingReason::kBackdropFilter) {}

inline EffectPaintPropertyNode* CreateAnimatingBackdropFilterEffect(
    const EffectPaintPropertyNodeOrAlias& parent,
    CompositorFilterOperations backdrop_filter = CompositorFilterOperations(),
    const ClipPaintPropertyNodeOrAlias* output_clip = nullptr) {}

inline ClipPaintPropertyNode* CreateClip(
    const ClipPaintPropertyNodeOrAlias& parent,
    const TransformPaintPropertyNodeOrAlias& local_transform_space,
    const gfx::RectF& layout_clip_rect,
    const FloatRoundedRect& paint_clip_rect) {}

inline ClipPaintPropertyNode* CreateClip(
    const ClipPaintPropertyNodeOrAlias& parent,
    const TransformPaintPropertyNodeOrAlias& local_transform_space,
    const FloatRoundedRect& clip_rect) {}

inline ClipPaintPropertyNode* CreatePixelMovingFilterClipExpander(
    const ClipPaintPropertyNodeOrAlias& parent,
    const EffectPaintPropertyNode& pixel_moving_filter) {}

inline void UpdateClip(ClipPaintPropertyNode& clip,
                       const gfx::RectF& layout_clip_rect,
                       const FloatRoundedRect& paint_clip_rect) {}

inline void UpdateClip(ClipPaintPropertyNode& clip,
                       const FloatRoundedRect& clip_rect) {}

inline ClipPaintPropertyNode* CreateClipPathClip(
    const ClipPaintPropertyNodeOrAlias& parent,
    const TransformPaintPropertyNodeOrAlias& local_transform_space,
    const FloatRoundedRect& clip_rect) {}

inline TransformPaintPropertyNode* Create2DTranslation(
    const TransformPaintPropertyNodeOrAlias& parent,
    float x,
    float y) {}

inline TransformPaintPropertyNode* CreateFixedPositionTranslation(
    const TransformPaintPropertyNodeOrAlias& parent,
    float offset_x,
    float offset_y,
    const TransformPaintPropertyNode& scroll_translation_for_fixed) {}

inline TransformPaintPropertyNode* CreateTransform(
    const TransformPaintPropertyNodeOrAlias& parent,
    const gfx::Transform& matrix,
    const gfx::Point3F& origin = gfx::Point3F(),
    CompositingReasons compositing_reasons = CompositingReason::kNone) {}

inline TransformPaintPropertyNode* CreateAnimatingTransform(
    const TransformPaintPropertyNodeOrAlias& parent,
    const gfx::Transform& matrix = gfx::Transform(),
    const gfx::Point3F& origin = gfx::Point3F()) {}

inline TransformPaintPropertyNode* CreateScrollTranslation(
    const TransformPaintPropertyNodeOrAlias& parent,
    float offset_x,
    float offset_y,
    const ScrollPaintPropertyNode& scroll,
    CompositingReasons compositing_reasons = CompositingReason::kNone) {}

inline TransformPaintPropertyNode* CreateScrollTranslation(
    const TransformPaintPropertyNodeOrAlias& parent_transform,
    const ScrollPaintPropertyNode& parent_scroll,
    float offset_x,
    float offset_y,
    const gfx::Rect& container_rect,
    const gfx::Size& contents_size,
    const ClipPaintPropertyNode* overflow_clip,
    CompositingReasons compositing_reasons = CompositingReason::kNone,
    MainThreadScrollingReasons main_thread_reasons =
        cc::MainThreadScrollingReason::kNotOpaqueForTextAndLCDText) {}

inline const ScrollPaintPropertyNode& DefaultParentScroll(
    const TransformPaintPropertyNodeOrAlias& parent_transform) {}

inline TransformPaintPropertyNode* CreateCompositedScrollTranslation(
    const TransformPaintPropertyNodeOrAlias& parent_transform,
    float offset_x,
    float offset_y,
    const ScrollPaintPropertyNode& scroll) {}

inline TransformPaintPropertyNode* CreateCompositedScrollTranslation(
    const TransformPaintPropertyNodeOrAlias& parent_transform,
    const ScrollPaintPropertyNode& parent_scroll,
    float offset_x,
    float offset_y,
    const gfx::Rect& container_rect,
    const gfx::Size& contents_size,
    const ClipPaintPropertyNode* overflow_clip,
    MainThreadScrollingReasons main_thread_reasons =
        cc::MainThreadScrollingReason::kNotScrollingOnMain) {}

inline PropertyTreeState CreateScrollTranslationState(
    const PropertyTreeState& parent_state,
    const ScrollPaintPropertyNode& parent_scroll,
    float offset_x,
    float offset_y,
    const gfx::Rect& container_rect,
    const gfx::Size& contents_size,
    CompositingReasons compositing_reasons = CompositingReason::kNone,
    MainThreadScrollingReasons main_thread_reasons =
        cc::MainThreadScrollingReason::kNotOpaqueForTextAndLCDText) {}

inline PropertyTreeState CreateScrollTranslationState(
    const PropertyTreeState& parent_state,
    float offset_x,
    float offset_y,
    const gfx::Rect& container_rect,
    const gfx::Size& contents_size,
    CompositingReasons compositing_reasons = CompositingReason::kNone,
    MainThreadScrollingReasons main_thread_reasons =
        cc::MainThreadScrollingReason::kNotOpaqueForTextAndLCDText) {}

inline PropertyTreeState CreateCompositedScrollTranslationState(
    const PropertyTreeState& parent_state,
    const ScrollPaintPropertyNode& parent_scroll,
    float offset_x,
    float offset_y,
    const gfx::Rect& container_rect,
    const gfx::Size& contents_size,
    MainThreadScrollingReasons main_thread_reasons =
        cc::MainThreadScrollingReason::kNotScrollingOnMain) {}

inline PropertyTreeState CreateCompositedScrollTranslationState(
    const PropertyTreeState& parent_state,
    float offset_x,
    float offset_y,
    const gfx::Rect& container_rect,
    const gfx::Size& contents_size,
    MainThreadScrollingReasons main_thread_reasons =
        cc::MainThreadScrollingReason::kNotScrollingOnMain) {}

inline PropertyTreeState DefaultPaintChunkProperties() {}

// Checked downcast from *PaintPropertyNodeOrAlias to *PaintPropertyNode.
// This is used in tests that expect the node to be an unaliased node.
inline const ClipPaintPropertyNode& ToUnaliased(
    const ClipPaintPropertyNodeOrAlias& node) {}
inline const EffectPaintPropertyNode& ToUnaliased(
    const EffectPaintPropertyNodeOrAlias& node) {}
inline const TransformPaintPropertyNode& ToUnaliased(
    const TransformPaintPropertyNodeOrAlias& node) {}

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_PAINT_PROPERTY_TEST_HELPERS_H_