Index: cc/texture_draw_quad.cc |
diff --git a/cc/texture_draw_quad.cc b/cc/texture_draw_quad.cc |
index 5ad73b69dc28731925dcf31518cd61148feedc72..11d17d8183a3d0955f184e3be07effab9577dc81 100644 |
--- a/cc/texture_draw_quad.cc |
+++ b/cc/texture_draw_quad.cc |
@@ -24,14 +24,22 @@ void TextureDrawQuad::SetNew(const SharedQuadState* shared_quad_state, |
unsigned resource_id, |
bool premultiplied_alpha, |
const gfx::RectF& uv_rect, |
+ const float vertex_opacity[4], |
bool flipped) { |
gfx::Rect visible_rect = rect; |
- bool needs_blending = false; |
+ bool needs_blending = vertex_opacity[0] != 1.0f |
+ || vertex_opacity[1] != 1.0f |
jamesr
2012/12/14 21:18:20
chromium style is to have the operator on the prev
Jerome
2012/12/14 21:48:47
Done.
|
+ || vertex_opacity[2] != 1.0f |
+ || vertex_opacity[3] != 1.0f; |
DrawQuad::SetAll(shared_quad_state, DrawQuad::TEXTURE_CONTENT, rect, |
opaque_rect, visible_rect, needs_blending); |
this->resource_id = resource_id; |
this->premultiplied_alpha = premultiplied_alpha; |
this->uv_rect = uv_rect; |
+ this->vertex_opacity[0] = vertex_opacity[0]; |
+ this->vertex_opacity[1] = vertex_opacity[1]; |
+ this->vertex_opacity[2] = vertex_opacity[2]; |
+ this->vertex_opacity[3] = vertex_opacity[3]; |
this->flipped = flipped; |
} |
@@ -43,12 +51,17 @@ void TextureDrawQuad::SetAll(const SharedQuadState* shared_quad_state, |
unsigned resource_id, |
bool premultiplied_alpha, |
const gfx::RectF& uv_rect, |
+ const float vertex_opacity[4], |
bool flipped) { |
DrawQuad::SetAll(shared_quad_state, DrawQuad::TEXTURE_CONTENT, rect, |
opaque_rect, visible_rect, needs_blending); |
this->resource_id = resource_id; |
this->premultiplied_alpha = premultiplied_alpha; |
this->uv_rect = uv_rect; |
+ this->vertex_opacity[0] = vertex_opacity[0]; |
+ this->vertex_opacity[1] = vertex_opacity[1]; |
+ this->vertex_opacity[2] = vertex_opacity[2]; |
+ this->vertex_opacity[3] = vertex_opacity[3]; |
this->flipped = flipped; |
} |
@@ -95,6 +108,27 @@ bool TextureDrawQuad::PerformClipping() { |
uv_rect.width () / rectF.width () * clippedRect.width (), |
uv_rect.height() / rectF.height() * clippedRect.height()); |
+ // Indexing according to the quad vertex generation: |
+ // 1--2 |
+ // | | |
+ // 0--3 |
+ if (vertex_opacity[0] != vertex_opacity[1] |
+ || vertex_opacity[0] != vertex_opacity[2] |
jamesr
2012/12/14 21:18:20
||s on previous line
Jerome
2012/12/14 21:48:47
Done.
|
+ || vertex_opacity[0] != vertex_opacity[3]) { |
+ const float x1 = (clippedRect.x() - rectF.x()) / rectF.width(); |
+ const float y1 = (clippedRect.y() - rectF.y()) / rectF.height(); |
+ const float x3 = (clippedRect.right() - rectF.x()) / rectF.width(); |
+ const float y3 = (clippedRect.bottom() - rectF.y()) / rectF.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. |
clippedRect -= offset; |
clippedRect.Scale(1.0f / x_scale, 1.0f / y_scale); |