summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-06 19:28:10 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-06 19:28:10 +0000
commitc5e61c7494bebd27df0e968d8d2644e5546154e8 (patch)
treeb1fc570f9f287111ba0b35a3f99f717edf998b22 /ui
parent75e6d54297cfd5f5516c3dd554a957386de72fd6 (diff)
downloadchromium_src-c5e61c7494bebd27df0e968d8d2644e5546154e8.zip
chromium_src-c5e61c7494bebd27df0e968d8d2644e5546154e8.tar.gz
chromium_src-c5e61c7494bebd27df0e968d8d2644e5546154e8.tar.bz2
Properly handle vertically flipping the texture.
Our old mechanism for drawing external textures from the GPU process that are vertically flipped does not work if the corresponding layer has a hole in it (we don't want to flip the hole). This patch handles the flip at the texture map where it belongs. BUG=none TEST=with --use-gl=egl on a debug build of TOUCH_UI, go to a page with a combo box (such as news.google.com); open the combo box; you should not see a bright purple hole. Review URL: http://codereview.chromium.org/8177007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104348 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/compositor/compositor.h7
-rw-r--r--ui/gfx/compositor/compositor_gl.cc32
-rw-r--r--ui/gfx/compositor/compositor_win.cc3
3 files changed, 30 insertions, 12 deletions
diff --git a/ui/gfx/compositor/compositor.h b/ui/gfx/compositor/compositor.h
index 5c45cc9..b6c4a55 100644
--- a/ui/gfx/compositor/compositor.h
+++ b/ui/gfx/compositor/compositor.h
@@ -28,7 +28,8 @@ struct TextureDrawParams {
TextureDrawParams()
: blend(false),
has_valid_alpha_channel(false),
- opacity(1.0f) {
+ opacity(1.0f),
+ vertically_flipped(false) {
}
// The transform to be applied to the texture.
@@ -45,6 +46,10 @@ struct TextureDrawParams {
// allow alpha to be animated (for effects such as cross fades).
float opacity;
+ // Sometimes the texture is vertically flipped. In this case we have to
+ // draw the texture differently.
+ bool vertically_flipped;
+
// The size of the surface that the texture is drawn to.
gfx::Size compositor_size;
diff --git a/ui/gfx/compositor/compositor_gl.cc b/ui/gfx/compositor/compositor_gl.cc
index 8e22e21..6f8e178 100644
--- a/ui/gfx/compositor/compositor_gl.cc
+++ b/ui/gfx/compositor/compositor_gl.cc
@@ -12,6 +12,7 @@
#include "base/threading/thread_restrictions.h"
#include "third_party/skia/include/core/SkDevice.h"
#include "third_party/skia/include/core/SkMatrix.h"
+#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkScalar.h"
#include "ui/gfx/rect.h"
@@ -378,7 +379,7 @@ void TextureGL::DrawInternal(const ui::TextureProgramGL& program,
gfx::Rect(gfx::Point(0, 0), size_));
// Verify that compositor_size has been set.
- DCHECK(params.compositor_size != gfx::Size(0,0));
+ DCHECK(params.compositor_size != gfx::Size(0, 0));
if (params.blend)
glEnable(GL_BLEND);
@@ -409,17 +410,26 @@ void TextureGL::DrawInternal(const ui::TextureProgramGL& program,
GLfloat m[16];
t.matrix().asColMajorf(m);
- SkRect texture_rect = SkRect::MakeXYWH(
- clip_bounds.x(),
- clip_bounds.y(),
- clip_bounds.width(),
- clip_bounds.height());
+ SkPoint texture_points[4];
+ texture_points[0] = SkPoint::Make(clip_bounds.x(),
+ clip_bounds.y() + clip_bounds.height());
+ texture_points[1] = SkPoint::Make(clip_bounds.x() + clip_bounds.width(),
+ clip_bounds.y() + clip_bounds.height());
+ texture_points[2] = SkPoint::Make(clip_bounds.x() + clip_bounds.width(),
+ clip_bounds.y());
+ texture_points[3] = SkPoint::Make(clip_bounds.x(), clip_bounds.y());
ui::Transform texture_rect_transform;
texture_rect_transform.ConcatScale(1.0f / size_.width(),
1.0f / size_.height());
+ if (params.vertically_flipped) {
+ ui::Transform vertical_flip;
+ vertical_flip.SetScaleY(-1.0);
+ vertical_flip.SetTranslateY(1.0);
+ texture_rect_transform.ConcatTransform(vertical_flip);
+ }
SkMatrix texture_transform_matrix = texture_rect_transform.matrix();
- texture_transform_matrix.mapRect(&texture_rect);
+ texture_transform_matrix.mapPoints(texture_points, 4);
SkRect clip_rect = SkRect::MakeXYWH(
clip_bounds.x(),
@@ -440,10 +450,10 @@ void TextureGL::DrawInternal(const ui::TextureProgramGL& program,
clip_rect.right(), clip_rect.bottom(), +0.,
clip_rect.left(), clip_rect.bottom(), +0.};
- GLfloat texture_vertices[] = { texture_rect.left(), texture_rect.bottom(),
- texture_rect.right(), texture_rect.bottom(),
- texture_rect.right(), texture_rect.top(),
- texture_rect.left(), texture_rect.top()};
+ GLfloat texture_vertices[] = { texture_points[0].x(), texture_points[0].y(),
+ texture_points[1].x(), texture_points[1].y(),
+ texture_points[2].x(), texture_points[2].y(),
+ texture_points[3].x(), texture_points[3].y()};
glVertexAttribPointer(program.a_pos_loc(), 3, GL_FLOAT,
GL_FALSE, 3 * sizeof(GLfloat), clip_vertices);
diff --git a/ui/gfx/compositor/compositor_win.cc b/ui/gfx/compositor/compositor_win.cc
index 8fb817b..5a6c431 100644
--- a/ui/gfx/compositor/compositor_win.cc
+++ b/ui/gfx/compositor/compositor_win.cc
@@ -242,6 +242,9 @@ void ViewTexture::SetCanvas(const SkCanvas& canvas,
void ViewTexture::Draw(const ui::TextureDrawParams& params,
const gfx::Rect& clip_bounds) {
+ if (!params.vertically_flipped)
+ NOTIMPLEMENTED();
+
compositor_->UpdatePerspective(params.transform, view_size_);
// Make texture active.