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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 ScopedTextureBinder(WebGraphicsContext3D* context, | 201 ScopedTextureBinder(WebGraphicsContext3D* context, |
202 WebGLId id) | 202 WebGLId id) |
203 : ScopedBinder<target>( | 203 : ScopedBinder<target>( |
204 context, | 204 context, |
205 id, | 205 id, |
206 &WebGraphicsContext3D::bindTexture) {} | 206 &WebGraphicsContext3D::bindTexture) {} |
207 }; | 207 }; |
208 | 208 |
209 class ScopedFlush { | 209 class ScopedFlush { |
210 public: | 210 public: |
211 ScopedFlush(WebGraphicsContext3D* context) | 211 explicit ScopedFlush(WebGraphicsContext3D* context) |
212 : context_(context) { | 212 : context_(context) { |
213 } | 213 } |
214 | 214 |
215 virtual ~ScopedFlush() { | 215 virtual ~ScopedFlush() { |
216 context_->flush(); | 216 context_->flush(); |
217 } | 217 } |
218 | 218 |
219 private: | 219 private: |
220 WebGraphicsContext3D* context_; | 220 WebGraphicsContext3D* context_; |
221 | 221 |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 } | 782 } |
783 return shader.Detach(); | 783 return shader.Detach(); |
784 } | 784 } |
785 | 785 |
786 void GLHelper::InitCopyTextToImpl() { | 786 void GLHelper::InitCopyTextToImpl() { |
787 // Lazily initialize |copy_texture_to_impl_| | 787 // Lazily initialize |copy_texture_to_impl_| |
788 if (!copy_texture_to_impl_.get()) | 788 if (!copy_texture_to_impl_.get()) |
789 copy_texture_to_impl_.reset(new CopyTextureToImpl(context_, | 789 copy_texture_to_impl_.reset(new CopyTextureToImpl(context_, |
790 context_for_thread_, | 790 context_for_thread_, |
791 this)); | 791 this)); |
792 | |
793 } | 792 } |
794 | 793 |
795 void GLHelper::CopySubBufferDamage(WebKit::WebGLId texture, | 794 void GLHelper::CopySubBufferDamage(WebKit::WebGLId texture, |
796 WebKit::WebGLId previous_texture, | 795 WebKit::WebGLId previous_texture, |
797 const SkRegion& new_damage, | 796 const SkRegion& new_damage, |
798 const SkRegion& old_damage) { | 797 const SkRegion& old_damage) { |
799 SkRegion region(old_damage); | 798 SkRegion region(old_damage); |
800 if (region.op(new_damage, SkRegion::kDifference_Op)) { | 799 if (region.op(new_damage, SkRegion::kDifference_Op)) { |
801 ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer()); | 800 ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer()); |
802 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( | 801 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( |
803 context_, dst_framebuffer); | 802 context_, dst_framebuffer); |
804 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture); | 803 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture); |
805 context_->framebufferTexture2D(GL_FRAMEBUFFER, | 804 context_->framebufferTexture2D(GL_FRAMEBUFFER, |
806 GL_COLOR_ATTACHMENT0, | 805 GL_COLOR_ATTACHMENT0, |
807 GL_TEXTURE_2D, | 806 GL_TEXTURE_2D, |
808 previous_texture, | 807 previous_texture, |
809 0); | 808 0); |
810 for (SkRegion::Iterator it(region); !it.done(); it.next()) { | 809 for (SkRegion::Iterator it(region); !it.done(); it.next()) { |
811 const SkIRect& rect = it.rect(); | 810 const SkIRect& rect = it.rect(); |
812 context_->copyTexSubImage2D(GL_TEXTURE_2D, 0, | 811 context_->copyTexSubImage2D(GL_TEXTURE_2D, 0, |
813 rect.x(), rect.y(), | 812 rect.x(), rect.y(), |
814 rect.x(), rect.y(), | 813 rect.x(), rect.y(), |
815 rect.width(), rect.height()); | 814 rect.width(), rect.height()); |
816 } | 815 } |
817 context_->flush(); | 816 context_->flush(); |
818 } | 817 } |
819 } | 818 } |
820 | 819 |
821 } // namespace content | 820 } // namespace content |
OLD | NEW |