OLD | NEW |
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 <queue> | 7 #include <queue> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 } | 405 } |
406 | 406 |
407 WebGLId GLHelper::CopyTextureToImpl::ScaleTexture( | 407 WebGLId GLHelper::CopyTextureToImpl::ScaleTexture( |
408 WebGLId src_texture, | 408 WebGLId src_texture, |
409 const gfx::Size& src_size, | 409 const gfx::Size& src_size, |
410 const gfx::Rect& src_subrect, | 410 const gfx::Rect& src_subrect, |
411 const gfx::Size& dst_size) { | 411 const gfx::Size& dst_size) { |
412 WebGLId dst_texture = context_->createTexture(); | 412 WebGLId dst_texture = context_->createTexture(); |
413 { | 413 { |
414 ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer()); | 414 ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer()); |
415 ScopedFramebufferBinder<GL_DRAW_FRAMEBUFFER> framebuffer_binder( | 415 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( |
416 context_, dst_framebuffer); | 416 context_, dst_framebuffer); |
417 { | 417 { |
418 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder( | 418 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder( |
419 context_, dst_texture); | 419 context_, dst_texture); |
420 context_->texImage2D(GL_TEXTURE_2D, | 420 context_->texImage2D(GL_TEXTURE_2D, |
421 0, | 421 0, |
422 GL_RGBA, | 422 GL_RGBA, |
423 dst_size.width(), | 423 dst_size.width(), |
424 dst_size.height(), | 424 dst_size.height(), |
425 0, | 425 0, |
426 GL_RGBA, | 426 GL_RGBA, |
427 GL_UNSIGNED_BYTE, | 427 GL_UNSIGNED_BYTE, |
428 NULL); | 428 NULL); |
429 context_->framebufferTexture2D(GL_DRAW_FRAMEBUFFER, | 429 context_->framebufferTexture2D(GL_FRAMEBUFFER, |
430 GL_COLOR_ATTACHMENT0, | 430 GL_COLOR_ATTACHMENT0, |
431 GL_TEXTURE_2D, | 431 GL_TEXTURE_2D, |
432 dst_texture, | 432 dst_texture, |
433 0); | 433 0); |
434 } | 434 } |
435 | 435 |
436 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, src_texture); | 436 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, src_texture); |
437 ScopedBufferBinder<GL_ARRAY_BUFFER> buffer_binder( | 437 ScopedBufferBinder<GL_ARRAY_BUFFER> buffer_binder( |
438 context_, vertex_attributes_buffer_); | 438 context_, vertex_attributes_buffer_); |
439 | 439 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 // lock, and we'll exit early, or we ensure that the texture is bound to the | 540 // lock, and we'll exit early, or we ensure that the texture is bound to the |
541 // framebuffer before the main thread has a chance to delete it. | 541 // framebuffer before the main thread has a chance to delete it. |
542 base::AutoLock auto_lock(request->lock); | 542 base::AutoLock auto_lock(request->lock); |
543 if (!request->texture || !request->pixels) | 543 if (!request->texture || !request->pixels) |
544 return; | 544 return; |
545 pixels = request->pixels; | 545 pixels = request->pixels; |
546 request->pixels = NULL; | 546 request->pixels = NULL; |
547 size = request->size; | 547 size = request->size; |
548 { | 548 { |
549 ScopedFlush flush(context); | 549 ScopedFlush flush(context); |
550 ScopedFramebufferBinder<GL_READ_FRAMEBUFFER> framebuffer_binder( | 550 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( |
551 context, dst_framebuffer); | 551 context, dst_framebuffer); |
552 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder( | 552 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder( |
553 context, request->texture); | 553 context, request->texture); |
554 context->framebufferTexture2D(GL_READ_FRAMEBUFFER, | 554 context->framebufferTexture2D(GL_FRAMEBUFFER, |
555 GL_COLOR_ATTACHMENT0, | 555 GL_COLOR_ATTACHMENT0, |
556 GL_TEXTURE_2D, | 556 GL_TEXTURE_2D, |
557 request->texture, | 557 request->texture, |
558 0); | 558 0); |
559 } | 559 } |
560 } | 560 } |
561 bool result = context->readBackFramebuffer( | 561 bool result = context->readBackFramebuffer( |
562 pixels, | 562 pixels, |
563 4 * size.GetArea(), | 563 4 * size.GetArea(), |
564 dst_framebuffer.id(), | 564 dst_framebuffer.id(), |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 WebKit::WGC3Dint compile_status = 0; | 673 WebKit::WGC3Dint compile_status = 0; |
674 context_->getShaderiv(shader, GL_COMPILE_STATUS, &compile_status); | 674 context_->getShaderiv(shader, GL_COMPILE_STATUS, &compile_status); |
675 if (!compile_status) { | 675 if (!compile_status) { |
676 LOG(ERROR) << std::string(context_->getShaderInfoLog(shader).utf8()); | 676 LOG(ERROR) << std::string(context_->getShaderInfoLog(shader).utf8()); |
677 return 0; | 677 return 0; |
678 } | 678 } |
679 return shader.Detach(); | 679 return shader.Detach(); |
680 } | 680 } |
681 | 681 |
682 } // namespace content | 682 } // namespace content |
OLD | NEW |