summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/skia/ImageSkia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/skia/ImageSkia.cpp')
-rw-r--r--WebCore/platform/graphics/skia/ImageSkia.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/WebCore/platform/graphics/skia/ImageSkia.cpp b/WebCore/platform/graphics/skia/ImageSkia.cpp
index d7f2830..cb089bb 100644
--- a/WebCore/platform/graphics/skia/ImageSkia.cpp
+++ b/WebCore/platform/graphics/skia/ImageSkia.cpp
@@ -38,7 +38,6 @@
#include "GraphicsContext.h"
#include "Logging.h"
#include "NativeImageSkia.h"
-#include "NotImplemented.h"
#include "PlatformContextSkia.h"
#include "PlatformString.h"
#include "SkiaUtils.h"
@@ -226,6 +225,12 @@ static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImag
SkPaint paint;
paint.setPorterDuffXfermode(compOp);
paint.setFilterBitmap(true);
+ int alpha = roundf(platformContext->getAlpha() * 256);
+ if (alpha > 255)
+ alpha = 255;
+ else if (alpha < 0)
+ alpha = 0;
+ paint.setAlpha(alpha);
skia::PlatformCanvas* canvas = platformContext->canvas();
@@ -305,7 +310,8 @@ void Image::drawPattern(GraphicsContext* context,
CompositeOperator compositeOp,
const FloatRect& destRect)
{
- if (destRect.isEmpty() || floatSrcRect.isEmpty())
+ FloatRect normSrcRect = normalizeRect(floatSrcRect);
+ if (destRect.isEmpty() || normSrcRect.isEmpty())
return; // nothing to draw
NativeImageSkia* bitmap = nativeImageForCurrentFrame();
@@ -316,7 +322,7 @@ void Image::drawPattern(GraphicsContext* context,
// it will internally reference the old bitmap's pixels, adjusting the row
// stride so the extra pixels appear as padding to the subsetted bitmap.
SkBitmap srcSubset;
- SkIRect srcRect = enclosingIntRect(floatSrcRect);
+ SkIRect srcRect = enclosingIntRect(normSrcRect);
bitmap->extractSubset(&srcSubset, srcRect);
SkBitmap resampled;
@@ -363,9 +369,9 @@ void Image::drawPattern(GraphicsContext* context,
// origin of the destination rect, which is what WebKit expects. Skia uses
// the coordinate system origin as the base for the patter. If WebKit wants
// a shifted image, it will shift it from there using the patternTransform.
- float adjustedX = phase.x() + floatSrcRect.x() *
+ float adjustedX = phase.x() + normSrcRect.x() *
narrowPrecisionToFloat(patternTransform.a());
- float adjustedY = phase.y() + floatSrcRect.y() *
+ float adjustedY = phase.y() + normSrcRect.y() *
narrowPrecisionToFloat(patternTransform.d());
matrix.postTranslate(SkFloatToScalar(adjustedX),
SkFloatToScalar(adjustedY));