diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 23:05:27 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 23:05:27 +0000 |
commit | 88ca4737f94734dd1ec191f9e532b908ff5d3e3a (patch) | |
tree | a6c5272efaf706b561fbffa5d3bbf2d9242d024c | |
parent | 2a13edde1666eda54128b60789823e86049d1fea (diff) | |
download | chromium_src-88ca4737f94734dd1ec191f9e532b908ff5d3e3a.zip chromium_src-88ca4737f94734dd1ec191f9e532b908ff5d3e3a.tar.gz chromium_src-88ca4737f94734dd1ec191f9e532b908ff5d3e3a.tar.bz2 |
Mac: Use a ScopedCFTypeRef the IOSurface owned by an accelerated surface container.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/4142005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63968 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/renderer_host/accelerated_surface_container_mac.cc | 21 | ||||
-rw-r--r-- | chrome/browser/renderer_host/accelerated_surface_container_mac.h | 3 |
2 files changed, 8 insertions, 16 deletions
diff --git a/chrome/browser/renderer_host/accelerated_surface_container_mac.cc b/chrome/browser/renderer_host/accelerated_surface_container_mac.cc index fdba6ea..8d7ce75 100644 --- a/chrome/browser/renderer_host/accelerated_surface_container_mac.cc +++ b/chrome/browser/renderer_host/accelerated_surface_container_mac.cc @@ -14,7 +14,6 @@ AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac( bool opaque) : manager_(manager), opaque_(opaque), - surface_(NULL), width_(0), height_(0), texture_(0), @@ -25,25 +24,17 @@ AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac( } AcceleratedSurfaceContainerMac::~AcceleratedSurfaceContainerMac() { - ReleaseIOSurface(); -} - -void AcceleratedSurfaceContainerMac::ReleaseIOSurface() { - if (surface_) { - CFRelease(surface_); - surface_ = NULL; - } } void AcceleratedSurfaceContainerMac::SetSizeAndIOSurface( int32 width, int32 height, uint64 io_surface_identifier) { - ReleaseIOSurface(); + surface_.reset(); IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); if (io_surface_support) { - surface_ = io_surface_support->IOSurfaceLookup( - static_cast<uint32>(io_surface_identifier)); + surface_.reset(io_surface_support->IOSurfaceLookup( + static_cast<uint32>(io_surface_identifier))); EnqueueTextureForDeletion(); width_ = width; height_ = height; @@ -85,7 +76,7 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { texture_pending_deletion_ = 0; } if (!texture_) { - if ((io_surface_support && !surface_) || + if ((io_surface_support && !surface_.get()) || (!io_surface_support && !transport_dib_.get())) return; glGenTextures(1, &texture_); @@ -112,7 +103,7 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { // When using an IOSurface, the texture does not need to be repeatedly // uploaded, just when we've been told we have to. if (io_surface_support && texture_needs_upload_) { - DCHECK(surface_); + DCHECK(surface_.get()); glBindTexture(target, texture_); // Don't think we need to identify a plane. GLuint plane = 0; @@ -123,7 +114,7 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { height_, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, - surface_, + surface_.get(), plane); texture_needs_upload_ = false; } diff --git a/chrome/browser/renderer_host/accelerated_surface_container_mac.h b/chrome/browser/renderer_host/accelerated_surface_container_mac.h index b0b6051..04742f3 100644 --- a/chrome/browser/renderer_host/accelerated_surface_container_mac.h +++ b/chrome/browser/renderer_host/accelerated_surface_container_mac.h @@ -31,6 +31,7 @@ #include "app/surface/transport_dib.h" #include "base/basictypes.h" +#include "base/mac/scoped_cftyperef.h" #include "base/scoped_ptr.h" #include "gfx/native_widget_types.h" #include "gfx/rect.h" @@ -91,7 +92,7 @@ class AcceleratedSurfaceContainerMac { // plugin process back to the browser process for drawing. // This is held as a CFTypeRef because we can't refer to the // IOSurfaceRef type when building on 10.5. - CFTypeRef surface_; + base::mac::ScopedCFTypeRef<CFTypeRef> surface_; // The TransportDIB which is used in pre-10.6 systems where the IOSurface // API is not supported. This is a weak reference to the actual TransportDIB |