diff options
author | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-04 09:25:53 +0000 |
---|---|---|
committer | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-04 09:25:53 +0000 |
commit | c3a6b4a7ad8dfff007c880035b256a77c5cd923b (patch) | |
tree | b6220d00432ccef4c19b2843d04100527dec4633 /content/browser/renderer_host | |
parent | 391bbe5ceb83b7df4a856838d20dd10a13dd6954 (diff) | |
download | chromium_src-c3a6b4a7ad8dfff007c880035b256a77c5cd923b.zip chromium_src-c3a6b4a7ad8dfff007c880035b256a77c5cd923b.tar.gz chromium_src-c3a6b4a7ad8dfff007c880035b256a77c5cd923b.tar.bz2 |
Remove IOSurfaceSupport
Link against IOSurface.framework instead -- this is an option starting in 10.6.
BUG=314190
Review URL: https://codereview.chromium.org/301973010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274746 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host')
7 files changed, 52 insertions, 79 deletions
diff --git a/content/browser/renderer_host/compositing_iosurface_mac.h b/content/browser/renderer_host/compositing_iosurface_mac.h index b1984d1..d632f52 100644 --- a/content/browser/renderer_host/compositing_iosurface_mac.h +++ b/content/browser/renderer_host/compositing_iosurface_mac.h @@ -10,6 +10,7 @@ #include <vector> #import <Cocoa/Cocoa.h> +#include <IOSurface/IOSurfaceAPI.h> #include <QuartzCore/QuartzCore.h> #include "base/callback.h" @@ -25,7 +26,6 @@ #include "ui/gfx/rect_conversions.h" #include "ui/gfx/size.h" -class IOSurfaceSupport; class SkBitmap; namespace gfx { @@ -46,7 +46,7 @@ class RenderWidgetHostViewMac; class CompositingIOSurfaceMac : public base::RefCounted<CompositingIOSurfaceMac> { public: - // Returns NULL if IOSurface support is missing or GL APIs fail. + // Returns NULL if IOSurface or GL API calls fail. static scoped_refptr<CompositingIOSurfaceMac> Create(); // Set IOSurface that will be drawn on the next NSView drawRect. @@ -204,7 +204,6 @@ class CompositingIOSurfaceMac }; CompositingIOSurfaceMac( - IOSurfaceSupport* io_surface_support, const scoped_refptr<CompositingIOSurfaceContext>& context); ~CompositingIOSurfaceMac(); @@ -273,9 +272,6 @@ class CompositingIOSurfaceMac gfx::Rect IntersectWithIOSurface(const gfx::Rect& rect) const; - // Cached pointer to IOSurfaceSupport Singleton. - IOSurfaceSupport* io_surface_support_; - // Offscreen context used for all operations other than drawing to the // screen. This is in the same share group as the contexts used for // drawing, and is the same for all IOSurfaces in all windows. @@ -283,7 +279,7 @@ class CompositingIOSurfaceMac // IOSurface data. uint64 io_surface_handle_; - base::ScopedCFTypeRef<CFTypeRef> io_surface_; + base::ScopedCFTypeRef<IOSurfaceRef> io_surface_; // The width and height of the io surface. gfx::Size pixel_io_surface_size_; // In pixels. diff --git a/content/browser/renderer_host/compositing_iosurface_mac.mm b/content/browser/renderer_host/compositing_iosurface_mac.mm index e6fae6b..5280fd5 100644 --- a/content/browser/renderer_host/compositing_iosurface_mac.mm +++ b/content/browser/renderer_host/compositing_iosurface_mac.mm @@ -4,6 +4,7 @@ #include "content/browser/renderer_host/compositing_iosurface_mac.h" +#include <OpenGL/CGLIOSurface.h> #include <OpenGL/CGLRenderers.h> #include <OpenGL/OpenGL.h> @@ -28,7 +29,6 @@ #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" #include "ui/gfx/size_conversions.h" #include "ui/gl/gl_context.h" -#include "ui/gl/io_surface_support_mac.h" #ifdef NDEBUG #define CHECK_GL_ERROR() @@ -218,12 +218,6 @@ void CompositingIOSurfaceMac::CopyContext::PrepareForAsynchronousReadback() { // static scoped_refptr<CompositingIOSurfaceMac> CompositingIOSurfaceMac::Create() { - IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); - if (!io_surface_support) { - LOG(ERROR) << "No IOSurface support"; - return NULL; - } - scoped_refptr<CompositingIOSurfaceContext> offscreen_context = CompositingIOSurfaceContext::Get( CompositingIOSurfaceContext::kOffscreenContextWindowNumber); @@ -232,15 +226,12 @@ scoped_refptr<CompositingIOSurfaceMac> CompositingIOSurfaceMac::Create() { return NULL; } - return new CompositingIOSurfaceMac(io_surface_support, - offscreen_context); + return new CompositingIOSurfaceMac(offscreen_context); } CompositingIOSurfaceMac::CompositingIOSurfaceMac( - IOSurfaceSupport* io_surface_support, const scoped_refptr<CompositingIOSurfaceContext>& offscreen_context) - : io_surface_support_(io_surface_support), - offscreen_context_(offscreen_context), + : offscreen_context_(offscreen_context), io_surface_handle_(0), scale_factor_(1.f), texture_(0), @@ -493,8 +484,7 @@ bool CompositingIOSurfaceMac::MapIOSurfaceToTextureWithContextCurrent( if (io_surface_ && io_surface_handle == io_surface_handle_) return true; - io_surface_.reset(io_surface_support_->IOSurfaceLookup( - static_cast<uint32>(io_surface_handle))); + io_surface_.reset(IOSurfaceLookup(static_cast<uint32>(io_surface_handle))); // Can fail if IOSurface with that ID was already released by the gpu // process. if (!io_surface_) { @@ -506,9 +496,8 @@ bool CompositingIOSurfaceMac::MapIOSurfaceToTextureWithContextCurrent( // Actual IOSurface size is rounded up to reduce reallocations during window // resize. Get the actual size to properly map the texture. - gfx::Size rounded_size( - io_surface_support_->IOSurfaceGetWidth(io_surface_), - io_surface_support_->IOSurfaceGetHeight(io_surface_)); + gfx::Size rounded_size(IOSurfaceGetWidth(io_surface_), + IOSurfaceGetHeight(io_surface_)); glGenTextures(1, &texture_); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture_); @@ -516,7 +505,7 @@ bool CompositingIOSurfaceMac::MapIOSurfaceToTextureWithContextCurrent( glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST); CHECK_AND_SAVE_GL_ERROR(); GLuint plane = 0; - CGLError cgl_error = io_surface_support_->CGLTexImageIOSurface2D( + CGLError cgl_error = CGLTexImageIOSurface2D( current_context->cgl_context(), GL_TEXTURE_RECTANGLE_ARB, GL_RGBA, diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 23b52ec..8ed6424 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -161,7 +161,6 @@ #if defined(OS_MACOSX) #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h" -#include "ui/gl/io_surface_support_mac.h" #endif #if defined(OS_WIN) @@ -2172,44 +2171,38 @@ void RenderProcessHostImpl::OnAllocateGpuMemoryBuffer(uint32 width, // GpuMemoryBufferImplIOSurface. crbug.com/325045, crbug.com/323304 if (GpuMemoryBufferImplIOSurface::IsConfigurationSupported(internalformat, usage)) { - IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); - if (io_surface_support) { - base::ScopedCFTypeRef<CFMutableDictionaryRef> properties; - properties.reset( - CFDictionaryCreateMutable(kCFAllocatorDefault, - 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks)); - AddIntegerValue( - properties, io_surface_support->GetKIOSurfaceWidth(), width); - AddIntegerValue( - properties, io_surface_support->GetKIOSurfaceHeight(), height); - AddIntegerValue(properties, - io_surface_support->GetKIOSurfaceBytesPerElement(), - GpuMemoryBufferImpl::BytesPerPixel(internalformat)); - AddIntegerValue( - properties, - io_surface_support->GetKIOSurfacePixelFormat(), - GpuMemoryBufferImplIOSurface::PixelFormat(internalformat)); - // TODO(reveman): Remove this when using a mach_port_t to transfer - // IOSurface to renderer process. crbug.com/323304 - AddBooleanValue( - properties, io_surface_support->GetKIOSurfaceIsGlobal(), true); - - base::ScopedCFTypeRef<CFTypeRef> io_surface( - io_surface_support->IOSurfaceCreate(properties)); - if (io_surface) { - gfx::GpuMemoryBufferHandle handle; - handle.type = gfx::IO_SURFACE_BUFFER; - handle.io_surface_id = io_surface_support->IOSurfaceGetID(io_surface); - - // TODO(reveman): This makes the assumption that the renderer will - // grab a reference to the surface before sending another message. - // crbug.com/325045 - last_io_surface_ = io_surface; - GpuMemoryBufferAllocated(reply, handle); - return; - } + base::ScopedCFTypeRef<CFMutableDictionaryRef> properties; + properties.reset( + CFDictionaryCreateMutable(kCFAllocatorDefault, + 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks)); + AddIntegerValue(properties, kIOSurfaceWidth, width); + AddIntegerValue(properties, kIOSurfaceHeight, height); + AddIntegerValue(properties, + kIOSurfaceBytesPerElement, + GpuMemoryBufferImpl::BytesPerPixel(internalformat)); + AddIntegerValue( + properties, + kIOSurfacePixelFormat, + GpuMemoryBufferImplIOSurface::PixelFormat(internalformat)); + // TODO(reveman): Remove this when using a mach_port_t to transfer + // IOSurface to renderer process. crbug.com/323304 + AddBooleanValue( + properties, kIOSurfaceIsGlobal, true); + + base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties)); + if (io_surface) { + gfx::GpuMemoryBufferHandle handle; + handle.type = gfx::IO_SURFACE_BUFFER; + handle.io_surface_id = IOSurfaceGetID(io_surface); + + // TODO(reveman): This makes the assumption that the renderer will + // grab a reference to the surface before sending another message. + // crbug.com/325045 + last_io_surface_ = io_surface; + GpuMemoryBufferAllocated(reply, handle); + return; } } #endif diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h index 89b7255..e2c7b24 100644 --- a/content/browser/renderer_host/render_process_host_impl.h +++ b/content/browser/renderer_host/render_process_host_impl.h @@ -23,6 +23,7 @@ #include "mojo/public/cpp/bindings/interface_ptr.h" #if defined(OS_MACOSX) +#include <IOSurface/IOSurfaceAPI.h> #include "base/mac/scoped_cftyperef.h" #endif @@ -451,7 +452,7 @@ class CONTENT_EXPORT RenderProcessHostImpl base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; #if defined(OS_MACOSX) - base::ScopedCFTypeRef<CFTypeRef> last_io_surface_; + base::ScopedCFTypeRef<IOSurfaceRef> last_io_surface_; #endif DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); diff --git a/content/browser/renderer_host/render_widget_helper_mac.mm b/content/browser/renderer_host/render_widget_helper_mac.mm index 4662782..4a16293 100644 --- a/content/browser/renderer_host/render_widget_helper_mac.mm +++ b/content/browser/renderer_host/render_widget_helper_mac.mm @@ -5,6 +5,7 @@ #include "content/browser/renderer_host/render_widget_helper.h" #import <Cocoa/Cocoa.h> +#include <IOSurface/IOSurfaceAPI.h> #include "base/bind.h" #include "content/browser/compositor/browser_compositor_view_mac.h" @@ -15,6 +16,7 @@ namespace { void OnNativeSurfaceBuffersSwappedOnUIThread( + base::ScopedCFTypeRef<IOSurfaceRef> io_surface, const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); gfx::AcceleratedWidget native_widget = @@ -39,20 +41,21 @@ void RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnIOThread( // and a potential deadlock. // TODO(ccameron): This immediate ack circumvents GPU back-pressure that // is necessary to throttle renderers. Fix that. - // TODO(ccameron): It is possible that the IOSurface will be deleted or - // reused soon as it is acked. Take out a reference to the IOSurface here, - // to ensure the IOSurface does not disappear before routing to the UI - // thread. AcceleratedSurfaceMsg_BufferPresented_Params ack_params; ack_params.sync_point = 0; ack_params.renderer_id = 0; gpu_process_host->Send(new AcceleratedSurfaceMsg_BufferPresented( params.route_id, ack_params)); + // Open the IOSurface handle before returning, to ensure that it is not + // closed as soon as the frame is acknowledged. + base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceLookup( + static_cast<uint32>(params.surface_handle))); + BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&OnNativeSurfaceBuffersSwappedOnUIThread, params)); + base::Bind(&OnNativeSurfaceBuffersSwappedOnUIThread, io_surface, params)); } } // namespace content diff --git a/content/browser/renderer_host/render_widget_host_view_browsertest.cc b/content/browser/renderer_host/render_widget_host_view_browsertest.cc index 1c85aa7..e054f21 100644 --- a/content/browser/renderer_host/render_widget_host_view_browsertest.cc +++ b/content/browser/renderer_host/render_widget_host_view_browsertest.cc @@ -33,10 +33,6 @@ #include "ui/gfx/switches.h" #include "ui/gl/gl_switches.h" -#if defined(OS_MACOSX) -#include "ui/gl/io_surface_support_mac.h" -#endif - #if defined(OS_WIN) #include "base/win/windows_version.h" #include "ui/gfx/win/dpi.h" @@ -223,10 +219,6 @@ class CompositingRenderWidgetHostViewBrowserTest } virtual bool SetUpSourceSurface(const char* wait_message) OVERRIDE { -#if defined(OS_MACOSX) - CHECK(IOSurfaceSupport::Initialize()); -#endif - content::DOMMessageQueue message_queue; NavigateToURL(shell(), TestUrl()); if (wait_message != NULL) { diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 93e6414..8959bf3 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -74,7 +74,6 @@ #include "ui/gfx/screen.h" #include "ui/gfx/size_conversions.h" #include "ui/gl/gl_switches.h" -#include "ui/gl/io_surface_support_mac.h" using content::BrowserAccessibility; using content::BrowserAccessibilityManager; |