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

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

Issue 11558039: Subrect snapshot support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved capture to the readback method Created 8 years 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 <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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 void CropScaleReadbackAndCleanTexture( 262 void CropScaleReadbackAndCleanTexture(
263 WebGLId src_texture, 263 WebGLId src_texture,
264 const gfx::Size& src_size, 264 const gfx::Size& src_size,
265 const gfx::Rect& src_subrect, 265 const gfx::Rect& src_subrect,
266 const gfx::Size& dst_size, 266 const gfx::Size& dst_size,
267 unsigned char* out, 267 unsigned char* out,
268 const base::Callback<void(bool)>& callback); 268 const base::Callback<void(bool)>& callback);
269 269
270 void ReadbackTextureSync(WebGLId texture, 270 void ReadbackTextureSync(WebGLId texture,
271 const gfx::Size& size, 271 const gfx::Rect& src_rect,
272 unsigned char* out); 272 unsigned char* out);
273 273
274 WebKit::WebGLId CopyAndScaleTexture(WebGLId texture, 274 WebKit::WebGLId CopyAndScaleTexture(WebGLId texture,
275 const gfx::Size& src_size, 275 const gfx::Size& src_size,
276 const gfx::Size& dst_size, 276 const gfx::Size& dst_size,
277 bool vertically_flip_texture); 277 bool vertically_flip_texture);
278 278
279 private: 279 private:
280 // A single request to CropScaleReadbackAndCleanTexture. 280 // A single request to CropScaleReadbackAndCleanTexture.
281 // Thread-safety notes: the main thread creates instances of this class. The 281 // Thread-safety notes: the main thread creates instances of this class. The
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 request_queue_.push(request); 551 request_queue_.push(request);
552 552
553 g_gl_helper_thread.Pointer()->message_loop_proxy()->PostTask(FROM_HERE, 553 g_gl_helper_thread.Pointer()->message_loop_proxy()->PostTask(FROM_HERE,
554 base::Bind(&ReadBackFramebuffer, 554 base::Bind(&ReadBackFramebuffer,
555 request, 555 request,
556 context_for_thread_, 556 context_for_thread_,
557 base::MessageLoopProxy::current())); 557 base::MessageLoopProxy::current()));
558 } 558 }
559 559
560 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(WebGLId texture, 560 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(WebGLId texture,
561 const gfx::Size& size, 561 const gfx::Rect& src_rect,
562 unsigned char* out) { 562 unsigned char* out) {
563 ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer()); 563 ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer());
564 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( 564 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(
565 context_, dst_framebuffer); 565 context_, dst_framebuffer);
566 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture); 566 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture);
567 context_->framebufferTexture2D(GL_FRAMEBUFFER, 567 context_->framebufferTexture2D(GL_FRAMEBUFFER,
568 GL_COLOR_ATTACHMENT0, 568 GL_COLOR_ATTACHMENT0,
569 GL_TEXTURE_2D, 569 GL_TEXTURE_2D,
570 texture, 570 texture,
571 0); 571 0);
572 context_->readPixels(0, 572 context_->readPixels(src_rect.x(),
573 0, 573 src_rect.y(),
574 size.width(), 574 src_rect.width(),
575 size.height(), 575 src_rect.height(),
576 GL_RGBA, 576 GL_RGBA,
577 GL_UNSIGNED_BYTE, 577 GL_UNSIGNED_BYTE,
578 out); 578 out);
579 } 579 }
580 580
581 WebKit::WebGLId GLHelper::CopyTextureToImpl::CopyAndScaleTexture( 581 WebKit::WebGLId GLHelper::CopyTextureToImpl::CopyAndScaleTexture(
582 WebGLId src_texture, 582 WebGLId src_texture,
583 const gfx::Size& src_size, 583 const gfx::Size& src_size,
584 const gfx::Size& dst_size, 584 const gfx::Size& dst_size,
585 bool vertically_flip_texture) { 585 bool vertically_flip_texture) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 InitCopyTextToImpl(); 733 InitCopyTextToImpl();
734 copy_texture_to_impl_->CropScaleReadbackAndCleanTexture(src_texture, 734 copy_texture_to_impl_->CropScaleReadbackAndCleanTexture(src_texture,
735 src_size, 735 src_size,
736 src_subrect, 736 src_subrect,
737 dst_size, 737 dst_size,
738 out, 738 out,
739 callback); 739 callback);
740 } 740 }
741 741
742 void GLHelper::ReadbackTextureSync(WebKit::WebGLId texture, 742 void GLHelper::ReadbackTextureSync(WebKit::WebGLId texture,
743 const gfx::Size& size, 743 const gfx::Rect& src_rect,
744 unsigned char* out) { 744 unsigned char* out) {
745 InitCopyTextToImpl(); 745 InitCopyTextToImpl();
746 copy_texture_to_impl_->ReadbackTextureSync(texture, 746 copy_texture_to_impl_->ReadbackTextureSync(texture,
747 size, 747 src_rect,
748 out); 748 out);
749 } 749 }
750 750
751 WebKit::WebGLId GLHelper::CopyTexture(WebKit::WebGLId texture, 751 WebKit::WebGLId GLHelper::CopyTexture(WebKit::WebGLId texture,
752 const gfx::Size& size) { 752 const gfx::Size& size) {
753 InitCopyTextToImpl(); 753 InitCopyTextToImpl();
754 return copy_texture_to_impl_->CopyAndScaleTexture(texture, 754 return copy_texture_to_impl_->CopyAndScaleTexture(texture,
755 size, 755 size,
756 size, 756 size,
757 false); 757 false);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 context_->copyTexSubImage2D(GL_TEXTURE_2D, 0, 812 context_->copyTexSubImage2D(GL_TEXTURE_2D, 0,
813 rect.x(), rect.y(), 813 rect.x(), rect.y(),
814 rect.x(), rect.y(), 814 rect.x(), rect.y(),
815 rect.width(), rect.height()); 815 rect.width(), rect.height());
816 } 816 }
817 context_->flush(); 817 context_->flush();
818 } 818 }
819 } 819 }
820 820
821 } // namespace content 821 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698