| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/renderer_host/accelerated_surface_container_mac.h" | 5 #include "chrome/browser/renderer_host/accelerated_surface_container_mac.h" |
| 6 | 6 |
| 7 #include "app/surface/io_surface_support_mac.h" | 7 #include "app/surface/io_surface_support_mac.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/renderer_host/accelerated_surface_container_manager_mac
.h" | 9 #include "chrome/browser/renderer_host/accelerated_surface_container_manager_mac
.h" |
| 10 #include "webkit/glue/plugins/webplugin.h" | 10 #include "webkit/glue/plugins/webplugin.h" |
| 11 | 11 |
| 12 AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac( | 12 AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac( |
| 13 AcceleratedSurfaceContainerManagerMac* manager, | 13 AcceleratedSurfaceContainerManagerMac* manager, |
| 14 bool opaque) | 14 bool opaque) |
| 15 : manager_(manager), | 15 : manager_(manager), |
| 16 opaque_(opaque), | 16 opaque_(opaque), |
| 17 surface_(NULL), | 17 surface_(NULL), |
| 18 width_(0), | 18 width_(0), |
| 19 height_(0), | 19 height_(0), |
| 20 texture_(0), | 20 texture_(0), |
| 21 texture_needs_upload_(true), | 21 texture_needs_upload_(true), |
| 22 texture_pending_deletion_(0) { | 22 texture_pending_deletion_(0), |
| 23 visible_(false), |
| 24 was_painted_to_(false) { |
| 23 } | 25 } |
| 24 | 26 |
| 25 AcceleratedSurfaceContainerMac::~AcceleratedSurfaceContainerMac() { | 27 AcceleratedSurfaceContainerMac::~AcceleratedSurfaceContainerMac() { |
| 26 ReleaseIOSurface(); | 28 ReleaseIOSurface(); |
| 27 } | 29 } |
| 28 | 30 |
| 29 void AcceleratedSurfaceContainerMac::ReleaseIOSurface() { | 31 void AcceleratedSurfaceContainerMac::ReleaseIOSurface() { |
| 30 if (surface_) { | 32 if (surface_) { |
| 31 CFRelease(surface_); | 33 CFRelease(surface_); |
| 32 surface_ = NULL; | 34 surface_ = NULL; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 55 if (TransportDIB::is_valid(transport_dib)) { | 57 if (TransportDIB::is_valid(transport_dib)) { |
| 56 transport_dib_.reset(TransportDIB::Map(transport_dib)); | 58 transport_dib_.reset(TransportDIB::Map(transport_dib)); |
| 57 EnqueueTextureForDeletion(); | 59 EnqueueTextureForDeletion(); |
| 58 width_ = width; | 60 width_ = width; |
| 59 height_ = height; | 61 height_ = height; |
| 60 } | 62 } |
| 61 } | 63 } |
| 62 | 64 |
| 63 void AcceleratedSurfaceContainerMac::SetGeometry( | 65 void AcceleratedSurfaceContainerMac::SetGeometry( |
| 64 const webkit_glue::WebPluginGeometry& geom) { | 66 const webkit_glue::WebPluginGeometry& geom) { |
| 65 // TODO(kbr): may need to pay attention to cutout rects. | 67 visible_ = geom.visible; |
| 66 if (geom.visible) | 68 clipRect_ = geom.clip_rect; |
| 67 clipRect_ = geom.clip_rect; | |
| 68 else | |
| 69 clipRect_ = gfx::Rect(); | |
| 70 } | 69 } |
| 71 | 70 |
| 72 void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { | 71 void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { |
| 73 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); | 72 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); |
| 74 GLenum target = GL_TEXTURE_RECTANGLE_ARB; | 73 GLenum target = GL_TEXTURE_RECTANGLE_ARB; |
| 75 if (texture_pending_deletion_) { | 74 if (texture_pending_deletion_) { |
| 76 // Clean up an old texture object. This is essentially a pre-emptive | 75 // Clean up an old texture object. This is essentially a pre-emptive |
| 77 // cleanup, as the resources will be released when the OpenGL context | 76 // cleanup, as the resources will be released when the OpenGL context |
| 78 // associated with our containing NSView is destroyed. However, if we | 77 // associated with our containing NSView is destroyed. However, if we |
| 79 // resize a plugin often, we might generate a lot of textures, so we | 78 // resize a plugin often, we might generate a lot of textures, so we |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 202 } |
| 204 | 203 |
| 205 void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() { | 204 void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() { |
| 206 if (texture_) { | 205 if (texture_) { |
| 207 DCHECK(texture_pending_deletion_ == 0); | 206 DCHECK(texture_pending_deletion_ == 0); |
| 208 texture_pending_deletion_ = texture_; | 207 texture_pending_deletion_ = texture_; |
| 209 texture_ = 0; | 208 texture_ = 0; |
| 210 } | 209 } |
| 211 } | 210 } |
| 212 | 211 |
| OLD | NEW |