RenderSVGResourceSolidColor.cpp [plain text]
#include "config.h"
#if ENABLE(SVG)
#include "RenderSVGResourceSolidColor.h"
#include "GraphicsContext.h"
#include "SVGRenderSupport.h"
#if PLATFORM(SKIA)
#include "PlatformContextSkia.h"
#endif
namespace WebCore {
RenderSVGResourceType RenderSVGResourceSolidColor::s_resourceType = SolidColorResourceType;
RenderSVGResourceSolidColor::RenderSVGResourceSolidColor()
{
}
RenderSVGResourceSolidColor::~RenderSVGResourceSolidColor()
{
}
bool RenderSVGResourceSolidColor::applyResource(RenderObject* object, RenderStyle* style, GraphicsContext*& context, unsigned short resourceMode)
{
ASSERT(context);
ASSERT(resourceMode != ApplyToDefaultMode);
const SVGRenderStyle* svgStyle = style ? style->svgStyle() : 0;
ColorSpace colorSpace = style ? style->colorSpace() : DeviceColorSpace;
if (resourceMode & ApplyToFillMode) {
context->setAlpha(svgStyle ? svgStyle->fillOpacity() : 1.0f);
context->setFillColor(m_color, colorSpace);
context->setFillRule(svgStyle ? svgStyle->fillRule() : RULE_NONZERO);
if (resourceMode & ApplyToTextMode)
context->setTextDrawingMode(cTextFill);
} else if (resourceMode & ApplyToStrokeMode) {
context->setAlpha(svgStyle ? svgStyle->strokeOpacity() : 1.0f);
context->setStrokeColor(m_color, colorSpace);
if (style)
applyStrokeStyleToContext(context, style, object);
if (resourceMode & ApplyToTextMode)
context->setTextDrawingMode(cTextStroke);
}
return true;
}
void RenderSVGResourceSolidColor::postApplyResource(RenderObject*, GraphicsContext*& context, unsigned short resourceMode)
{
ASSERT(context);
ASSERT(resourceMode != ApplyToDefaultMode);
if (!(resourceMode & ApplyToTextMode)) {
if (resourceMode & ApplyToFillMode)
context->fillPath();
else if (resourceMode & ApplyToStrokeMode)
context->strokePath();
}
#if PLATFORM(SKIA)
context->beginPath();
context->platformContext()->setFillShader(0);
context->platformContext()->setStrokeShader(0);
#endif
}
}
#endif