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

Side by Side Diff: content/common/gpu/client/gl_helper.cc

Issue 10214014: Backport to R19 of r132638 r133017 r133579 r133732 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src
Patch Set: Created 8 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 | 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/common/gpu/client/gl_helper.h" 5 #include "content/common/gpu/client/gl_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " 8 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h "
9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
10 #include "ui/gfx/gl/gl_bindings.h" 10 #include "ui/gfx/gl/gl_bindings.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 class ScopedTextureBinder : ScopedBinder<target> { 164 class ScopedTextureBinder : ScopedBinder<target> {
165 public: 165 public:
166 ScopedTextureBinder(WebKit::WebGraphicsContext3D* context, 166 ScopedTextureBinder(WebKit::WebGraphicsContext3D* context,
167 WebKit::WebGLId id) 167 WebKit::WebGLId id)
168 : ScopedBinder<target>( 168 : ScopedBinder<target>(
169 context, 169 context,
170 id, 170 id,
171 &WebKit::WebGraphicsContext3D::bindTexture) {} 171 &WebKit::WebGraphicsContext3D::bindTexture) {}
172 }; 172 };
173 173
174 class ScopedFlush {
175 public:
176 ScopedFlush(WebKit::WebGraphicsContext3D* context)
177 : context_(context) {
178 }
179
180 virtual ~ScopedFlush() {
181 context_->flush();
182 }
183
184 private:
185 WebKit::WebGraphicsContext3D* context_;
186
187 DISALLOW_COPY_AND_ASSIGN(ScopedFlush);
188 };
189
174 } // namespace 190 } // namespace
175 191
176 namespace content { 192 namespace content {
177 193
178 // Implements GLHelper::CopyTextureTo and encapsulates the data needed for it. 194 // Implements GLHelper::CopyTextureTo and encapsulates the data needed for it.
179 class GLHelper::CopyTextureToImpl { 195 class GLHelper::CopyTextureToImpl {
180 public: 196 public:
181 CopyTextureToImpl(WebKit::WebGraphicsContext3D* context, 197 CopyTextureToImpl(WebKit::WebGraphicsContext3D* context,
182 GLHelper* helper) 198 GLHelper* helper)
183 : context_(context), 199 : context_(context),
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 296
281 void GLHelper::CopyTextureToImpl::Detach() { 297 void GLHelper::CopyTextureToImpl::Detach() {
282 program_.Detach(); 298 program_.Detach();
283 vertex_attributes_buffer_.Detach(); 299 vertex_attributes_buffer_.Detach();
284 } 300 }
285 301
286 bool GLHelper::CopyTextureToImpl::CopyTextureTo(WebKit::WebGLId src_texture, 302 bool GLHelper::CopyTextureToImpl::CopyTextureTo(WebKit::WebGLId src_texture,
287 const gfx::Size& src_size, 303 const gfx::Size& src_size,
288 const gfx::Size& dst_size, 304 const gfx::Size& dst_size,
289 unsigned char* out) { 305 unsigned char* out) {
306 ScopedFlush flush(context_);
290 ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer()); 307 ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer());
291 ScopedTexture dst_texture(context_, context_->createTexture()); 308 ScopedTexture dst_texture(context_, context_->createTexture());
292 { 309 {
293 ScopedFramebufferBinder<GL_DRAW_FRAMEBUFFER> framebuffer_binder( 310 ScopedFramebufferBinder<GL_DRAW_FRAMEBUFFER> framebuffer_binder(
294 context_, dst_framebuffer); 311 context_, dst_framebuffer);
295 { 312 {
296 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, dst_texture); 313 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, dst_texture);
297 context_->texImage2D(GL_TEXTURE_2D, 314 context_->texImage2D(GL_TEXTURE_2D,
298 0, 315 0,
299 GL_RGBA, 316 GL_RGBA,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 WebKit::WGC3Dint compile_status = 0; 408 WebKit::WGC3Dint compile_status = 0;
392 context_->getShaderiv(shader, GL_COMPILE_STATUS, &compile_status); 409 context_->getShaderiv(shader, GL_COMPILE_STATUS, &compile_status);
393 if (!compile_status) { 410 if (!compile_status) {
394 LOG(ERROR) << std::string(context_->getShaderInfoLog(shader).utf8()); 411 LOG(ERROR) << std::string(context_->getShaderInfoLog(shader).utf8());
395 return 0; 412 return 0;
396 } 413 }
397 return shader.Detach(); 414 return shader.Detach();
398 } 415 }
399 416
400 } // namespace content 417 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/image_transport_factory.cc ('k') | content/common/gpu/texture_image_transport_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698