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

Unified Diff: chrome/browser/renderer_host/accelerated_surface_container_mac.cc

Issue 4101002: Mac/gpu: Don't show uninitialized surfaces while resizing plugins / composited tabs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: white padding Created 10 years, 1 month 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
Index: chrome/browser/renderer_host/accelerated_surface_container_mac.cc
diff --git a/chrome/browser/renderer_host/accelerated_surface_container_mac.cc b/chrome/browser/renderer_host/accelerated_surface_container_mac.cc
index ca2a6008f1f96d93c7e190cd408cd4dd7de0425f..7fb2e07b43cf28536dbdd4f8dbaa4c2517f54230 100644
--- a/chrome/browser/renderer_host/accelerated_surface_container_mac.cc
+++ b/chrome/browser/renderer_host/accelerated_surface_container_mac.cc
@@ -31,18 +31,11 @@ void AcceleratedSurfaceContainerMac::SetSizeAndIOSurface(
int32 width,
int32 height,
uint64 io_surface_identifier) {
- surface_.reset();
- surface_id_ = 0;
- IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize();
- if (io_surface_support) {
- surface_.reset(io_surface_support->IOSurfaceLookup(
- static_cast<uint32>(io_surface_identifier)));
- if (surface_.get())
- surface_id_ = io_surface_identifier;
- EnqueueTextureForDeletion();
- width_ = width;
- height_ = height;
- }
+ // Ignore |io_surface_identifier|: The surface hasn't been painted to and
+ // only contains garbage data. Update the surface in |set_was_painted_to()|
+ // instead.
+ width_ = width;
+ height_ = height;
}
void AcceleratedSurfaceContainerMac::SetSizeAndTransportDIB(
@@ -114,8 +107,8 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) {
io_surface_support->CGLTexImageIOSurface2D(context,
target,
GL_RGBA,
- width_,
- height_,
+ surface_width_,
+ surface_height_,
GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV,
surface_.get(),
@@ -141,6 +134,9 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) {
}
if (texture_) {
+ int texture_width = io_surface_support ? surface_width_ : width_;
+ int texture_height = io_surface_support ? surface_height_ : height_;
+
// TODO(kbr): convert this to use only OpenGL ES 2.0 functionality.
// TODO(kbr): may need to pay attention to cutout rects.
@@ -149,6 +145,11 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) {
int clipWidth = clipRect_.width();
int clipHeight = clipRect_.height();
+ if (clipX + clipWidth > texture_width)
+ clipWidth = texture_width - clipX;
+ if (clipY + clipHeight > texture_height)
+ clipHeight = texture_height - clipY;
+
if (opaque_) {
// Pepper 3D's output is currently considered opaque even if the
// program draws pixels with alpha less than 1. In order to have
@@ -179,16 +180,16 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) {
glEnable(target);
glBegin(GL_TRIANGLE_STRIP);
- glTexCoord2f(clipX, height_ - clipY);
+ glTexCoord2f(clipX, texture_height - clipY);
glVertex3f(0, 0, 0);
- glTexCoord2f(clipX + clipWidth, height_ - clipY);
+ glTexCoord2f(clipX + clipWidth, texture_height - clipY);
glVertex3f(clipWidth, 0, 0);
- glTexCoord2f(clipX, height_ - clipY - clipHeight);
+ glTexCoord2f(clipX, texture_height - clipY - clipHeight);
glVertex3f(0, clipHeight, 0);
- glTexCoord2f(clipX + clipWidth, height_ - clipY - clipHeight);
+ glTexCoord2f(clipX + clipWidth, texture_height - clipY - clipHeight);
glVertex3f(clipWidth, clipHeight, 0);
glEnd();
@@ -197,11 +198,22 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) {
}
void AcceleratedSurfaceContainerMac::set_was_painted_to(uint64 surface_id) {
- if (surface_id) {
- // Check that only the most current IOSurface allocated for this container
- // is painted to.
- DCHECK(surface_);
- DCHECK_EQ(surface_id, surface_id_);
+ if (surface_id && (!surface_ || surface_id != surface_id_)) {
+ // Keep the surface that was most recently painted to around.
+ if (IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize()) {
+ CFTypeRef surface = io_surface_support->IOSurfaceLookup(
+ static_cast<uint32>(surface_id));
+ // Can fail if IOSurface with that ID was already released by the
+ // gpu process or the plugin process. We will get a |set_was_painted_to()|
+ // message with a new surface soon in that case.
+ if (surface) {
+ surface_.reset(surface);
+ surface_id_ = surface_id;
+ surface_width_ = io_surface_support->IOSurfaceGetWidth(surface_);
+ surface_height_ = io_surface_support->IOSurfaceGetHeight(surface_);
+ EnqueueTextureForDeletion();
+ }
+ }
}
was_painted_to_ = true;
}

Powered by Google App Engine
This is Rietveld 408576698