summaryrefslogtreecommitdiffstats
path: root/cc/quads
diff options
context:
space:
mode:
authorjun.a.jiang@intel.com <jun.a.jiang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-05 04:59:04 +0000
committerjun.a.jiang@intel.com <jun.a.jiang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-05 04:59:04 +0000
commit0a7465e3c2aec71ebdec2a9569542adc3fbe2f30 (patch)
tree61c6912b53fd19077e5a6043939c20a9b490c561 /cc/quads
parent89c20ffd91a6a98d79439ccdd1785b343c34b1db (diff)
downloadchromium_src-0a7465e3c2aec71ebdec2a9569542adc3fbe2f30.zip
chromium_src-0a7465e3c2aec71ebdec2a9569542adc3fbe2f30.tar.gz
chromium_src-0a7465e3c2aec71ebdec2a9569542adc3fbe2f30.tar.bz2
Remove PerformClipping(),CanClipSelf() and the related logic in LTHCommon.
There is a precision lost issue for texture layers with CSS transforms(Scaling) when applying TextureDrawQuad::PerformClipping() to avoid explicitly setting a scissor. The rect is first divided by the scale_factor, then round to integer value and finally multiplied by the scale_factor in GLRenderer::EnqueueTextureQuad(). The round process loses precision and the later scale operation enlarges the error. This error leads to wrong width and height drawn and introduces visual defects. BUG=240259 Review URL: https://codereview.chromium.org/24427006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227177 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/quads')
-rw-r--r--cc/quads/draw_quad_unittest.cc96
-rw-r--r--cc/quads/texture_draw_quad.cc74
-rw-r--r--cc/quads/texture_draw_quad.h2
3 files changed, 0 insertions, 172 deletions
diff --git a/cc/quads/draw_quad_unittest.cc b/cc/quads/draw_quad_unittest.cc
index 08a1a7a..986d3d6 100644
--- a/cc/quads/draw_quad_unittest.cc
+++ b/cc/quads/draw_quad_unittest.cc
@@ -506,102 +506,6 @@ TEST(DrawQuadTest, CopyTextureDrawQuad) {
EXPECT_EQ(flipped, copy_quad->flipped);
}
-TEST(DrawQuadTest, ClipTextureDrawQuad) {
- gfx::Rect opaque_rect(3, 7, 10, 12);
- unsigned resource_id = 82;
- bool premultiplied_alpha = true;
- bool flipped = true;
- CREATE_SHARED_STATE();
- // The original quad position is (30, 40) its size is 50*60.
- shared_state->content_to_target_transform =
- gfx::Transform(1.f, 0.f, 0.f, 1.f, 10.f, 20.f);
- // After transformation, the quad position is (40, 60) its size is 50*60.
- shared_state->clip_rect = gfx::Rect(50, 70, 30, 20);
-
- // The original quad is 'ABCD', the clipped quad is 'abcd':
- // 40 50 90
- // B--:-------C 60
- // | b----c -|-70
- // | | | |
- // | a----d -|-90
- // | |
- // A----------D 120
- // UV and vertex opacity are stored per vertex on the parent rectangle 'ABCD'.
-
- // This is the UV value for vertex 'B'.
- gfx::PointF uv_top_left(0.1f, 0.2f);
- // This is the UV value for vertex 'D'.
- gfx::PointF uv_bottom_right(0.9f, 0.8f);
- // This the vertex opacity for the vertices 'ABCD'.
- const float vertex_opacity[] = { 0.3f, 0.4f, 0.7f, 0.8f };
- {
- CREATE_QUAD_8_NEW(TextureDrawQuad,
- opaque_rect,
- resource_id,
- premultiplied_alpha,
- uv_top_left,
- uv_bottom_right,
- SK_ColorTRANSPARENT,
- vertex_opacity,
- flipped);
- CREATE_QUAD_7_ALL(TextureDrawQuad,
- resource_id,
- premultiplied_alpha,
- uv_top_left,
- uv_bottom_right,
- SK_ColorTRANSPARENT,
- vertex_opacity,
- flipped);
- EXPECT_TRUE(quad_all->PerformClipping());
-
- // This is the expected UV value for vertex 'b'.
- // uv(b) = uv(B) + (Bb / BD) * (uv(D) - uv(B))
- // 0.3 = 0.2 + (10 / 60) * (0.8 - 0.2)
- gfx::PointF uv_top_left_clipped(0.26f, 0.3f);
- // This is the expected UV value for vertex 'd'.
- // uv(d) = uv(B) + (Bd / BD) * (uv(D) - uv(B))
- gfx::PointF uv_bottom_right_clipped(0.74f, 0.5f);
- // This the expected vertex opacity for the vertices 'abcd'.
- // They are computed with a bilinear interpolation of the corner values.
- const float vertex_opacity_clipped[] = { 0.43f, 0.45f, 0.65f, 0.67f };
-
- EXPECT_EQ(uv_top_left_clipped, quad_all->uv_top_left);
- EXPECT_EQ(uv_bottom_right_clipped, quad_all->uv_bottom_right);
- EXPECT_FLOAT_ARRAY_EQ(vertex_opacity_clipped, quad_all->vertex_opacity, 4);
- }
-
- uv_top_left = gfx::PointF(0.8f, 0.7f);
- uv_bottom_right = gfx::PointF(0.2f, 0.1f);
- {
- CREATE_QUAD_8_NEW(TextureDrawQuad,
- opaque_rect,
- resource_id,
- premultiplied_alpha,
- uv_top_left,
- uv_bottom_right,
- SK_ColorTRANSPARENT,
- vertex_opacity,
- flipped);
- CREATE_QUAD_7_ALL(TextureDrawQuad,
- resource_id,
- premultiplied_alpha,
- uv_top_left,
- uv_bottom_right,
- SK_ColorTRANSPARENT,
- vertex_opacity,
- flipped);
- EXPECT_TRUE(quad_all->PerformClipping());
-
- // This is the expected UV value for vertex 'b'.
- gfx::PointF uv_top_left_clipped(0.68f, 0.6f);
- // This is the expected UV value for vertex 'd'.
- gfx::PointF uv_bottom_right_clipped(0.32f, 0.4f);
-
- EXPECT_EQ(uv_top_left_clipped, quad_all->uv_top_left);
- EXPECT_EQ(uv_bottom_right_clipped, quad_all->uv_bottom_right);
- }
-}
-
TEST(DrawQuadTest, CopyTileDrawQuad) {
gfx::Rect opaque_rect(33, 44, 22, 33);
unsigned resource_id = 104;
diff --git a/cc/quads/texture_draw_quad.cc b/cc/quads/texture_draw_quad.cc
index ae7cfd6..191dcc4 100644
--- a/cc/quads/texture_draw_quad.cc
+++ b/cc/quads/texture_draw_quad.cc
@@ -84,80 +84,6 @@ const TextureDrawQuad* TextureDrawQuad::MaterialCast(const DrawQuad* quad) {
return static_cast<const TextureDrawQuad*>(quad);
}
-bool TextureDrawQuad::PerformClipping() {
- // This only occurs if the rect is only scaled and translated (and thus still
- // axis aligned).
- if (!quadTransform().IsPositiveScaleOrTranslation())
- return false;
-
- // Grab our scale and make sure it's positive.
- float x_scale = static_cast<float>(quadTransform().matrix().getDouble(0, 0));
- float y_scale = static_cast<float>(quadTransform().matrix().getDouble(1, 1));
-
- // Grab our offset.
- gfx::Vector2dF offset(
- static_cast<float>(quadTransform().matrix().getDouble(0, 3)),
- static_cast<float>(quadTransform().matrix().getDouble(1, 3)));
-
- // Transform the rect by the scale and offset.
- gfx::RectF rect_f = rect;
- rect_f.Scale(x_scale, y_scale);
- rect_f += offset;
-
- // Perform clipping and check to see if the result is empty.
- gfx::RectF clipped_rect = IntersectRects(rect_f, clipRect());
- if (clipped_rect.IsEmpty()) {
- rect = gfx::Rect();
- uv_top_left = gfx::PointF();
- uv_bottom_right = gfx::PointF();
- return true;
- }
-
- // Create a new uv-rect by clipping the old one to the new bounds.
- gfx::Vector2dF uv_scale(uv_bottom_right - uv_top_left);
- uv_scale.Scale(1.f / rect_f.width(), 1.f / rect_f.height());
- uv_bottom_right = uv_top_left +
- gfx::ScaleVector2d(
- clipped_rect.bottom_right() - rect_f.origin(),
- uv_scale.x(),
- uv_scale.y());
- uv_top_left = uv_top_left +
- gfx::ScaleVector2d(
- clipped_rect.origin() - rect_f.origin(),
- uv_scale.x(),
- uv_scale.y());
-
- // Indexing according to the quad vertex generation:
- // 1--2
- // | |
- // 0--3
- if (vertex_opacity[0] != vertex_opacity[1]
- || vertex_opacity[0] != vertex_opacity[2]
- || vertex_opacity[0] != vertex_opacity[3]) {
- const float x1 = (clipped_rect.x() - rect_f.x()) / rect_f.width();
- const float y1 = (clipped_rect.y() - rect_f.y()) / rect_f.height();
- const float x3 = (clipped_rect.right() - rect_f.x()) / rect_f.width();
- const float y3 = (clipped_rect.bottom() - rect_f.y()) / rect_f.height();
- const float x1y1 = x1 * vertex_opacity[2] + (1.0f - x1) * vertex_opacity[1];
- const float x1y3 = x1 * vertex_opacity[3] + (1.0f - x1) * vertex_opacity[0];
- const float x3y1 = x3 * vertex_opacity[2] + (1.0f - x3) * vertex_opacity[1];
- const float x3y3 = x3 * vertex_opacity[3] + (1.0f - x3) * vertex_opacity[0];
- vertex_opacity[0] = y3 * x1y3 + (1.0f - y3) * x1y1;
- vertex_opacity[1] = y1 * x1y3 + (1.0f - y1) * x1y1;
- vertex_opacity[2] = y1 * x3y3 + (1.0f - y1) * x3y1;
- vertex_opacity[3] = y3 * x3y3 + (1.0f - y3) * x3y1;
- }
-
- // Move the clipped rectangle back into its space.
- clipped_rect -= offset;
- clipped_rect.Scale(1.0f / x_scale, 1.0f / y_scale);
- rect = gfx::Rect(static_cast<int>(clipped_rect.x() + 0.5f),
- static_cast<int>(clipped_rect.y() + 0.5f),
- static_cast<int>(clipped_rect.width() + 0.5f),
- static_cast<int>(clipped_rect.height() + 0.5f));
- return true;
-}
-
void TextureDrawQuad::ExtendValue(base::DictionaryValue* value) const {
value->SetInteger("resource_id", resource_id);
value->SetBoolean("premultiplied_alpha", premultiplied_alpha);
diff --git a/cc/quads/texture_draw_quad.h b/cc/quads/texture_draw_quad.h
index 7f06618..4aa4d7a 100644
--- a/cc/quads/texture_draw_quad.h
+++ b/cc/quads/texture_draw_quad.h
@@ -53,8 +53,6 @@ class CC_EXPORT TextureDrawQuad : public DrawQuad {
static const TextureDrawQuad* MaterialCast(const DrawQuad*);
- bool PerformClipping();
-
private:
TextureDrawQuad();
virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE;