summaryrefslogtreecommitdiffstats
path: root/content/plugin/webplugin_accelerated_surface_proxy_mac.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-16 17:23:58 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-16 17:23:58 +0000
commit3c5c6d8d4dd6b6b6fd3115dbbe2b155b9eb207f9 (patch)
tree6832386fa85e7dc6db0e094041b5bd3587dd7748 /content/plugin/webplugin_accelerated_surface_proxy_mac.cc
parent0590a140d2291f2aebfb54179f1282d798faa6a8 (diff)
downloadchromium_src-3c5c6d8d4dd6b6b6fd3115dbbe2b155b9eb207f9.zip
chromium_src-3c5c6d8d4dd6b6b6fd3115dbbe2b155b9eb207f9.tar.gz
chromium_src-3c5c6d8d4dd6b6b6fd3115dbbe2b155b9eb207f9.tar.bz2
Move plugin code to content.
TBR=avi Review URL: http://codereview.chromium.org/6672048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78386 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/plugin/webplugin_accelerated_surface_proxy_mac.cc')
-rw-r--r--content/plugin/webplugin_accelerated_surface_proxy_mac.cc79
1 files changed, 79 insertions, 0 deletions
diff --git a/content/plugin/webplugin_accelerated_surface_proxy_mac.cc b/content/plugin/webplugin_accelerated_surface_proxy_mac.cc
new file mode 100644
index 0000000..7f5d486
--- /dev/null
+++ b/content/plugin/webplugin_accelerated_surface_proxy_mac.cc
@@ -0,0 +1,79 @@
+// 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 "content/plugin/webplugin_accelerated_surface_proxy_mac.h"
+
+#include "app/surface/accelerated_surface_mac.h"
+#include "app/surface/transport_dib.h"
+#include "content/plugin/webplugin_proxy.h"
+
+WebPluginAcceleratedSurfaceProxy::WebPluginAcceleratedSurfaceProxy(
+ WebPluginProxy* plugin_proxy)
+ : plugin_proxy_(plugin_proxy),
+ window_handle_(NULL) {
+ surface_ = new AcceleratedSurface;
+ // It's possible for OpenGL to fail to initialze (e.g., if an incompatible
+ // mode is forced via flags), so handle that gracefully.
+ if (!surface_->Initialize(NULL, true)) {
+ delete surface_;
+ surface_ = NULL;
+ return;
+ }
+
+ // 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) {
+ if (!surface_)
+ return;
+
+ 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_ ? surface_->context() : NULL;
+}
+
+void WebPluginAcceleratedSurfaceProxy::StartDrawing() {
+ if (!surface_)
+ return;
+
+ surface_->MakeCurrent();
+ surface_->Clear(gfx::Rect(surface_->GetSize()));
+}
+
+void WebPluginAcceleratedSurfaceProxy::EndDrawing() {
+ if (!surface_)
+ return;
+
+ surface_->SwapBuffers();
+ plugin_proxy_->AcceleratedFrameBuffersDidSwap(
+ window_handle_, surface_->GetSurfaceId());
+}