RenderSVGResourceSolidColor.cpp [plain text]
#include "config.h"
#include "RenderSVGResourceSolidColor.h"
#include "Frame.h"
#include "FrameView.h"
#include "GraphicsContext.h"
#include "RenderStyle.h"
#include "RenderView.h"
namespace WebCore {
RenderSVGResourceType RenderSVGResourceSolidColor::s_resourceType = SolidColorResourceType;
RenderSVGResourceSolidColor::RenderSVGResourceSolidColor()
{
}
RenderSVGResourceSolidColor::~RenderSVGResourceSolidColor()
{
}
bool RenderSVGResourceSolidColor::applyResource(RenderElement& renderer, const RenderStyle& style, GraphicsContext*& context, unsigned short resourceMode)
{
ASSERT(context);
ASSERT(resourceMode != ApplyToDefaultMode);
const SVGRenderStyle& svgStyle = style.svgStyle();
ColorSpace colorSpace = style.colorSpace();
bool isRenderingMask = renderer.view().frameView().paintBehavior() & PaintBehaviorRenderingSVGMask;
if (resourceMode & ApplyToFillMode) {
if (!isRenderingMask)
context->setAlpha(svgStyle.fillOpacity());
else
context->setAlpha(1);
context->setFillColor(m_color, colorSpace);
if (!isRenderingMask)
context->setFillRule(svgStyle.fillRule());
if (resourceMode & ApplyToTextMode)
context->setTextDrawingMode(TextModeFill);
} else if (resourceMode & ApplyToStrokeMode) {
ASSERT(!isRenderingMask);
context->setAlpha(svgStyle.strokeOpacity());
context->setStrokeColor(m_color, colorSpace);
SVGRenderSupport::applyStrokeStyleToContext(context, style, renderer);
if (resourceMode & ApplyToTextMode)
context->setTextDrawingMode(TextModeStroke);
}
return true;
}
void RenderSVGResourceSolidColor::postApplyResource(RenderElement&, GraphicsContext*& context, unsigned short resourceMode, const Path* path, const RenderSVGShape* shape)
{
ASSERT(context);
ASSERT(resourceMode != ApplyToDefaultMode);
if (resourceMode & ApplyToFillMode) {
if (path)
context->fillPath(*path);
else if (shape)
shape->fillShape(context);
}
if (resourceMode & ApplyToStrokeMode) {
if (path)
context->strokePath(*path);
else if (shape)
shape->strokeShape(context);
}
}
}