Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: content/plugin/webplugin_accelerated_surface_proxy_mac.cc

Issue 1852593004: Remove content/plugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_npapi_test_plugin
Patch Set: . Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import <OpenGL/OpenGL.h>
6 #include <stdint.h>
7
8 #include "content/plugin/webplugin_accelerated_surface_proxy_mac.h"
9
10 #include "base/bind.h"
11 #include "base/command_line.h"
12 #include "content/plugin/webplugin_proxy.h"
13 #include "content/public/common/content_switches.h"
14 #include "ui/surface/accelerated_surface_mac.h"
15 #include "ui/surface/transport_dib.h"
16
17 namespace content {
18
19 WebPluginAcceleratedSurfaceProxy* WebPluginAcceleratedSurfaceProxy::Create(
20 WebPluginProxy* plugin_proxy,
21 gfx::GpuPreference gpu_preference) {
22 // This code path shouldn't be taken if CA plugins are disabled
23 // because the CA drawing model shouldn't be advertised.
24 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
25 switches::kDisableCoreAnimationPlugins));
26
27 AcceleratedSurface* surface = new AcceleratedSurface;
28 // It's possible for OpenGL to fail to initialize (e.g., if an incompatible
29 // mode is forced via flags), so handle that gracefully.
30 if (!surface->Initialize(NULL, true, gpu_preference)) {
31 delete surface;
32 return NULL;
33 }
34
35 return new WebPluginAcceleratedSurfaceProxy(plugin_proxy, surface);
36 }
37
38 WebPluginAcceleratedSurfaceProxy::WebPluginAcceleratedSurfaceProxy(
39 WebPluginProxy* plugin_proxy,
40 AcceleratedSurface* surface)
41 : plugin_proxy_(plugin_proxy),
42 surface_(surface) {
43 }
44
45 WebPluginAcceleratedSurfaceProxy::~WebPluginAcceleratedSurfaceProxy() {
46 if (surface_) {
47 surface_->Destroy();
48 delete surface_;
49 surface_ = NULL;
50 }
51 }
52
53 void WebPluginAcceleratedSurfaceProxy::SetSize(const gfx::Size& size) {
54 if (!surface_)
55 return;
56
57 uint32_t io_surface_id = surface_->SetSurfaceSize(size);
58 // If allocation fails for some reason, still inform the plugin proxy.
59 plugin_proxy_->AcceleratedPluginAllocatedIOSurface(
60 size.width(), size.height(), io_surface_id);
61 }
62
63 CGLContextObj WebPluginAcceleratedSurfaceProxy::context() {
64 return surface_ ? surface_->context() : NULL;
65 }
66
67 void WebPluginAcceleratedSurfaceProxy::StartDrawing() {
68 if (!surface_)
69 return;
70
71 surface_->MakeCurrent();
72 surface_->Clear(gfx::Rect(surface_->GetSize()));
73 }
74
75 void WebPluginAcceleratedSurfaceProxy::EndDrawing() {
76 if (!surface_)
77 return;
78
79 surface_->SwapBuffers();
80 plugin_proxy_->AcceleratedPluginSwappedIOSurface();
81 }
82
83 } // namespace content
OLDNEW
« no previous file with comments | « content/plugin/webplugin_accelerated_surface_proxy_mac.h ('k') | content/plugin/webplugin_delegate_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698