| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 #include "webkit/glue/plugins/mac_accelerated_surface_container_manager.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "webkit/glue/plugins/mac_accelerated_surface_container.h" | |
| 9 #include "webkit/glue/plugins/webplugin.h" | |
| 10 | |
| 11 MacAcceleratedSurfaceContainerManager::MacAcceleratedSurfaceContainerManager() | |
| 12 : current_id_(0) { | |
| 13 } | |
| 14 | |
| 15 gfx::PluginWindowHandle | |
| 16 MacAcceleratedSurfaceContainerManager::AllocateFakePluginWindowHandle() { | |
| 17 MacAcceleratedSurfaceContainer* container = | |
| 18 new MacAcceleratedSurfaceContainer(); | |
| 19 gfx::PluginWindowHandle res = | |
| 20 static_cast<gfx::PluginWindowHandle>(++current_id_); | |
| 21 plugin_window_to_container_map_.insert(std::make_pair(res, container)); | |
| 22 return res; | |
| 23 } | |
| 24 | |
| 25 void MacAcceleratedSurfaceContainerManager::DestroyFakePluginWindowHandle( | |
| 26 gfx::PluginWindowHandle id) { | |
| 27 MacAcceleratedSurfaceContainer* container = MapIDToContainer(id); | |
| 28 if (container) | |
| 29 delete container; | |
| 30 plugin_window_to_container_map_.erase(id); | |
| 31 } | |
| 32 | |
| 33 void MacAcceleratedSurfaceContainerManager::SetSizeAndIOSurface( | |
| 34 gfx::PluginWindowHandle id, | |
| 35 int32 width, | |
| 36 int32 height, | |
| 37 uint64 io_surface_identifier) { | |
| 38 MacAcceleratedSurfaceContainer* container = MapIDToContainer(id); | |
| 39 if (container) | |
| 40 container->SetSizeAndIOSurface(width, height, | |
| 41 io_surface_identifier, this); | |
| 42 } | |
| 43 | |
| 44 void MacAcceleratedSurfaceContainerManager::SetSizeAndTransportDIB( | |
| 45 gfx::PluginWindowHandle id, | |
| 46 int32 width, | |
| 47 int32 height, | |
| 48 TransportDIB::Handle transport_dib) { | |
| 49 MacAcceleratedSurfaceContainer* container = MapIDToContainer(id); | |
| 50 if (container) | |
| 51 container->SetSizeAndTransportDIB(width, height, | |
| 52 transport_dib, this); | |
| 53 } | |
| 54 | |
| 55 void MacAcceleratedSurfaceContainerManager::MovePluginContainer( | |
| 56 const webkit_glue::WebPluginGeometry& move) { | |
| 57 MacAcceleratedSurfaceContainer* container = MapIDToContainer(move.window); | |
| 58 if (container) | |
| 59 container->MoveTo(move); | |
| 60 } | |
| 61 | |
| 62 void MacAcceleratedSurfaceContainerManager::Draw(CGLContextObj context) { | |
| 63 glClearColor(0, 0, 0, 0); | |
| 64 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |
| 65 | |
| 66 GLenum target = GL_TEXTURE_RECTANGLE_ARB; | |
| 67 glTexEnvi(target, GL_TEXTURE_ENV_MODE, GL_REPLACE); | |
| 68 | |
| 69 for (PluginWindowToContainerMap::const_iterator i = | |
| 70 plugin_window_to_container_map_.begin(); | |
| 71 i != plugin_window_to_container_map_.end(); ++i) { | |
| 72 MacAcceleratedSurfaceContainer* container = i->second; | |
| 73 container->Draw(context); | |
| 74 } | |
| 75 | |
| 76 // Unbind any texture from the texture target to ensure that the | |
| 77 // next time through we will have to re-bind the texture and thereby | |
| 78 // pick up modifications from the other process. | |
| 79 glBindTexture(target, 0); | |
| 80 | |
| 81 glFlush(); | |
| 82 } | |
| 83 | |
| 84 void MacAcceleratedSurfaceContainerManager::EnqueueTextureForDeletion( | |
| 85 GLuint texture) { | |
| 86 if (texture) { | |
| 87 textures_pending_deletion_.push_back(texture); | |
| 88 } | |
| 89 } | |
| 90 | |
| 91 MacAcceleratedSurfaceContainer* | |
| 92 MacAcceleratedSurfaceContainerManager::MapIDToContainer( | |
| 93 gfx::PluginWindowHandle id) { | |
| 94 PluginWindowToContainerMap::const_iterator i = | |
| 95 plugin_window_to_container_map_.find(id); | |
| 96 if (i != plugin_window_to_container_map_.end()) | |
| 97 return i->second; | |
| 98 | |
| 99 LOG(ERROR) << "Request for plugin container for unknown window id " << id; | |
| 100 | |
| 101 return NULL; | |
| 102 } | |
| 103 | |
| OLD | NEW |