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

Side by Side Diff: content/renderer/pepper/pepper_platform_context_3d_impl.cc

Issue 9580030: Inform webkit when PPAPI plugin contents are opaque. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix is_opaque Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "content/renderer/pepper/pepper_platform_context_3d_impl.h" 5 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/common/gpu/client/content_gl_context.h" 8 #include "content/common/gpu/client/content_gl_context.h"
9 #include "content/common/gpu/client/gpu_channel_host.h" 9 #include "content/common/gpu/client/gpu_channel_host.h"
10 #include "content/common/gpu/client/command_buffer_proxy.h" 10 #include "content/common/gpu/client/command_buffer_proxy.h"
11 #include "content/renderer/pepper/pepper_parent_context_provider.h" 11 #include "content/renderer/pepper/pepper_parent_context_provider.h"
12 #include "content/renderer/render_thread_impl.h" 12 #include "content/renderer/render_thread_impl.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 14 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
15 #include "gpu/command_buffer/client/gles2_implementation.h" 15 #include "gpu/command_buffer/client/gles2_implementation.h"
16 #include "ui/gfx/gl/gpu_preference.h" 16 #include "ui/gfx/gl/gpu_preference.h"
17 17
18 #ifdef ENABLE_GPU 18 #ifdef ENABLE_GPU
19 19
20 PlatformContext3DImpl::PlatformContext3DImpl( 20 PlatformContext3DImpl::PlatformContext3DImpl(
21 PepperParentContextProvider* parent_context_provider) 21 PepperParentContextProvider* parent_context_provider)
22 : parent_context_provider_(parent_context_provider), 22 : parent_context_provider_(parent_context_provider),
23 parent_texture_id_(0), 23 parent_texture_id_(0),
24 has_alpha_(false),
24 command_buffer_(NULL), 25 command_buffer_(NULL),
25 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 26 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
26 } 27 }
27 28
28 PlatformContext3DImpl::~PlatformContext3DImpl() { 29 PlatformContext3DImpl::~PlatformContext3DImpl() {
29 if (parent_context_.get() && parent_texture_id_ != 0) { 30 if (parent_context_.get() && parent_texture_id_ != 0) {
30 // Flush any remaining commands in the parent context to make sure the 31 // Flush any remaining commands in the parent context to make sure the
31 // texture id accounting stays consistent. 32 // texture id accounting stays consistent.
32 gpu::gles2::GLES2Implementation* parent_gles2 = 33 gpu::gles2::GLES2Implementation* parent_gles2 =
33 parent_context_->GetImplementation(); 34 parent_context_->GetImplementation();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 for (const int32_t* attr = attrib_list; 92 for (const int32_t* attr = attrib_list;
92 attr[0] != ContentGLContext::NONE; 93 attr[0] != ContentGLContext::NONE;
93 attr += 2) { 94 attr += 2) {
94 switch (attr[0]) { 95 switch (attr[0]) {
95 case ContentGLContext::WIDTH: 96 case ContentGLContext::WIDTH:
96 surface_size.set_width(attr[1]); 97 surface_size.set_width(attr[1]);
97 break; 98 break;
98 case ContentGLContext::HEIGHT: 99 case ContentGLContext::HEIGHT:
99 surface_size.set_height(attr[1]); 100 surface_size.set_height(attr[1]);
100 break; 101 break;
102 case ContentGLContext::ALPHA_SIZE:
103 has_alpha_ = attr[1] > 0;
104 // fall-through
101 default: 105 default:
102 attribs.push_back(attr[0]); 106 attribs.push_back(attr[0]);
103 attribs.push_back(attr[1]); 107 attribs.push_back(attr[1]);
104 break; 108 break;
105 } 109 }
106 } 110 }
107 attribs.push_back(ContentGLContext::NONE); 111 attribs.push_back(ContentGLContext::NONE);
108 } 112 }
109 113
110 command_buffer_ = channel_->CreateOffscreenCommandBuffer( 114 command_buffer_ = channel_->CreateOffscreenCommandBuffer(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return false; 149 return false;
146 150
147 return true; 151 return true;
148 } 152 }
149 153
150 unsigned PlatformContext3DImpl::GetBackingTextureId() { 154 unsigned PlatformContext3DImpl::GetBackingTextureId() {
151 DCHECK(command_buffer_); 155 DCHECK(command_buffer_);
152 return parent_texture_id_; 156 return parent_texture_id_;
153 } 157 }
154 158
159 bool PlatformContext3DImpl::IsOpaque() {
160 DCHECK(command_buffer_);
161 return !has_alpha_;
162 }
163
155 gpu::CommandBuffer* PlatformContext3DImpl::GetCommandBuffer() { 164 gpu::CommandBuffer* PlatformContext3DImpl::GetCommandBuffer() {
156 return command_buffer_; 165 return command_buffer_;
157 } 166 }
158 167
159 int PlatformContext3DImpl::GetCommandBufferRouteId() { 168 int PlatformContext3DImpl::GetCommandBufferRouteId() {
160 DCHECK(command_buffer_); 169 DCHECK(command_buffer_);
161 return command_buffer_->route_id(); 170 return command_buffer_->route_id();
162 } 171 }
163 172
164 void PlatformContext3DImpl::SetContextLostCallback(const base::Closure& task) { 173 void PlatformContext3DImpl::SetContextLostCallback(const base::Closure& task) {
165 context_lost_callback_ = task; 174 context_lost_callback_ = task;
166 } 175 }
167 176
168 bool PlatformContext3DImpl::Echo(const base::Closure& task) { 177 bool PlatformContext3DImpl::Echo(const base::Closure& task) {
169 return command_buffer_->Echo(task); 178 return command_buffer_->Echo(task);
170 } 179 }
171 180
172 void PlatformContext3DImpl::OnContextLost() { 181 void PlatformContext3DImpl::OnContextLost() {
173 DCHECK(command_buffer_); 182 DCHECK(command_buffer_);
174 183
175 if (!context_lost_callback_.is_null()) 184 if (!context_lost_callback_.is_null())
176 context_lost_callback_.Run(); 185 context_lost_callback_.Run();
177 } 186 }
178 187
179 #endif // ENABLE_GPU 188 #endif // ENABLE_GPU
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_platform_context_3d_impl.h ('k') | webkit/plugins/ppapi/plugin_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698