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

Side by Side Diff: chrome/browser/renderer_host/accelerated_surface_container_mac.cc

Issue 1166002: Fix handling of Mac accelerated plugin layers across tab switch. (Closed)
Patch Set: Created 10 years, 9 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
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "webkit/glue/webplugin.h" 8 #include "webkit/glue/webplugin.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 "chrome/common/io_surface_support_mac.h" 10 #include "chrome/common/io_surface_support_mac.h"
11 11
12 AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac() 12 AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac()
13 : x_(0), 13 : x_(0),
14 y_(0), 14 y_(0),
15 surface_(NULL), 15 surface_(NULL),
16 width_(0), 16 width_(0),
17 height_(0), 17 height_(0),
18 texture_(0) { 18 texture_(0),
19 texture_needs_upload_(true) {
19 } 20 }
20 21
21 AcceleratedSurfaceContainerMac::~AcceleratedSurfaceContainerMac() { 22 AcceleratedSurfaceContainerMac::~AcceleratedSurfaceContainerMac() {
22 ReleaseIOSurface(); 23 ReleaseIOSurface();
23 } 24 }
24 25
25 void AcceleratedSurfaceContainerMac::ReleaseIOSurface() { 26 void AcceleratedSurfaceContainerMac::ReleaseIOSurface() {
26 if (surface_) { 27 if (surface_) {
27 CFRelease(surface_); 28 CFRelease(surface_);
28 surface_ = NULL; 29 surface_ = NULL;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); 71 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize();
71 GLenum target = GL_TEXTURE_RECTANGLE_ARB; 72 GLenum target = GL_TEXTURE_RECTANGLE_ARB;
72 if (!texture_) { 73 if (!texture_) {
73 if ((io_surface_support && !surface_) || 74 if ((io_surface_support && !surface_) ||
74 (!io_surface_support && !transport_dib_.get())) 75 (!io_surface_support && !transport_dib_.get()))
75 return; 76 return;
76 glGenTextures(1, &texture_); 77 glGenTextures(1, &texture_);
77 glBindTexture(target, texture_); 78 glBindTexture(target, texture_);
78 glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 79 glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
79 glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 80 glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
80 // When using an IOSurface, the texture does not need to be repeatedly 81 if (!io_surface_support) {
81 // uploaded, so bind the IOSurface once during texture gen in this case.
82 if (io_surface_support) {
83 DCHECK(surface_);
84 // Don't think we need to identify a plane.
85 GLuint plane = 0;
86 io_surface_support->CGLTexImageIOSurface2D(context,
87 target,
88 GL_RGBA,
89 width_,
90 height_,
91 GL_BGRA,
92 GL_UNSIGNED_INT_8_8_8_8_REV,
93 surface_,
94 plane);
95 } else {
96 // Reserve space on the card for the actual texture upload, done with the 82 // Reserve space on the card for the actual texture upload, done with the
97 // glTexSubImage2D() call, below. 83 // glTexSubImage2D() call, below.
98 glTexImage2D(target, 84 glTexImage2D(target,
99 0, // mipmap level 0 85 0, // mipmap level 0
100 GL_RGBA, // internal format 86 GL_RGBA, // internal format
101 width_, 87 width_,
102 height_, 88 height_,
103 0, // no border 89 0, // no border
104 GL_BGRA, // The GPU plugin read BGRA pixels 90 GL_BGRA, // The GPU plugin read BGRA pixels
105 GL_UNSIGNED_INT_8_8_8_8_REV, 91 GL_UNSIGNED_INT_8_8_8_8_REV,
106 NULL); // No data, this call just reserves room. 92 NULL); // No data, this call just reserves room.
107 } 93 }
108 } 94 }
109 95
96 // When using an IOSurface, the texture does not need to be repeatedly
97 // uploaded, just when we've been told we have to.
98 if (io_surface_support && texture_needs_upload_) {
99 DCHECK(surface_);
100 glBindTexture(target, texture_);
101 // Don't think we need to identify a plane.
102 GLuint plane = 0;
103 io_surface_support->CGLTexImageIOSurface2D(context,
104 target,
105 GL_RGBA,
106 width_,
107 height_,
108 GL_BGRA,
109 GL_UNSIGNED_INT_8_8_8_8_REV,
110 surface_,
111 plane);
112 texture_needs_upload_ = false;
113 }
110 // If using TransportDIBs, the texture needs to be uploaded every frame. 114 // If using TransportDIBs, the texture needs to be uploaded every frame.
111 if (transport_dib_.get() != NULL) { 115 if (transport_dib_.get() != NULL) {
112 void* pixel_memory = transport_dib_->memory(); 116 void* pixel_memory = transport_dib_->memory();
113 if (pixel_memory) { 117 if (pixel_memory) {
114 glBindTexture(target, texture_); 118 glBindTexture(target, texture_);
115 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // Needed for NPOT textures. 119 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // Needed for NPOT textures.
116 glTexSubImage2D(target, 120 glTexSubImage2D(target,
117 0, // mipmap level 0 121 0, // mipmap level 0
118 0, // x-offset 122 0, // x-offset
119 0, // y-offset 123 0, // y-offset
(...skipping 29 matching lines...) Expand all
149 glDisable(target); 153 glDisable(target);
150 } 154 }
151 } 155 }
152 156
153 void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion( 157 void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion(
154 AcceleratedSurfaceContainerManagerMac* manager) { 158 AcceleratedSurfaceContainerManagerMac* manager) {
155 manager->EnqueueTextureForDeletion(texture_); 159 manager->EnqueueTextureForDeletion(texture_);
156 texture_ = 0; 160 texture_ = 0;
157 } 161 }
158 162
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698