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

Unified Diff: cc/CCRendererSoftware.cpp

Issue 11121008: Use antialiasing and bitmap filtering when needed in software compositor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/CCRendererSoftware.cpp
diff --git a/cc/CCRendererSoftware.cpp b/cc/CCRendererSoftware.cpp
index 89a758b4f55c6cc6c9cff52b4bc678512d089a13..2cd65360fd6eba1efc5e8c55b6159d23c23c6f9a 100644
--- a/cc/CCRendererSoftware.cpp
+++ b/cc/CCRendererSoftware.cpp
@@ -19,6 +19,7 @@
#include <public/WebImage.h>
#include <public/WebSize.h>
#include <public/WebTransformationMatrix.h>
+#include <limits>
using WebKit::WebCompositorSoftwareOutputDevice;
using WebKit::WebImage;
@@ -53,6 +54,20 @@ void toSkMatrix(SkMatrix* flattened, const WebTransformationMatrix& m)
flattened->set(8, m.m44());
}
+bool isZero(float f)
aelias_OOO_until_Jul13 2012/10/12 21:26:56 No need for this method. You can use SkScalarNear
+{
+ return abs(f) < std::numeric_limits<float>::epsilon();
danakj 2012/10/12 21:24:37 thanks! i think this should be std::abs() as well
+}
+
+bool isScaleAndTranslate(const SkMatrix& matrix)
+{
+ return isZero(matrix[SkMatrix::kMSkewX]) &&
+ isZero(matrix[SkMatrix::kMSkewY]) &&
+ isZero(matrix[SkMatrix::kMPersp0]) &&
+ isZero(matrix[SkMatrix::kMPersp1]) &&
+ isZero(matrix[SkMatrix::kMPersp2] - 1.0f);
+}
+
} // anonymous namespace
PassOwnPtr<CCRendererSoftware> CCRendererSoftware::create(CCRendererClient* client, CCResourceProvider* resourceProvider, WebCompositorSoftwareOutputDevice* outputDevice)
@@ -178,6 +193,10 @@ void CCRendererSoftware::drawQuad(DrawingFrame& frame, const CCDrawQuad* quad)
m_skCurrentCanvas->setMatrix(skDeviceMatrix);
m_skCurrentPaint.reset();
+ if (!isScaleAndTranslate(skDeviceMatrix)) {
+ m_skCurrentPaint.setAntiAlias(true);
+ m_skCurrentPaint.setFilterBitmap(true);
+ }
if (quad->needsBlending()) {
m_skCurrentPaint.setAlpha(quad->opacity() * 255);
m_skCurrentPaint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698