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

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

Issue 11194042: Implement TextureImageTransportSurface using texture mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h "
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
20 #include "third_party/skia/include/core/SkRegion.h"
20 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
21 #include "ui/gfx/size.h" 22 #include "ui/gfx/size.h"
23 #include "ui/gfx/skia_util.h"
jonathan.backer 2012/12/04 19:15:13 nit: necessary?
no sievers 2012/12/05 22:02:34 Done.
22 #include "ui/gl/gl_bindings.h" 24 #include "ui/gl/gl_bindings.h"
23 25
24 using WebKit::WebGLId; 26 using WebKit::WebGLId;
25 using WebKit::WebGraphicsContext3D; 27 using WebKit::WebGraphicsContext3D;
26 28
27 namespace { 29 namespace {
28 30
29 const char kGLHelperThreadName[] = "GLHelperThread"; 31 const char kGLHelperThreadName[] = "GLHelperThread";
30 32
31 class GLHelperThread : public base::Thread { 33 class GLHelperThread : public base::Thread {
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 786
785 void GLHelper::InitCopyTextToImpl() { 787 void GLHelper::InitCopyTextToImpl() {
786 // Lazily initialize |copy_texture_to_impl_| 788 // Lazily initialize |copy_texture_to_impl_|
787 if (!copy_texture_to_impl_.get()) 789 if (!copy_texture_to_impl_.get())
788 copy_texture_to_impl_.reset(new CopyTextureToImpl(context_, 790 copy_texture_to_impl_.reset(new CopyTextureToImpl(context_,
789 context_for_thread_, 791 context_for_thread_,
790 this)); 792 this));
791 793
792 } 794 }
793 795
796 void GLHelper::CopySubBufferDamage(WebKit::WebGLId texture,
797 WebKit::WebGLId previous_texture,
798 const SkRegion& new_damage,
799 const SkRegion& old_damage) {
800 SkRegion region(old_damage);
801 if (region.op(new_damage, SkRegion::kDifference_Op)) {
802 ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer());
803 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(
804 context_, dst_framebuffer);
805 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture);
806 context_->framebufferTexture2D(GL_FRAMEBUFFER,
807 GL_COLOR_ATTACHMENT0,
808 GL_TEXTURE_2D,
809 previous_texture,
810 0);
811 for (SkRegion::Iterator it(region); !it.done(); it.next()) {
812 const SkIRect& rect = it.rect();
813 context_->copyTexSubImage2D(GL_TEXTURE_2D, 0,
814 rect.x(), rect.y(),
815 rect.x(), rect.y(),
816 rect.width(), rect.height());
817 }
818 context_->flush();
819 }
820 }
821
794 } // namespace content 822 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698