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

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

Issue 3185004: Cleanups to well-behaved accelerated plugin CL requested by... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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
Index: chrome/browser/renderer_host/accelerated_surface_container_mac.cc
===================================================================
--- chrome/browser/renderer_host/accelerated_surface_container_mac.cc (revision 56221)
+++ chrome/browser/renderer_host/accelerated_surface_container_mac.cc (working copy)
@@ -18,11 +18,11 @@
width_(0),
height_(0),
texture_(0),
- texture_needs_upload_(true) {
+ texture_needs_upload_(true),
+ texture_pending_deletion_(0) {
}
AcceleratedSurfaceContainerMac::~AcceleratedSurfaceContainerMac() {
- EnqueueTextureForDeletion();
ReleaseIOSurface();
}
@@ -60,7 +60,7 @@
}
}
-void AcceleratedSurfaceContainerMac::MoveTo(
+void AcceleratedSurfaceContainerMac::SetGeometry(
const webkit_glue::WebPluginGeometry& geom) {
// TODO(kbr): may need to pay attention to cutout rects.
if (geom.visible)
@@ -72,6 +72,19 @@
void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) {
IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize();
GLenum target = GL_TEXTURE_RECTANGLE_ARB;
+ if (texture_pending_deletion_) {
+ // Clean up an old texture object. This is essentially a pre-emptive
+ // cleanup, as the resources will be released when the OpenGL context
+ // associated with our containing NSView is destroyed. However, if we
+ // resize a plugin often, we might generate a lot of textures, so we
+ // should try to eagerly reclaim their resources. Note also that the
+ // OpenGL context must be current when performing the deletion, and it
+ // seems risky to make the OpenGL context current at an arbitrary point
+ // in time, which is why the deletion does not occur in the container's
+ // destructor.
+ glDeleteTextures(1, &texture_pending_deletion_);
+ texture_pending_deletion_ = 0;
+ }
if (!texture_) {
if ((io_surface_support && !surface_) ||
(!io_surface_support && !transport_dib_.get()))
@@ -191,7 +204,8 @@
void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() {
if (texture_) {
- manager_->EnqueueTextureForDeletion(texture_);
+ DCHECK(texture_pending_deletion_ == 0);
+ texture_pending_deletion_ = texture_;
texture_ = 0;
}
}

Powered by Google App Engine
This is Rietveld 408576698