1 /* 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_RESOURCE_MASKER_H_ 21 #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_RESOURCE_MASKER_H_ 22 23 #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_container.h" 24 #include "third_party/blink/renderer/core/svg/svg_unit_types.h" 25 #include "third_party/blink/renderer/platform/geometry/float_rect.h" 26 #include "third_party/skia/include/core/SkRefCnt.h" 27 28 namespace blink { 29 30 class AffineTransform; 31 class GraphicsContext; 32 class SVGMaskElement; 33 34 class LayoutSVGResourceMasker final : public LayoutSVGResourceContainer { 35 public: 36 explicit LayoutSVGResourceMasker(SVGMaskElement*); 37 ~LayoutSVGResourceMasker() override; 38 GetName()39 const char* GetName() const override { return "LayoutSVGResourceMasker"; } 40 41 void RemoveAllClientsFromCache() override; 42 43 FloatRect ResourceBoundingBox(const FloatRect& reference_box); 44 45 SVGUnitTypes::SVGUnitType MaskUnits() const; 46 SVGUnitTypes::SVGUnitType MaskContentUnits() const; 47 48 static const LayoutSVGResourceType kResourceType = kMaskerResourceType; ResourceType()49 LayoutSVGResourceType ResourceType() const override { return kResourceType; } 50 51 sk_sp<const PaintRecord> CreatePaintRecord(AffineTransform&, 52 const FloatRect&, 53 GraphicsContext&); 54 55 private: 56 void CalculateMaskContentVisualRect(); 57 58 sk_sp<const PaintRecord> cached_paint_record_; 59 FloatRect mask_content_boundaries_; 60 }; 61 62 DEFINE_LAYOUT_SVG_RESOURCE_TYPE_CASTS(LayoutSVGResourceMasker, 63 kMaskerResourceType); 64 65 } // namespace blink 66 67 #endif 68