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

Unified Diff: cc/texture_draw_quad.cc

Issue 11783094: cc: Add point-based UV coordinate on TextureLayer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 11 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 | « cc/texture_draw_quad.h ('k') | cc/texture_layer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/texture_draw_quad.cc
diff --git a/cc/texture_draw_quad.cc b/cc/texture_draw_quad.cc
index 6ce491af8d0e46880cbf9a316ce0bd30a4a7e04b..9a657a77116d0d6b9fa4ad3e28b0796b27220b9b 100644
--- a/cc/texture_draw_quad.cc
+++ b/cc/texture_draw_quad.cc
@@ -5,6 +5,7 @@
#include "cc/texture_draw_quad.h"
#include "base/logging.h"
+#include "ui/gfx/vector2d_f.h"
namespace cc {
@@ -21,7 +22,8 @@ scoped_ptr<TextureDrawQuad> TextureDrawQuad::Create() {
void TextureDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
gfx::Rect rect, gfx::Rect opaque_rect,
unsigned resource_id, bool premultiplied_alpha,
- const gfx::RectF& uv_rect,
+ gfx::PointF uv_top_left,
+ gfx::PointF uv_bottom_right,
const float vertex_opacity[4], bool flipped) {
gfx::Rect visible_rect = rect;
bool needs_blending = vertex_opacity[0] != 1.0f || vertex_opacity[1] != 1.0f
@@ -30,7 +32,8 @@ void TextureDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
opaque_rect, visible_rect, needs_blending);
this->resource_id = resource_id;
this->premultiplied_alpha = premultiplied_alpha;
- this->uv_rect = uv_rect;
+ this->uv_top_left = uv_top_left;
+ this->uv_bottom_right = uv_bottom_right;
this->vertex_opacity[0] = vertex_opacity[0];
this->vertex_opacity[1] = vertex_opacity[1];
this->vertex_opacity[2] = vertex_opacity[2];
@@ -42,13 +45,15 @@ void TextureDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
gfx::Rect rect, gfx::Rect opaque_rect,
gfx::Rect visible_rect, bool needs_blending,
unsigned resource_id, bool premultiplied_alpha,
- const gfx::RectF& uv_rect,
+ gfx::PointF uv_top_left,
+ gfx::PointF uv_bottom_right,
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->uv_top_left = uv_top_left;
+ this->uv_bottom_right = uv_bottom_right;
this->vertex_opacity[0] = vertex_opacity[0];
this->vertex_opacity[1] = vertex_opacity[1];
this->vertex_opacity[2] = vertex_opacity[2];
@@ -90,18 +95,24 @@ bool TextureDrawQuad::PerformClipping() {
gfx::RectF clippedRect = IntersectRects(rectF, clipRect());
if (clippedRect.IsEmpty()) {
rect = gfx::Rect();
- uv_rect = gfx::RectF();
+ 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.
- uv_rect = gfx::RectF(
- uv_rect.x()
- + uv_rect.width() / rectF.width() * (clippedRect.x() - rectF.x()),
- uv_rect.y()
- + uv_rect.height() / rectF.height() * (clippedRect.y() - rectF.y()),
- uv_rect.width() / rectF.width() * clippedRect.width(),
- uv_rect.height() / rectF.height() * clippedRect.height());
+ gfx::Vector2dF uv_scale(uv_bottom_right - uv_top_left);
+ uv_scale.Scale(1.f / rectF.width(), 1.f / rectF.height());
+ uv_bottom_right = uv_top_left +
+ gfx::ScaleVector2d(
+ clippedRect.bottom_right() - rectF.origin(),
+ uv_scale.x(),
+ uv_scale.y());
+ uv_top_left = uv_top_left +
+ gfx::ScaleVector2d(
+ clippedRect.origin() - rectF.origin(),
+ uv_scale.x(),
+ uv_scale.y());
// Indexing according to the quad vertex generation:
// 1--2
« no previous file with comments | « cc/texture_draw_quad.h ('k') | cc/texture_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698