Diff
Modified: trunk/Source/Platform/ChangeLog (121582 => 121583)
--- trunk/Source/Platform/ChangeLog 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/Platform/ChangeLog 2012-06-29 19:57:29 UTC (rev 121583)
@@ -1,3 +1,15 @@
+2012-06-28 James Robinson <[email protected]>
+
+ [chromium] Remove mapRect and mapQuad from WebTransformationMatrix
+ https://bugs.webkit.org/show_bug.cgi?id=90230
+
+ Reviewed by Adrienne Walker.
+
+ Removes clipping-unaware mapRect, mapQuad and projectPoint functions from the WebTransformationMatrix interface.
+
+ * chromium/public/WebTransformationMatrix.h:
+ (WebTransformationMatrix):
+
2012-06-28 Adrienne Walker <[email protected]>
[chromium] Split WebScrollbar into WebPluginScrollbar and WebScrollbar
Modified: trunk/Source/Platform/chromium/public/WebTransformationMatrix.h (121582 => 121583)
--- trunk/Source/Platform/chromium/public/WebTransformationMatrix.h 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/Platform/chromium/public/WebTransformationMatrix.h 2012-06-29 19:57:29 UTC (rev 121583)
@@ -141,13 +141,9 @@
// FIXME: these map functions should not exist, should be using CCMathUtil
// instead. Eventually CCMathUtil functions could be merged here, but its
// not yet the right time for that.
- WebCore::FloatRect mapRect(const WebCore::FloatRect&) const;
- WebCore::IntRect mapRect(const WebCore::IntRect&) const;
WebCore::FloatPoint3D mapPoint(const WebCore::FloatPoint3D&) const;
WebCore::FloatPoint mapPoint(const WebCore::FloatPoint&) const;
WebCore::IntPoint mapPoint(const WebCore::IntPoint&) const;
- WebCore::FloatQuad mapQuad(const WebCore::FloatQuad&) const;
- WebCore::FloatPoint projectPoint(const WebCore::FloatPoint&, bool* clamped = 0) const;
#endif
protected:
Modified: trunk/Source/WebCore/ChangeLog (121582 => 121583)
--- trunk/Source/WebCore/ChangeLog 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/WebCore/ChangeLog 2012-06-29 19:57:29 UTC (rev 121583)
@@ -1,3 +1,39 @@
+2012-06-28 James Robinson <[email protected]>
+
+ [chromium] Remove mapRect and mapQuad from WebTransformationMatrix
+ https://bugs.webkit.org/show_bug.cgi?id=90230
+
+ Reviewed by Adrienne Walker.
+
+ Replaces calls to WebTransformationMatrix::mapRect/mapQuad with clipping-aware calls to CCMathUtils. In most
+ cases, we do not expect clipping to happen. For others (such as area calculations in CCOverdrawMetrics) we can
+ handle a clipped quad easily.
+
+ * platform/chromium/support/WebTransformationMatrix.cpp:
+ * platform/graphics/chromium/LayerRendererChromium.cpp:
+ (WebCore::LayerRendererChromium::drawRenderPassQuad):
+ (WebCore::LayerRendererChromium::drawTileQuad):
+ * platform/graphics/chromium/RenderSurfaceChromium.cpp:
+ (WebCore::RenderSurfaceChromium::drawableContentRect):
+ * platform/graphics/chromium/cc/CCLayerImpl.cpp:
+ (WebCore::CCLayerImpl::getDrawRect):
+ * platform/graphics/chromium/cc/CCOcclusionTracker.cpp:
+ (WebCore::transformSurfaceOpaqueRegion):
+ (WebCore::addOcclusionBehindLayer):
+ * platform/graphics/chromium/cc/CCOverdrawMetrics.cpp:
+ (WebCore):
+ (WebCore::polygonArea):
+ (WebCore::areaOfMappedQuad):
+ (WebCore::CCOverdrawMetrics::didUpload):
+ (WebCore::CCOverdrawMetrics::didCullForDrawing):
+ (WebCore::CCOverdrawMetrics::didDraw):
+ * platform/graphics/chromium/cc/CCRenderPass.cpp:
+ (WebCore::CCRenderPass::appendQuadsToFillScreen):
+ * platform/graphics/chromium/cc/CCRenderSurface.cpp:
+ (WebCore::CCRenderSurface::drawableContentRect):
+ * platform/graphics/chromium/cc/CCSharedQuadState.cpp:
+ (WebCore::CCSharedQuadState::isLayerAxisAlignedIntRect):
+
2012-06-29 Ryosuke Niwa <[email protected]>
Mac build fix after r121575. It rolls out r121547 but didn't roll out the follow up build fix r121553.
Modified: trunk/Source/WebCore/platform/chromium/support/WebTransformationMatrix.cpp (121582 => 121583)
--- trunk/Source/WebCore/platform/chromium/support/WebTransformationMatrix.cpp 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/WebCore/platform/chromium/support/WebTransformationMatrix.cpp 2012-06-29 19:57:29 UTC (rev 121583)
@@ -422,16 +422,6 @@
return m_private;
}
-FloatRect WebTransformationMatrix::mapRect(const FloatRect& rect) const
-{
- return m_private.mapRect(rect);
-}
-
-IntRect WebTransformationMatrix::mapRect(const IntRect& rect) const
-{
- return m_private.mapRect(rect);
-}
-
FloatPoint3D WebTransformationMatrix::mapPoint(const FloatPoint3D& p) const
{
return m_private.mapPoint(p);
@@ -447,14 +437,4 @@
return m_private.mapPoint(p);
}
-FloatQuad WebTransformationMatrix::mapQuad(const FloatQuad& quad) const
-{
- return m_private.mapQuad(quad);
-}
-
-FloatPoint WebTransformationMatrix::projectPoint(const FloatPoint& p, bool* clamped) const
-{
- return m_private.projectPoint(p, clamped);
-}
-
} // namespace WebKit
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (121582 => 121583)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2012-06-29 19:57:29 UTC (rev 121583)
@@ -587,7 +587,9 @@
if (drawingSurface->hasValidBackgroundTexture())
copyTextureToFramebuffer(drawingSurface->backgroundTexture()->textureId(), quad->quadRect().size(), quad->layerTransform());
- FloatQuad deviceQuad = contentsDeviceTransform.mapQuad(sharedGeometryQuad());
+ bool clipped = false;
+ FloatQuad deviceQuad = CCMathUtil::mapQuad(contentsDeviceTransform, sharedGeometryQuad(), clipped);
+ ASSERT(!clipped);
CCLayerQuad deviceLayerBounds = CCLayerQuad(FloatQuad(deviceQuad.boundingBox()));
CCLayerQuad deviceLayerEdges = CCLayerQuad(deviceQuad);
@@ -660,8 +662,9 @@
GLC(context(), context()->uniform3fv(shaderEdgeLocation, 8, edge));
}
- // Map device space quad to surface space.
- FloatQuad surfaceQuad = contentsDeviceTransform.inverse().mapQuad(deviceLayerEdges.floatQuad());
+ // Map device space quad to surface space. contentsDeviceTransform has no perspective since it was generated with to2dTransform() so we don't need to project.
+ FloatQuad surfaceQuad = CCMathUtil::mapQuad(contentsDeviceTransform.inverse(), deviceLayerEdges.floatQuad(), clipped);
+ ASSERT(!clipped);
drawTexturedQuad(quad->layerTransform(), quad->quadRect().width(), quad->quadRect().height(), quad->opacity(), surfaceQuad,
shaderMatrixLocation, shaderAlphaLocation, shaderQuadLocation);
@@ -761,6 +764,7 @@
bool clipped = false;
FloatQuad deviceLayerQuad = CCMathUtil::mapQuad(deviceTransform, FloatQuad(quad->layerRect()), clipped);
+ ASSERT(!clipped);
TileProgramUniforms uniforms;
// For now, we simply skip anti-aliasing with the quad is clipped. This only happens
@@ -845,7 +849,8 @@
// Map quad to layer space.
WebTransformationMatrix inverseDeviceTransform = deviceTransform.inverse();
- localQuad = inverseDeviceTransform.mapQuad(deviceQuad.floatQuad());
+ localQuad = CCMathUtil::mapQuad(inverseDeviceTransform, deviceQuad.floatQuad(), clipped);
+ ASSERT(!clipped);
} else {
// Move fragment shader transform to vertex shader. We can do this while
// still producing correct results as fragmentTexTransformLocation
Modified: trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp (121582 => 121583)
--- trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp 2012-06-29 19:57:29 UTC (rev 121583)
@@ -58,9 +58,9 @@
{
FloatRect localContentRect(-0.5 * m_contentRect.width(), -0.5 * m_contentRect.height(),
m_contentRect.width(), m_contentRect.height());
- FloatRect drawableContentRect = m_drawTransform.mapRect(localContentRect);
+ FloatRect drawableContentRect = CCMathUtil::mapClippedRect(m_drawTransform, localContentRect);
if (m_owningLayer->replicaLayer())
- drawableContentRect.unite(m_replicaDrawTransform.mapRect(localContentRect));
+ drawableContentRect.unite(CCMathUtil::mapClippedRect(m_replicaDrawTransform, localContentRect));
return drawableContentRect;
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp (121582 => 121583)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp 2012-06-29 19:57:29 UTC (rev 121583)
@@ -231,7 +231,7 @@
// Form the matrix used by the shader to map the corners of the layer's
// bounds into the view space.
FloatRect layerRect(-0.5 * bounds().width(), -0.5 * bounds().height(), bounds().width(), bounds().height());
- IntRect mappedRect = enclosingIntRect(drawTransform().mapRect(layerRect));
+ IntRect mappedRect = enclosingIntRect(CCMathUtil::mapClippedRect(drawTransform(), layerRect));
return mappedRect;
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCMathUtil.cpp (121582 => 121583)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCMathUtil.cpp 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCMathUtil.cpp 2012-06-29 19:57:29 UTC (rev 121583)
@@ -278,13 +278,13 @@
{
FloatQuad projectedQuad;
bool clippedPoint;
- projectedQuad.setP1(transform.projectPoint(q.p1(), &clippedPoint));
+ projectedQuad.setP1(projectPoint(transform, q.p1(), clippedPoint));
clipped = clippedPoint;
- projectedQuad.setP2(transform.projectPoint(q.p2(), &clippedPoint));
+ projectedQuad.setP2(projectPoint(transform, q.p2(), clippedPoint));
clipped |= clippedPoint;
- projectedQuad.setP3(transform.projectPoint(q.p3(), &clippedPoint));
+ projectedQuad.setP3(projectPoint(transform, q.p3(), clippedPoint));
clipped |= clippedPoint;
- projectedQuad.setP4(transform.projectPoint(q.p4(), &clippedPoint));
+ projectedQuad.setP4(projectPoint(transform, q.p4(), clippedPoint));
clipped |= clippedPoint;
return projectedQuad;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp (121582 => 121583)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp 2012-06-29 19:57:29 UTC (rev 121583)
@@ -151,9 +151,9 @@
Region transformedRegion;
Vector<IntRect> rects = region.rects();
- // Clipping has been verified above, so mapRect will give correct results.
for (size_t i = 0; i < rects.size(); ++i) {
- IntRect transformedRect = enclosedIntRect(transform.mapRect(FloatRect(rects[i])));
+ // We've already checked for clipping in the mapQuad call above, these calls should not clip anything further.
+ IntRect transformedRect = enclosedIntRect(CCMathUtil::mapClippedRect(transform, FloatRect(rects[i])));
if (!surface->clipRect().isEmpty())
transformedRect.intersect(surface->clipRect());
transformedRegion.unite(transformedRect);
@@ -319,9 +319,9 @@
return;
Vector<IntRect> contentRects = opaqueContents.rects();
- // We verify that the possible bounds of this region are not clipped above, so we can use mapRect() safely here.
for (size_t i = 0; i < contentRects.size(); ++i) {
- IntRect transformedRect = enclosedIntRect(transform.mapRect(FloatRect(contentRects[i])));
+ // We've already checked for clipping in the mapQuad call above, these calls should not clip anything further.
+ IntRect transformedRect = enclosedIntRect(CCMathUtil::mapClippedRect(transform, FloatRect(contentRects[i])));
transformedRect.intersect(scissorRect);
if (transformedRect.width() >= minimumTrackingSize.width() || transformedRect.height() >= minimumTrackingSize.height()) {
if (occludingScreenSpaceRects)
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCOverdrawMetrics.cpp (121582 => 121583)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCOverdrawMetrics.cpp 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCOverdrawMetrics.cpp 2012-06-29 19:57:29 UTC (rev 121583)
@@ -33,6 +33,7 @@
#include "TraceEvent.h"
#include "cc/CCLayerTreeHost.h"
#include "cc/CCLayerTreeHostImpl.h"
+#include "cc/CCMathUtil.h"
#include <public/Platform.h>
#include <public/WebTransformationMatrix.h>
@@ -57,15 +58,27 @@
return p1.x() * p2.y() - p1.y() * p2.x();
}
-// Computes area of quads that are possibly non-rectangular. Can be easily extended to polygons.
-static inline float quadArea(const FloatQuad& quad)
+// Calculates area of an arbitrary convex polygon with up to 8 points.
+static inline float polygonArea(const FloatPoint points[8], int numPoints)
{
- return fabs(0.5 * (wedgeProduct(quad.p1(), quad.p2()) +
- wedgeProduct(quad.p2(), quad.p3()) +
- wedgeProduct(quad.p3(), quad.p4()) +
- wedgeProduct(quad.p4(), quad.p1())));
+ if (numPoints < 3)
+ return 0;
+
+ float area = 0;
+ for (int i = 0; i < numPoints; ++i)
+ area += wedgeProduct(points[i], points[(i+1)%numPoints]);
+ return fabs(0.5f * area);
}
+// Takes a given quad, maps it by the given transformation, and gives the area of the resulting polygon.
+static inline float areaOfMappedQuad(const WebTransformationMatrix& transform, const FloatQuad& quad)
+{
+ FloatPoint clippedQuad[8];
+ int numVerticesInClippedQuad = 0;
+ CCMathUtil::mapClippedQuad(transform, quad, clippedQuad, numVerticesInClippedQuad);
+ return polygonArea(clippedQuad, numVerticesInClippedQuad);
+}
+
void CCOverdrawMetrics::didPaint(const IntRect& paintedRect)
{
if (!m_recordMetricsForFrame)
@@ -85,8 +98,8 @@
if (!m_recordMetricsForFrame)
return;
- float uploadArea = quadArea(transformToTarget.mapQuad(FloatQuad(uploadRect)));
- float uploadOpaqueArea = quadArea(transformToTarget.mapQuad(FloatQuad(intersection(opaqueRect, uploadRect))));
+ float uploadArea = areaOfMappedQuad(transformToTarget, FloatQuad(uploadRect));
+ float uploadOpaqueArea = areaOfMappedQuad(transformToTarget, FloatQuad(intersection(opaqueRect, uploadRect)));
m_pixelsUploadedOpaque += uploadOpaqueArea;
m_pixelsUploadedTranslucent += uploadArea - uploadOpaqueArea;
@@ -97,8 +110,8 @@
if (!m_recordMetricsForFrame)
return;
- float beforeCullArea = quadArea(transformToTarget.mapQuad(FloatQuad(beforeCullRect)));
- float afterCullArea = quadArea(transformToTarget.mapQuad(FloatQuad(afterCullRect)));
+ float beforeCullArea = areaOfMappedQuad(transformToTarget, FloatQuad(beforeCullRect));
+ float afterCullArea = areaOfMappedQuad(transformToTarget, FloatQuad(afterCullRect));
m_pixelsCulledForDrawing += beforeCullArea - afterCullArea;
}
@@ -108,8 +121,8 @@
if (!m_recordMetricsForFrame)
return;
- float afterCullArea = quadArea(transformToTarget.mapQuad(FloatQuad(afterCullRect)));
- float afterCullOpaqueArea = quadArea(transformToTarget.mapQuad(FloatQuad(intersection(opaqueRect, afterCullRect))));
+ float afterCullArea = areaOfMappedQuad(transformToTarget, FloatQuad(afterCullRect));
+ float afterCullOpaqueArea = areaOfMappedQuad(transformToTarget, FloatQuad(intersection(opaqueRect, afterCullRect)));
m_pixelsDrawnOpaque += afterCullOpaqueArea;
m_pixelsDrawnTranslucent += afterCullArea - afterCullOpaqueArea;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp (121582 => 121583)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp 2012-06-29 19:57:29 UTC (rev 121583)
@@ -28,6 +28,7 @@
#include "cc/CCRenderPass.h"
#include "cc/CCLayerImpl.h"
+#include "cc/CCMathUtil.h"
#include "cc/CCQuadCuller.h"
#include "cc/CCSharedQuadState.h"
#include "cc/CCSolidColorDrawQuad.h"
@@ -95,7 +96,8 @@
WebTransformationMatrix transformToLayerSpace = rootLayer->screenSpaceTransform().inverse();
Vector<IntRect> fillRects = fillRegion.rects();
for (size_t i = 0; i < fillRects.size(); ++i) {
- IntRect layerRect = transformToLayerSpace.mapRect(fillRects[i]);
+ // The root layer transform is composed of translations and scales only, no perspective, so mapping is sufficient.
+ IntRect layerRect = CCMathUtil::mapClippedRect(transformToLayerSpace, fillRects[i]);
m_quadList.append(CCSolidColorDrawQuad::create(sharedQuadState.get(), layerRect, screenBackgroundColor));
}
m_sharedQuadStateList.append(sharedQuadState.release());
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp (121582 => 121583)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp 2012-06-29 19:57:29 UTC (rev 121583)
@@ -78,9 +78,9 @@
{
FloatRect localContentRect(-0.5 * m_contentRect.width(), -0.5 * m_contentRect.height(),
m_contentRect.width(), m_contentRect.height());
- FloatRect drawableContentRect = m_drawTransform.mapRect(localContentRect);
+ FloatRect drawableContentRect = CCMathUtil::mapClippedRect(m_drawTransform, localContentRect);
if (hasReplica())
- drawableContentRect.unite(m_replicaDrawTransform.mapRect(localContentRect));
+ drawableContentRect.unite(CCMathUtil::mapClippedRect(m_replicaDrawTransform, localContentRect));
return drawableContentRect;
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSharedQuadState.cpp (121582 => 121583)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSharedQuadState.cpp 2012-06-29 19:05:18 UTC (rev 121582)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSharedQuadState.cpp 2012-06-29 19:57:29 UTC (rev 121583)
@@ -27,6 +27,8 @@
#include "cc/CCSharedQuadState.h"
+#include "cc/CCMathUtil.h"
+
using WebKit::WebTransformationMatrix;
namespace WebCore {
@@ -50,8 +52,9 @@
{
// Note: this doesn't consider window or projection matrices.
// Assume that they're orthonormal and have integer scales and translations.
- FloatQuad quad = quadTransform().mapQuad(FloatQuad(layerRect()));
- return quad.isRectilinear() && quad.boundingBox().isExpressibleAsIntRect();
+ bool clipped = false;
+ FloatQuad quad = CCMathUtil::mapQuad(quadTransform(), FloatQuad(layerRect()), clipped);
+ return !clipped && quad.isRectilinear() && quad.boundingBox().isExpressibleAsIntRect();
}
}