summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/skia
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/skia')
-rw-r--r--WebCore/platform/graphics/skia/FontCustomPlatformData.cpp4
-rw-r--r--WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp43
-rw-r--r--WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp3
-rw-r--r--WebCore/platform/graphics/skia/GraphicsContextSkia.cpp43
-rw-r--r--WebCore/platform/graphics/skia/ImageBufferSkia.cpp51
-rw-r--r--WebCore/platform/graphics/skia/ImageSkia.cpp59
-rw-r--r--WebCore/platform/graphics/skia/PlatformContextSkia.cpp25
-rw-r--r--WebCore/platform/graphics/skia/PlatformContextSkia.h4
-rw-r--r--WebCore/platform/graphics/skia/SkiaFontWin.cpp11
-rw-r--r--WebCore/platform/graphics/skia/SkiaUtils.cpp2
10 files changed, 168 insertions, 77 deletions
diff --git a/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp b/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp
index 2ea568b..161fee9 100644
--- a/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp
+++ b/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp
@@ -65,7 +65,7 @@ FontCustomPlatformData::~FontCustomPlatformData()
#endif
}
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontRenderingMode mode)
+FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, FontRenderingMode mode)
{
#if OS(WINDOWS)
ASSERT(m_fontReference);
@@ -102,7 +102,7 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b
return FontPlatformData(hfont, size);
#elif OS(LINUX) || OS(FREEBSD) || PLATFORM(BREWMP)
ASSERT(m_fontReference);
- return FontPlatformData(m_fontReference, "", size, bold && !m_fontReference->isBold(), italic && !m_fontReference->isItalic());
+ return FontPlatformData(m_fontReference, "", size, bold && !m_fontReference->isBold(), italic && !m_fontReference->isItalic(), orientation);
#else
notImplemented();
return FontPlatformData();
diff --git a/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp b/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp
index 6024d43..66e6839 100644
--- a/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp
+++ b/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp
@@ -32,6 +32,7 @@
#include "GlyphPageTreeNode.h"
#include "Font.h"
+#include "HarfbuzzSkia.h"
#include "SimpleFontData.h"
#include "SkTemplates.h"
@@ -40,6 +41,36 @@
namespace WebCore {
+static int substituteWithVerticalGlyphs(const SimpleFontData* fontData, uint16_t* glyphs, unsigned bufferLength)
+{
+ HB_FaceRec_* hbFace = fontData->platformData().harfbuzzFace();
+ if (!hbFace->gsub) {
+ // if there is no GSUB table, treat it as not covered
+ return 0Xffff;
+ }
+
+ HB_Buffer buffer;
+ hb_buffer_new(&buffer);
+ for (unsigned i = 0; i < bufferLength; ++i)
+ hb_buffer_add_glyph(buffer, glyphs[i], 0, i);
+
+ HB_UShort scriptIndex;
+ HB_UShort featureIndex;
+
+ HB_GSUB_Select_Script(hbFace->gsub, HB_MAKE_TAG('D', 'F', 'L', 'T'), &scriptIndex);
+ HB_GSUB_Select_Feature(hbFace->gsub, HB_MAKE_TAG('v', 'e', 'r', 't'), scriptIndex, 0xffff, &featureIndex);
+ HB_GSUB_Add_Feature(hbFace->gsub, featureIndex, 1);
+ HB_GSUB_Select_Feature(hbFace->gsub, HB_MAKE_TAG('v', 'r', 't', '2'), scriptIndex, 0xffff, &featureIndex);
+ HB_GSUB_Add_Feature(hbFace->gsub, featureIndex, 1);
+
+ int error = HB_GSUB_Apply_String(hbFace->gsub, buffer);
+ if (!error) {
+ for (unsigned i = 0; i < bufferLength; ++i)
+ glyphs[i] = static_cast<Glyph>(buffer->out_string[i].gindex);
+ }
+ return error;
+}
+
bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
{
if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) {
@@ -60,6 +91,18 @@ bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned b
return false;
}
+ if ((fontData->orientation() == Vertical) && (!fontData->isBrokenIdeographFont())) {
+ bool lookVariants = false;
+ for (unsigned i = 0; i < bufferLength; ++i) {
+ if (!Font::isCJKIdeograph(buffer[i])) {
+ lookVariants = true;
+ continue;
+ }
+ }
+ if (lookVariants)
+ substituteWithVerticalGlyphs(fontData, glyphs, bufferLength);
+ }
+
unsigned allGlyphs = 0; // track if any of the glyphIDs are non-zero
for (unsigned i = 0; i < length; i++) {
setGlyphDataForIndex(offset + i, glyphs[i], glyphs[i] ? fontData : NULL);
diff --git a/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp b/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp
index cbe6775..8b7ac86 100644
--- a/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp
+++ b/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp
@@ -53,7 +53,8 @@ bool GraphicsContext3D::getImageData(Image* image,
NativeImageSkia* skiaImage = 0;
AlphaOp neededAlphaOp = AlphaDoNothing;
if (image->data()) {
- ImageSource decoder(false, ignoreGammaAndColorProfile);
+ ImageSource decoder(ImageSource::AlphaNotPremultiplied,
+ ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied);
decoder.setData(image->data(), true);
if (!decoder.frameCount() || !decoder.frameIsCompleteAtIndex(0))
return false;
diff --git a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
index 7c0bcd1..1b217ee 100644
--- a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
+++ b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
@@ -37,7 +37,6 @@
#include "GLES2Canvas.h"
#include "Gradient.h"
#include "GraphicsContextPlatformPrivate.h"
-#include "GraphicsContextPrivate.h"
#include "ImageBuffer.h"
#include "IntRect.h"
#include "NativeImageSkia.h"
@@ -219,17 +218,15 @@ void addCornerArc(SkPath* path, const SkRect& rect, const IntSize& size, int sta
// This may be called with a NULL pointer to create a graphics context that has
// no painting.
-GraphicsContext::GraphicsContext(PlatformGraphicsContext* gc)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate(gc))
+void GraphicsContext::platformInit(PlatformGraphicsContext* gc)
{
+ m_data = new GraphicsContextPlatformPrivate(gc);
setPaintingDisabled(!gc || !platformContext()->canvas());
}
-GraphicsContext::~GraphicsContext()
+void GraphicsContext::platformDestroy()
{
delete m_data;
- this->destroyGraphicsContextPrivate(m_common);
}
PlatformGraphicsContext* GraphicsContext::platformContext() const
@@ -420,11 +417,15 @@ void GraphicsContext::clipOut(const Path& p)
platformContext()->canvas()->clipPath(path, SkRegion::kDifference_Op);
}
-void GraphicsContext::clipPath(WindRule clipRule)
+void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule)
{
if (paintingDisabled())
return;
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(pathToClip);
+
SkPath path = platformContext()->currentPathInLocalCoordinates();
if (!isPathSkiaSafe(getCTM(), path))
return;
@@ -723,18 +724,22 @@ void GraphicsContext::drawRect(const IntRect& rect)
platformContext()->drawRect(r);
}
-void GraphicsContext::fillPath()
+void GraphicsContext::fillPath(const Path& pathToFill)
{
if (paintingDisabled())
return;
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(pathToFill);
+
SkPath path = platformContext()->currentPathInLocalCoordinates();
if (!isPathSkiaSafe(getCTM(), path))
return;
platformContext()->prepareForSoftwareDraw();
- const GraphicsContextState& state = m_common->state;
+ const GraphicsContextState& state = m_state;
path.setFillType(state.fillRule == RULE_EVENODD ?
SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType);
@@ -921,7 +926,7 @@ void GraphicsContext::setAlpha(float alpha)
platformContext()->setAlpha(alpha);
}
-void GraphicsContext::setCompositeOperation(CompositeOperator op)
+void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op)
{
if (paintingDisabled())
return;
@@ -1061,13 +1066,15 @@ void GraphicsContext::setPlatformShadow(const FloatSize& size,
double height = size.height();
double blur = blurFloat;
- // TODO(tc): This still does not address the issue that shadows
- // within canvas elements should ignore transforms.
- if (m_common->state.shadowsIgnoreTransforms) {
+ SkBlurDrawLooper::BlurFlags blurFlags = SkBlurDrawLooper::kNone_BlurFlag;
+
+ if (m_state.shadowsIgnoreTransforms) {
// Currently only the GraphicsContext associated with the
// CanvasRenderingContext for HTMLCanvasElement have shadows ignore
// Transforms. So with this flag set, we know this state is associated
// with a CanvasRenderingContext.
+ blurFlags = SkBlurDrawLooper::kIgnoreTransform_BlurFlag;
+
// CG uses natural orientation for Y axis, but the HTML5 canvas spec
// does not.
// So we now flip the height since it was flipped in
@@ -1083,7 +1090,7 @@ void GraphicsContext::setPlatformShadow(const FloatSize& size,
// TODO(tc): Should we have a max value for the blur? CG clamps at 1000.0
// for perf reasons.
- SkDrawLooper* dl = new SkBlurDrawLooper(blur / 2, width, height, c);
+ SkDrawLooper* dl = new SkBlurDrawLooper(blur / 2, width, height, c, blurFlags);
platformContext()->setDrawLooper(dl);
dl->unref();
}
@@ -1128,7 +1135,7 @@ void GraphicsContext::setPlatformStrokePattern(Pattern* pattern)
platformContext()->setStrokeShader(pattern->platformPattern(getCTM()));
}
-void GraphicsContext::setPlatformTextDrawingMode(int mode)
+void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags mode)
{
if (paintingDisabled())
return;
@@ -1177,11 +1184,15 @@ void GraphicsContext::strokeArc(const IntRect& r, int startAngle, int angleSpan)
platformContext()->canvas()->drawPath(path, paint);
}
-void GraphicsContext::strokePath()
+void GraphicsContext::strokePath(const Path& pathToStroke)
{
if (paintingDisabled())
return;
+ // FIXME: Be smarter about this.
+ beginPath();
+ addPath(pathToStroke);
+
SkPath path = platformContext()->currentPathInLocalCoordinates();
if (!isPathSkiaSafe(getCTM(), path))
return;
diff --git a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
index adb732b..468ccda 100644
--- a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
+++ b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
@@ -40,6 +40,8 @@
#include "GLES2Canvas.h"
#include "GraphicsContext.h"
#include "ImageData.h"
+#include "JPEGImageEncoder.h"
+#include "MIMETypeRegistry.h"
#include "PNGImageEncoder.h"
#include "PlatformContextSkia.h"
#include "SkColorPriv.h"
@@ -60,7 +62,7 @@ ImageBufferData::ImageBufferData(const IntSize& size)
{
}
-ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, ColorSpace, RenderingMode, bool& success)
: m_data(size)
, m_size(size)
{
@@ -244,14 +246,6 @@ PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect
return getImageData<Premultiplied>(rect, *context()->platformContext()->bitmap(), m_size);
}
-// This function does the equivalent of (a * b + 254) / 255, without an integer divide.
-// Valid for a, b in the range [0..255].
-unsigned mulDiv255Ceil(unsigned a, unsigned b)
-{
- unsigned value = a * b + 255;
- return (value + (value >> 8)) >> 8;
-}
-
template <Multiply multiplied>
void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint& destPoint,
const SkBitmap& bitmap, const IntSize& size)
@@ -295,9 +289,9 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
const unsigned char* srcPixel = &srcRow[x * 4];
if (multiplied == Unmultiplied) {
unsigned char alpha = srcPixel[3];
- unsigned char r = mulDiv255Ceil(srcPixel[0], alpha);
- unsigned char g = mulDiv255Ceil(srcPixel[1], alpha);
- unsigned char b = mulDiv255Ceil(srcPixel[2], alpha);
+ unsigned char r = SkMulDiv255Ceiling(srcPixel[0], alpha);
+ unsigned char g = SkMulDiv255Ceiling(srcPixel[1], alpha);
+ unsigned char b = SkMulDiv255Ceiling(srcPixel[2], alpha);
destRow[x] = SkPackARGB32(alpha, r, g, b);
} else
destRow[x] = SkPackARGB32(srcPixel[3], srcPixel[0],
@@ -318,20 +312,27 @@ void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& so
putImageData<Premultiplied>(source, sourceRect, destPoint, *context()->platformContext()->bitmap(), m_size);
}
-String ImageBuffer::toDataURL(const String&, const double*) const
+String ImageBuffer::toDataURL(const String& mimeType, const double* quality) const
{
- // Encode the image into a vector.
- Vector<unsigned char> pngEncodedData;
- PNGImageEncoder::encode(*context()->platformContext()->bitmap(), &pngEncodedData);
-
- // Convert it into base64.
- Vector<char> base64EncodedData;
- base64Encode(*reinterpret_cast<Vector<char>*>(&pngEncodedData), base64EncodedData);
- // Append with a \0 so that it's a valid string.
- base64EncodedData.append('\0');
-
- // And the resulting string.
- return makeString("data:image/png;base64,", base64EncodedData.data());
+ ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
+
+ Vector<unsigned char> encodedImage;
+ if (mimeType == "image/jpeg") {
+ int compressionQuality = JPEGImageEncoder::DefaultCompressionQuality;
+ if (quality && *quality >= 0.0 && *quality <= 1.0)
+ compressionQuality = static_cast<int>(*quality * 100 + 0.5);
+ if (!JPEGImageEncoder::encode(*context()->platformContext()->bitmap(), compressionQuality, &encodedImage))
+ return "data:,";
+ } else {
+ if (!PNGImageEncoder::encode(*context()->platformContext()->bitmap(), &encodedImage))
+ return "data:,";
+ ASSERT(mimeType == "image/png");
+ }
+
+ Vector<char> base64Data;
+ base64Encode(*reinterpret_cast<Vector<char>*>(&encodedImage), base64Data);
+
+ return makeString("data:", mimeType, ";base64,", base64Data);
}
} // namespace WebCore
diff --git a/WebCore/platform/graphics/skia/ImageSkia.cpp b/WebCore/platform/graphics/skia/ImageSkia.cpp
index ae2653a..c7fa6f4 100644
--- a/WebCore/platform/graphics/skia/ImageSkia.cpp
+++ b/WebCore/platform/graphics/skia/ImageSkia.cpp
@@ -143,7 +143,9 @@ static ResamplingMode computeResamplingMode(PlatformContextSkia* platformContext
// Everything else gets resampled.
// If the platform context permits high quality interpolation, use it.
- if (platformContext->interpolationQuality() == InterpolationHigh)
+ // High quality interpolation only enabled for scaling and translation.
+ if (platformContext->interpolationQuality() == InterpolationHigh
+ && !(platformContext->canvas()->getTotalMatrix().getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)))
return RESAMPLE_AWESOME;
return RESAMPLE_LINEAR;
@@ -178,17 +180,32 @@ static void drawResampledBitmap(SkCanvas& canvas, SkPaint& paint, const NativeIm
SkIRect resizedImageRect = // Represents the size of the resized image.
{ 0, 0, destRectRounded.width(), destRectRounded.height() };
- if (srcIsFull && bitmap.hasResizedBitmap(destRectRounded.width(), destRectRounded.height())) {
+ // Apply forward transform to destRect to estimate required size of
+ // re-sampled bitmap, and use only in calls required to resize, or that
+ // check for the required size.
+ SkRect destRectTransformed;
+ canvas.getTotalMatrix().mapRect(&destRectTransformed, destRect);
+ SkIRect destRectTransformedRounded;
+ destRectTransformed.round(&destRectTransformedRounded);
+
+ if (srcIsFull && bitmap.hasResizedBitmap(destRectTransformedRounded.width(), destRectTransformedRounded.height())) {
// Yay, this bitmap frame already has a resized version.
- SkBitmap resampled = bitmap.resizedBitmap(destRectRounded.width(), destRectRounded.height());
+ SkBitmap resampled = bitmap.resizedBitmap(destRectTransformedRounded.width(), destRectTransformedRounded.height());
canvas.drawBitmapRect(resampled, 0, destRect, &paint);
return;
}
// Compute the visible portion of our rect.
+ // We also need to compute the transformed portion of the
+ // visible portion for use below.
SkRect destBitmapSubsetSk;
ClipRectToCanvas(canvas, destRect, &destBitmapSubsetSk);
+ SkRect destBitmapSubsetTransformed;
+ canvas.getTotalMatrix().mapRect(&destBitmapSubsetTransformed, destBitmapSubsetSk);
destBitmapSubsetSk.offset(-destRect.fLeft, -destRect.fTop);
+ SkIRect destBitmapSubsetTransformedRounded;
+ destBitmapSubsetTransformed.round(&destBitmapSubsetTransformedRounded);
+ destBitmapSubsetTransformedRounded.offset(-destRectTransformedRounded.fLeft, -destRectTransformedRounded.fTop);
// The matrix inverting, etc. could have introduced rounding error which
// causes the bounds to be outside of the resized bitmap. We round outward
@@ -207,27 +224,33 @@ static void drawResampledBitmap(SkCanvas& canvas, SkPaint& paint, const NativeIm
destBitmapSubsetSkI.height())) {
// We're supposed to resize the entire image and cache it, even though
// we don't need all of it.
- SkBitmap resampled = bitmap.resizedBitmap(destRectRounded.width(),
- destRectRounded.height());
+ SkBitmap resampled = bitmap.resizedBitmap(destRectTransformedRounded.width(),
+ destRectTransformedRounded.height());
canvas.drawBitmapRect(resampled, 0, destRect, &paint);
} else {
// We should only resize the exposed part of the bitmap to do the
// minimal possible work.
// Resample the needed part of the image.
- SkBitmap resampled = skia::ImageOperations::Resize(subset,
- skia::ImageOperations::RESIZE_LANCZOS3,
- destRectRounded.width(), destRectRounded.height(),
- destBitmapSubsetSkI);
-
- // Compute where the new bitmap should be drawn. Since our new bitmap
- // may be smaller than the original, we have to shift it over by the
- // same amount that we cut off the top and left.
- destBitmapSubsetSkI.offset(destRect.fLeft, destRect.fTop);
- SkRect offsetDestRect;
- offsetDestRect.set(destBitmapSubsetSkI);
-
- canvas.drawBitmapRect(resampled, 0, offsetDestRect, &paint);
+ // Transforms above plus rounding may cause destBitmapSubsetTransformedRounded
+ // to go outside the image, so need to clip to avoid problems.
+ if (destBitmapSubsetTransformedRounded.intersect(0, 0,
+ destRectTransformedRounded.width(), destRectTransformedRounded.height())) {
+
+ SkBitmap resampled = skia::ImageOperations::Resize(subset,
+ skia::ImageOperations::RESIZE_LANCZOS3,
+ destRectTransformedRounded.width(), destRectTransformedRounded.height(),
+ destBitmapSubsetTransformedRounded);
+
+ // Compute where the new bitmap should be drawn. Since our new bitmap
+ // may be smaller than the original, we have to shift it over by the
+ // same amount that we cut off the top and left.
+ destBitmapSubsetSkI.offset(destRect.fLeft, destRect.fTop);
+ SkRect offsetDestRect;
+ offsetDestRect.set(destBitmapSubsetSkI);
+
+ canvas.drawBitmapRect(resampled, 0, offsetDestRect, &paint);
+ }
}
}
diff --git a/WebCore/platform/graphics/skia/PlatformContextSkia.cpp b/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
index d610c2a..d3c0e00 100644
--- a/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
+++ b/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
@@ -94,8 +94,8 @@ struct PlatformContextSkia::State {
SkPaint::Join m_lineJoin;
SkDashPathEffect* m_dash;
- // Text. (See cTextFill & friends in GraphicsContext.h.)
- int m_textDrawingMode;
+ // Text. (See TextModeFill & friends in GraphicsContext.h.)
+ TextDrawingModeFlags m_textDrawingMode;
// Helper function for applying the state's alpha value to the given input
// color to produce a new output color.
@@ -137,7 +137,7 @@ PlatformContextSkia::State::State()
, m_lineCap(SkPaint::kDefault_Cap)
, m_lineJoin(SkPaint::kDefault_Join)
, m_dash(0)
- , m_textDrawingMode(cTextFill)
+ , m_textDrawingMode(TextModeFill)
, m_interpolationQuality(InterpolationHigh)
, m_canvasClipApplied(false)
{
@@ -299,6 +299,9 @@ void PlatformContextSkia::clipPathAntiAliased(const SkPath& clipPath)
if (!haveLayerOutstanding) {
SkRect bounds = clipPath.getBounds();
canvas()->saveLayerAlpha(&bounds, 255, static_cast<SkCanvas::SaveFlags>(SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag | SkCanvas::kClipToLayer_SaveFlag));
+ // Guards state modification during clipped operations.
+ // The state is popped in applyAntiAliasedClipPaths().
+ canvas()->save();
}
}
@@ -494,6 +497,9 @@ void PlatformContextSkia::setStrokeThickness(float thickness)
void PlatformContextSkia::setStrokeShader(SkShader* strokeShader)
{
+ if (strokeShader)
+ m_state->m_strokeColor = Color::black;
+
if (strokeShader != m_state->m_strokeShader) {
SkSafeUnref(m_state->m_strokeShader);
m_state->m_strokeShader = strokeShader;
@@ -501,7 +507,7 @@ void PlatformContextSkia::setStrokeShader(SkShader* strokeShader)
}
}
-int PlatformContextSkia::getTextDrawingMode() const
+TextDrawingModeFlags PlatformContextSkia::getTextDrawingMode() const
{
return m_state->m_textDrawingMode;
}
@@ -521,11 +527,11 @@ int PlatformContextSkia::getNormalizedAlpha() const
return alpha;
}
-void PlatformContextSkia::setTextDrawingMode(int mode)
+void PlatformContextSkia::setTextDrawingMode(TextDrawingModeFlags mode)
{
- // cTextClip is never used, so we assert that it isn't set:
+ // TextModeClip is never used, so we assert that it isn't set:
// https://bugs.webkit.org/show_bug.cgi?id=21898
- ASSERT(!(mode & cTextClip));
+ ASSERT(!(mode & TextModeClip));
m_state->m_textDrawingMode = mode;
}
@@ -578,6 +584,9 @@ void PlatformContextSkia::setFillRule(SkPath::FillType fr)
void PlatformContextSkia::setFillShader(SkShader* fillShader)
{
+ if (fillShader)
+ m_state->m_fillColor = Color::black;
+
if (fillShader != m_state->m_fillShader) {
SkSafeUnref(m_state->m_fillShader);
m_state->m_fillShader = fillShader;
@@ -675,6 +684,8 @@ void PlatformContextSkia::applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths)
// When we call restore on the SkCanvas, the layer's bitmap is composed
// into the layer below and we end up with correct, anti-aliased clipping.
+ m_canvas->restore();
+
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kClear_Mode);
paint.setAntiAlias(true);
diff --git a/WebCore/platform/graphics/skia/PlatformContextSkia.h b/WebCore/platform/graphics/skia/PlatformContextSkia.h
index 110085d..11b311a 100644
--- a/WebCore/platform/graphics/skia/PlatformContextSkia.h
+++ b/WebCore/platform/graphics/skia/PlatformContextSkia.h
@@ -125,14 +125,14 @@ public:
void setStrokeColor(SkColor);
void setStrokeThickness(float thickness);
void setStrokeShader(SkShader*);
- void setTextDrawingMode(int mode);
+ void setTextDrawingMode(TextDrawingModeFlags mode);
void setUseAntialiasing(bool enable);
void setDashPathEffect(SkDashPathEffect*);
SkDrawLooper* getDrawLooper() const;
StrokeStyle getStrokeStyle() const;
float getStrokeThickness() const;
- int getTextDrawingMode() const;
+ TextDrawingModeFlags getTextDrawingMode() const;
float getAlpha() const;
int getNormalizedAlpha() const;
diff --git a/WebCore/platform/graphics/skia/SkiaFontWin.cpp b/WebCore/platform/graphics/skia/SkiaFontWin.cpp
index 6acfd35..5046c50 100644
--- a/WebCore/platform/graphics/skia/SkiaFontWin.cpp
+++ b/WebCore/platform/graphics/skia/SkiaFontWin.cpp
@@ -225,8 +225,9 @@ bool windowsCanHandleDrawTextShadow(GraphicsContext *context)
FloatSize shadowOffset;
float shadowBlur;
Color shadowColor;
+ ColorSpace shadowColorSpace;
- bool hasShadow = context->getShadow(shadowOffset, shadowBlur, shadowColor);
+ bool hasShadow = context->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
return (hasShadow && (shadowBlur == 0) && (shadowColor.alpha() == 255) && (context->fillColor().alpha() == 255));
}
@@ -242,7 +243,7 @@ bool windowsCanHandleTextDrawing(GraphicsContext* context)
return false;
// Check for stroke effects.
- if (context->platformContext()->getTextDrawingMode() != cTextFill)
+ if (context->platformContext()->getTextDrawingMode() != TextModeFill)
return false;
// Check for gradients.
@@ -307,7 +308,7 @@ bool paintSkiaText(GraphicsContext* context,
HGDIOBJ oldFont = SelectObject(dc, hfont);
PlatformContextSkia* platformContext = context->platformContext();
- int textMode = platformContext->getTextDrawingMode();
+ TextDrawingModeFlags textMode = platformContext->getTextDrawingMode();
// Filling (if necessary). This is the common case.
SkPaint paint;
@@ -315,7 +316,7 @@ bool paintSkiaText(GraphicsContext* context,
paint.setFlags(SkPaint::kAntiAlias_Flag);
bool didFill = false;
- if ((textMode & cTextFill) && SkColorGetA(paint.getColor())) {
+ if ((textMode & TextModeFill) && SkColorGetA(paint.getColor())) {
if (!skiaDrawText(hfont, dc, platformContext->canvas(), *origin, &paint,
&glyphs[0], &advances[0], &offsets[0], numGlyphs))
return false;
@@ -323,7 +324,7 @@ bool paintSkiaText(GraphicsContext* context,
}
// Stroking on top (if necessary).
- if ((textMode & cTextStroke)
+ if ((textMode & TextModeStroke)
&& platformContext->getStrokeStyle() != NoStroke
&& platformContext->getStrokeThickness() > 0) {
diff --git a/WebCore/platform/graphics/skia/SkiaUtils.cpp b/WebCore/platform/graphics/skia/SkiaUtils.cpp
index b16a344..da83793 100644
--- a/WebCore/platform/graphics/skia/SkiaUtils.cpp
+++ b/WebCore/platform/graphics/skia/SkiaUtils.cpp
@@ -108,7 +108,7 @@ SkXfermode::Mode WebCoreCompositeToSkiaComposite(CompositeOperator op)
return (SkXfermode::Mode)table[i].m_xfermodeMode;
}
- SkDEBUGF(("GraphicsContext::setCompositeOperation uknown CompositeOperator %d\n", op));
+ SkDEBUGF(("GraphicsContext::setPlatformCompositeOperation unknown CompositeOperator %d\n", op));
return SkXfermode::kSrcOver_Mode; // fall-back
}