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

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

Issue 17971002: Make RenderWidgetHostViewAura::CopyFromCompositingSurface readback layer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tabcapture-aura: SpellingIsHardLetsGoShopping Created 7 years, 5 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 <queue> 7 #include <queue>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "cc/resources/sync_point_helper.h" 17 #include "cc/resources/sync_point_helper.h"
18 #include "content/common/gpu/client/gl_helper_scaling.h" 18 #include "content/common/gpu/client/gl_helper_scaling.h"
19 #include "gpu/command_buffer/common/mailbox.h"
19 #include "media/base/video_frame.h" 20 #include "media/base/video_frame.h"
20 #include "media/base/video_util.h" 21 #include "media/base/video_util.h"
21 #include "third_party/WebKit/public/platform/WebCString.h" 22 #include "third_party/WebKit/public/platform/WebCString.h"
22 #include "third_party/skia/include/core/SkRegion.h" 23 #include "third_party/skia/include/core/SkRegion.h"
23 #include "ui/gfx/rect.h" 24 #include "ui/gfx/rect.h"
24 #include "ui/gfx/size.h" 25 #include "ui/gfx/size.h"
25 #include "ui/gl/gl_bindings.h" 26 #include "ui/gl/gl_bindings.h"
26 27
27 using WebKit::WebGLId; 28 using WebKit::WebGLId;
28 using WebKit::WebGraphicsContext3D; 29 using WebKit::WebGraphicsContext3D;
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 copy_texture_to_impl_->CropScaleReadbackAndCleanTexture( 535 copy_texture_to_impl_->CropScaleReadbackAndCleanTexture(
535 src_texture, 536 src_texture,
536 src_size, 537 src_size,
537 src_subrect, 538 src_subrect,
538 dst_size, 539 dst_size,
539 out, 540 out,
540 callback, 541 callback,
541 GLHelper::SCALER_QUALITY_FAST); 542 GLHelper::SCALER_QUALITY_FAST);
542 } 543 }
543 544
545 void GLHelper::CropScaleReadbackAndCleanMailbox(
546 const gpu::Mailbox& src_mailbox,
547 uint32 sync_point,
548 const gfx::Size& src_size,
549 const gfx::Rect& src_subrect,
550 const gfx::Size& dst_size,
551 unsigned char* out,
552 const base::Callback<void(bool)>& callback) {
553 WebGLId mailbox_texture = ConsumeMailboxToTexture(src_mailbox, sync_point);
554 CropScaleReadbackAndCleanTexture(
555 mailbox_texture, src_size, src_subrect, dst_size, out, callback);
556 context_->deleteTexture(mailbox_texture);
557 }
558
544 void GLHelper::ReadbackTextureSync(WebKit::WebGLId texture, 559 void GLHelper::ReadbackTextureSync(WebKit::WebGLId texture,
545 const gfx::Rect& src_rect, 560 const gfx::Rect& src_rect,
546 unsigned char* out) { 561 unsigned char* out) {
547 InitCopyTextToImpl(); 562 InitCopyTextToImpl();
548 copy_texture_to_impl_->ReadbackTextureSync(texture, 563 copy_texture_to_impl_->ReadbackTextureSync(texture,
549 src_rect, 564 src_rect,
550 out); 565 out);
551 } 566 }
552 567
553 WebKit::WebGLId GLHelper::CopyTexture(WebKit::WebGLId texture, 568 WebKit::WebGLId GLHelper::CopyTexture(WebKit::WebGLId texture,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 WebKit::WebGLId texture = context_->createTexture(); 653 WebKit::WebGLId texture = context_->createTexture();
639 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, 654 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_,
640 texture); 655 texture);
641 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 656 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
642 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 657 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
643 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 658 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
644 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 659 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
645 return texture; 660 return texture;
646 } 661 }
647 662
663 WebKit::WebGLId GLHelper::ConsumeMailboxToTexture(const gpu::Mailbox& mailbox,
664 uint32 sync_point) {
665 if (mailbox.IsZero())
666 return 0;
667 if (sync_point)
668 context_->waitSyncPoint(sync_point);
669 WebKit::WebGLId texture = CreateTexture();
670 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_,
671 texture);
672 context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
673 return texture;
674 }
675
648 void GLHelper::ResizeTexture(WebKit::WebGLId texture, const gfx::Size& size) { 676 void GLHelper::ResizeTexture(WebKit::WebGLId texture, const gfx::Size& size) {
649 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture); 677 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture);
650 context_->texImage2D(GL_TEXTURE_2D, 0, GL_RGB, 678 context_->texImage2D(GL_TEXTURE_2D, 0, GL_RGB,
651 size.width(), size.height(), 0, 679 size.width(), size.height(), 0,
652 GL_RGB, GL_UNSIGNED_BYTE, NULL); 680 GL_RGB, GL_UNSIGNED_BYTE, NULL);
653 } 681 }
654 682
655 void GLHelper::CopyTextureSubImage(WebKit::WebGLId texture, 683 void GLHelper::CopyTextureSubImage(WebKit::WebGLId texture,
656 const gfx::Rect& rect) { 684 const gfx::Rect& rect) {
657 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture); 685 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture);
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 quality, 988 quality,
961 src_size, 989 src_size,
962 src_subrect, 990 src_subrect,
963 dst_size, 991 dst_size,
964 dst_subrect, 992 dst_subrect,
965 flip_vertically, 993 flip_vertically,
966 use_mrt); 994 use_mrt);
967 } 995 }
968 996
969 } // namespace content 997 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/gl_helper.h ('k') | content/port/browser/render_widget_host_view_port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698