summaryrefslogtreecommitdiffstats
path: root/cc/quads/texture_draw_quad.cc
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/texture_draw_quad.cc
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/texture_draw_quad.cc')
-rw-r--r--cc/quads/texture_draw_quad.cc74
1 files changed, 0 insertions, 74 deletions
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);