diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-01 18:04:06 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-01 18:04:06 +0000 |
commit | 8b4755fa086ef5d41e6a6ed40a38ac45390b9511 (patch) | |
tree | 555a11c1fdaee95ebfb29cdfb9a7a2a7cce9a3c1 /chrome/plugin/webplugin_accelerated_surface_proxy_mac.cc | |
parent | 56bf1b7944f2c7b2a620b0e1476086b7e60f0da6 (diff) | |
download | chromium_src-8b4755fa086ef5d41e6a6ed40a38ac45390b9511.zip chromium_src-8b4755fa086ef5d41e6a6ed40a38ac45390b9511.tar.gz chromium_src-8b4755fa086ef5d41e6a6ed40a38ac45390b9511.tar.bz2 |
Enable the invalidating Core Animation plugin drawing model on 10.5
This also adds a layer of abstraction between the concept of the accelerated surface, and our cross-process implementation (which is something we needed to fix in general, but was necessary here to avoid bleeding TransportDIB references into code that's not supposed to know about process separation). There's no in-process implementation since we don't support in-process plugins on the Mac, but the abstraction is now there if we want to add one in the future.
BUG=32012
TEST=Plugins using invalidating Core Animation model should run on 10.5
Review URL: http://codereview.chromium.org/3449023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61199 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/webplugin_accelerated_surface_proxy_mac.cc')
-rw-r--r-- | chrome/plugin/webplugin_accelerated_surface_proxy_mac.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/chrome/plugin/webplugin_accelerated_surface_proxy_mac.cc b/chrome/plugin/webplugin_accelerated_surface_proxy_mac.cc new file mode 100644 index 0000000..551d711 --- /dev/null +++ b/chrome/plugin/webplugin_accelerated_surface_proxy_mac.cc @@ -0,0 +1,61 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import <OpenGL/OpenGL.h> + +#include "chrome/plugin/webplugin_accelerated_surface_proxy_mac.h" + +#include "app/surface/accelerated_surface_mac.h" +#include "app/surface/transport_dib.h" +#include "chrome/plugin/webplugin_proxy.h" + +WebPluginAcceleratedSurfaceProxy::WebPluginAcceleratedSurfaceProxy( + WebPluginProxy* plugin_proxy) : plugin_proxy_(plugin_proxy) { + surface_ = new AcceleratedSurface; + surface_->Initialize(NULL, true); + + // Only used for 10.5 support, but harmless on 10.6+. + surface_->SetTransportDIBAllocAndFree( + NewCallback(plugin_proxy_, &WebPluginProxy::AllocSurfaceDIB), + NewCallback(plugin_proxy_, &WebPluginProxy::FreeSurfaceDIB)); +} + +WebPluginAcceleratedSurfaceProxy::~WebPluginAcceleratedSurfaceProxy() { + if (surface_) { + surface_->Destroy(); + delete surface_; + surface_ = NULL; + } +} + +void WebPluginAcceleratedSurfaceProxy::SetWindowHandle( + gfx::PluginWindowHandle window) { + window_handle_ = window; +} + +void WebPluginAcceleratedSurfaceProxy::SetSize(const gfx::Size& size) { + uint64 io_surface_id = surface_->SetSurfaceSize(size); + if (io_surface_id) { + plugin_proxy_->SetAcceleratedSurface(window_handle_, size, io_surface_id); + } else { + TransportDIB::Handle transport_dib = surface_->SetTransportDIBSize(size); + if (TransportDIB::is_valid(transport_dib)) { + plugin_proxy_->SetAcceleratedDIB(window_handle_, size, transport_dib); + } + } +} + +CGLContextObj WebPluginAcceleratedSurfaceProxy::context() { + return surface_->context(); +} + +void WebPluginAcceleratedSurfaceProxy::StartDrawing() { + surface_->MakeCurrent(); + surface_->Clear(gfx::Rect(surface_->GetSize())); +} + +void WebPluginAcceleratedSurfaceProxy::EndDrawing() { + surface_->SwapBuffers(); + plugin_proxy_->AcceleratedFrameBuffersDidSwap(window_handle_); +} |