Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2245)

Unified Diff: Source/platform/graphics/GraphicsContext.cpp

Issue 416543002: Move logic from NativeImageSkia to GraphicsContext and SkiaUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Test regressions fixed Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/graphics/GraphicsContext.h ('k') | Source/platform/graphics/skia/NativeImageSkia.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/GraphicsContext.cpp
diff --git a/Source/platform/graphics/GraphicsContext.cpp b/Source/platform/graphics/GraphicsContext.cpp
index c3ff6fbec7bf687b2412efceddd52dfe3533ada3..b25ad43ba743ec97a82e34e30c66809ac76399ad 100644
--- a/Source/platform/graphics/GraphicsContext.cpp
+++ b/Source/platform/graphics/GraphicsContext.cpp
@@ -34,6 +34,7 @@
#include "platform/graphics/DisplayList.h"
#include "platform/graphics/Gradient.h"
#include "platform/graphics/ImageBuffer.h"
+#include "platform/graphics/skia/SkiaUtils.h"
#include "platform/text/BidiResolver.h"
#include "platform/text/TextRunIterator.h"
#include "platform/weborigin/KURL.h"
@@ -397,7 +398,7 @@ void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation
mutableState()->setCompositeOperation(compositeOperation, blendMode);
}
-SkColorFilter* GraphicsContext::colorFilter()
+SkColorFilter* GraphicsContext::colorFilter() const
{
return immutableState()->colorFilter();
}
@@ -1856,4 +1857,51 @@ void GraphicsContext::didDrawTextInRect(const SkRect& textRect)
}
}
+void GraphicsContext::preparePaintForDrawRectToRect(
+ SkPaint* paint,
+ const SkRect& srcRect,
+ const SkRect& destRect,
+ CompositeOperator compositeOp,
+ blink::WebBlendMode blendMode,
+ bool isLazyDecoded,
+ bool isDataComplete) const
+{
+ paint->setXfermode(WebCoreCompositeToSkiaComposite(compositeOp, blendMode).get());
+ paint->setColorFilter(this->colorFilter());
+ paint->setAlpha(this->getNormalizedAlpha());
+ paint->setLooper(this->drawLooper());
+ paint->setAntiAlias(shouldDrawAntiAliased(this, destRect));
+
+ InterpolationQuality resampling;
+ if (this->isAccelerated()) {
+ resampling = InterpolationLow;
+ } else if (this->printing()) {
+ resampling = InterpolationNone;
+ } else if (isLazyDecoded) {
+ resampling = InterpolationHigh;
+ } else {
+ // Take into account scale applied to the canvas when computing sampling mode (e.g. CSS scale or page scale).
+ SkRect destRectTarget = destRect;
+ SkMatrix totalMatrix = this->getTotalMatrix();
+ if (!(totalMatrix.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)))
+ totalMatrix.mapRect(&destRectTarget, destRect);
+
+ resampling = computeInterpolationQuality(totalMatrix,
+ SkScalarToFloat(srcRect.width()), SkScalarToFloat(srcRect.height()),
+ SkScalarToFloat(destRectTarget.width()), SkScalarToFloat(destRectTarget.height()),
+ isDataComplete);
+ }
+
+ if (resampling == InterpolationNone) {
+ // FIXME: This is to not break tests (it results in the filter bitmap flag
+ // being set to true). We need to decide if we respect InterpolationNone
+ // being returned from computeInterpolationQuality.
+ resampling = InterpolationLow;
+ }
+ resampling = limitInterpolationQuality(this, resampling);
+
+ bool useBicubicFilter = resampling == InterpolationHigh;
+ paint->setFilterLevel(convertToSkiaFilterLevel(useBicubicFilter, resampling));
+}
+
}
« no previous file with comments | « Source/platform/graphics/GraphicsContext.h ('k') | Source/platform/graphics/skia/NativeImageSkia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698