blob: aacce7f02c2cca1e13ab35de2e4b44c94709a7da [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// 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_CORE_PAINT_SVG_ROOT_PAINTER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_SVG_ROOT_PAINTER_H_
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
namespace blink {
class AffineTransform;
class IntRect;
class LayoutSVGRoot;
struct PaintInfo;
struct PhysicalOffset;
class SVGRootPainter {
STACK_ALLOCATED();
public:
SVGRootPainter(const LayoutSVGRoot& layout_svg_root)
: layout_svg_root_(layout_svg_root) {}
void PaintReplaced(const PaintInfo&, const PhysicalOffset& paint_offset);
// The embedded SVG document uses an unsnapped viewport box for layout, while
// SVG root's border box ultimately gets snapped during paint. This
// translate/scale transform is applied to compensate the difference, in
// addition to applying the local to border box transform.
AffineTransform TransformToPixelSnappedBorderBox(
const PhysicalOffset& paint_offset) const;
private:
IntRect PixelSnappedSize(const PhysicalOffset& paint_offset) const;
const LayoutSVGRoot& layout_svg_root_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_SVG_ROOT_PAINTER_H_