This source file includes following definitions.
- Create
- surface_
- SetSize
- context
- StartDrawing
- EndDrawing
#import <OpenGL/OpenGL.h>
#include "content/plugin/webplugin_accelerated_surface_proxy_mac.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "content/plugin/webplugin_proxy.h"
#include "content/public/common/content_switches.h"
#include "ui/gl/io_surface_support_mac.h"
#include "ui/surface/accelerated_surface_mac.h"
#include "ui/surface/transport_dib.h"
namespace content {
WebPluginAcceleratedSurfaceProxy* WebPluginAcceleratedSurfaceProxy::Create(
WebPluginProxy* plugin_proxy,
gfx::GpuPreference gpu_preference) {
DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableCoreAnimationPlugins));
if (!IOSurfaceSupport::Initialize())
return NULL;
AcceleratedSurface* surface = new AcceleratedSurface;
if (!surface->Initialize(NULL, true, gpu_preference)) {
delete surface;
return NULL;
}
return new WebPluginAcceleratedSurfaceProxy(plugin_proxy, surface);
}
WebPluginAcceleratedSurfaceProxy::WebPluginAcceleratedSurfaceProxy(
WebPluginProxy* plugin_proxy,
AcceleratedSurface* surface)
: plugin_proxy_(plugin_proxy),
surface_(surface) {
}
WebPluginAcceleratedSurfaceProxy::~WebPluginAcceleratedSurfaceProxy() {
if (surface_) {
surface_->Destroy();
delete surface_;
surface_ = NULL;
}
}
void WebPluginAcceleratedSurfaceProxy::SetSize(const gfx::Size& size) {
if (!surface_)
return;
uint32 io_surface_id = surface_->SetSurfaceSize(size);
plugin_proxy_->AcceleratedPluginAllocatedIOSurface(
size.width(), size.height(), io_surface_id);
}
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_->AcceleratedPluginSwappedIOSurface();
}
}