skia2/experimental/svg/model/SkSVGNode.h
borenet a5344ee50a Revert of [SVGDom] Opacity optimization (patchset #4 id:60001 of https://codereview.chromium.org/2353503005/ )
Reason for revert:
Failing assertion

Original issue's description:
> [SVGDom] Opacity optimization
>
> Apply opacity as fill/stroke paint alpha instead of saveLayer, when
> possible.
>
> R=robertphillips@google.com,stephana@google.com,reed@google.com
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2353503005
>
> Committed: https://skia.googlesource.com/skia/+/3dbb7b9f196d793fbd16243157ee67638891f5dc

TBR=reed@google.com,robertphillips@google.com,stephana@google.com,fmalita@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.chromium.org/2359603002
2016-09-20 13:39:46 -07:00

82 lines
2.0 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkSVGNode_DEFINED
#define SkSVGNode_DEFINED
#include "SkRefCnt.h"
#include "SkSVGAttribute.h"
class SkCanvas;
class SkMatrix;
class SkPaint;
class SkSVGRenderContext;
class SkSVGValue;
enum class SkSVGTag {
kCircle,
kDefs,
kEllipse,
kG,
kLine,
kLinearGradient,
kPath,
kPolygon,
kPolyline,
kRect,
kStop,
kSvg
};
class SkSVGNode : public SkRefCnt {
public:
virtual ~SkSVGNode();
SkSVGTag tag() const { return fTag; }
virtual void appendChild(sk_sp<SkSVGNode>) = 0;
void render(const SkSVGRenderContext&) const;
bool asPaint(const SkSVGRenderContext&, SkPaint*) const;
void setAttribute(SkSVGAttribute, const SkSVGValue&);
void setFill(const SkSVGPaint&);
void setFillOpacity(const SkSVGNumberType&);
void setOpacity(const SkSVGNumberType&);
void setStroke(const SkSVGPaint&);
void setStrokeOpacity(const SkSVGNumberType&);
void setStrokeWidth(const SkSVGLength&);
protected:
SkSVGNode(SkSVGTag);
// Called before onRender(), to apply local attributes to the context. Unlike onRender(),
// onPrepareToRender() bubbles up the inheritance chain: overriders should always call
// INHERITED::onPrepareToRender(), unless they intend to short-circuit rendering
// (return false).
// Implementations are expected to return true if rendering is to continue, or false if
// the node/subtree rendering is disabled.
virtual bool onPrepareToRender(SkSVGRenderContext*) const;
virtual void onRender(const SkSVGRenderContext&) const = 0;
virtual bool onAsPaint(const SkSVGRenderContext&, SkPaint*) const { return false; }
virtual void onSetAttribute(SkSVGAttribute, const SkSVGValue&);
private:
SkSVGTag fTag;
// FIXME: this should be sparse
SkSVGPresentationAttributes fPresentationAttributes;
typedef SkRefCnt INHERITED;
};
#endif // SkSVGNode_DEFINED