diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 02:28:48 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 02:28:48 +0000 |
commit | 43f28f83bc268dea720843a2616058b64b3e8810 (patch) | |
tree | 3c3c4fc9c43dad15246fae82cb5b965e6b217281 /webkit/glue/plugins/mac_gpu_plugin_container.h | |
parent | 2d48004e1f2c8cecd015144c179f993d883aba9c (diff) | |
download | chromium_src-43f28f83bc268dea720843a2616058b64b3e8810.zip chromium_src-43f28f83bc268dea720843a2616058b64b3e8810.tar.gz chromium_src-43f28f83bc268dea720843a2616058b64b3e8810.tar.bz2 |
[GPU] Get GPU process running on the mac
Initial port of GPU process / plugin to Mac OS X. Uses new IOSurface
APIs and therefore currently runs only on 10.6. Alternate strategy
will need to be devised for 10.5.
Slight UI issues remain such as GPU plugins initially showing up in
the wrong place on the page. These will be fixed in follow-on bugs.
Minimal changes made to command buffer code to get it to compile on
Mac OS X. Commented out use of nested anonymous namespaces in
gles2_cmd_decoder.cc which were causing the linker to crash with a seg
fault.
Refactored gyp files so the OS test enabling the GPU plugin is in one
place, common.gypi, and other files test only the variable enable_gpu.
Slight change to gles2_demo_cc.cc to add some simple animation to
verify that updates from the GPU plugin are reaching the screen.
Changed Pepper test plugin to use 3D view by default and commented out
use of audio context because of recent issues.
TEST=none (ran Pepper Test Plugin with 3D view enabled)
BUG=http://crbug.com/25988
Review URL: http://codereview.chromium.org/558035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37934 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins/mac_gpu_plugin_container.h')
-rw-r--r-- | webkit/glue/plugins/mac_gpu_plugin_container.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/webkit/glue/plugins/mac_gpu_plugin_container.h b/webkit/glue/plugins/mac_gpu_plugin_container.h new file mode 100644 index 0000000..92e9fcb --- /dev/null +++ b/webkit/glue/plugins/mac_gpu_plugin_container.h @@ -0,0 +1,98 @@ +// 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. + +#ifndef WEBKIT_GLUE_PLUGINS_MAC_GPU_PLUGIN_CONTAINER_H_ +#define WEBKIT_GLUE_PLUGINS_MAC_GPU_PLUGIN_CONTAINER_H_ + +// The "GPU plugin" is currently implemented as a special kind of +// NPAPI plugin to provide high-performance on-screen 3D rendering for +// Pepper 3D. +// +// On Windows and X11 platforms the GPU plugin relies on cross-process +// parenting of windows, which is not supported via any public APIs in +// the Mac OS X window system. +// +// To achieve full hardware acceleration we use the new IOSurface APIs +// introduced in Mac OS X 10.6. The GPU plugin's process produces an +// IOSurface and renders into it using OpenGL. It uses the +// IOSurfaceGetID and IOSurfaceLookup APIs to pass a reference to this +// surface to the browser process for on-screen rendering. The GPU +// plugin essentially looks like a windowless plugin; the browser +// process gets all of the mouse events, because the plugin process +// does not have an on-screen window. +// +// This class encapsulates some of the management of these data +// structures, in conjunction with the MacGPUPluginContainerManager. + +#include <CoreFoundation/CoreFoundation.h> +#include <OpenGL/OpenGL.h> + +#include "app/gfx/native_widget_types.h" +#include "base/basictypes.h" + +namespace webkit_glue { +struct WebPluginGeometry; +} + +class MacGPUPluginContainerManager; + +class MacGPUPluginContainer { + public: + MacGPUPluginContainer(); + virtual ~MacGPUPluginContainer(); + + // Sets the backing store and size of this plugin container. + void SetSizeAndBackingStore(int32 width, + int32 height, + uint64 io_surface_identifier, + MacGPUPluginContainerManager* manager); + + // Tells the plugin container that it has moved relative to the + // origin of the window, for example because of a scroll event. + void MoveTo(const webkit_glue::WebPluginGeometry& geom); + + // Draws this plugin's contents, texture mapped onto a quad in the + // given OpenGL context. TODO(kbr): figure out and define exactly + // how the coordinate system will work out. + void Draw(CGLContextObj context); + + // Enqueue our texture for later deletion. Call this before deleting + // this object. + void EnqueueTextureForDeletion(MacGPUPluginContainerManager* manager); + + private: + // We currently only have a viable implementation of this class on + // Snow Leopard. We need to think about fallback strategies that + // will work on Leopard. + + // The x and y coordinates of the plugin window on the web page. + // TODO(kbr): see whether additional clipping information is + // necessary. + int x_; + int y_; + + void ReleaseIOSurface(); + + // The IOSurfaceRef, if any, that has been handed from the GPU + // 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_; + + // The width and height of the surface. + int32 width_; + int32 height_; + + // The "live" OpenGL texture referring to this IOSurfaceRef. Note + // that per the CGLTexImageIOSurface2D API we do not need to + // explicitly update this texture's contents once created. All we + // need to do is ensure it is re-bound before attempting to draw + // with it. + GLuint texture_; + + DISALLOW_COPY_AND_ASSIGN(MacGPUPluginContainer); +}; + +#endif // WEBKIT_GLUE_PLUGINS_MAC_GPU_PLUGIN_CONTAINER_H_ + |