Index: content/common/gpu/client/gl_helper.cc |
diff --git a/content/common/gpu/client/gl_helper.cc b/content/common/gpu/client/gl_helper.cc |
index ef862966fad79849a252fce6cb2f18a8043fd1aa..560882ceddf8ddd0e31efe061b171e4b443073e9 100644 |
--- a/content/common/gpu/client/gl_helper.cc |
+++ b/content/common/gpu/client/gl_helper.cc |
@@ -15,10 +15,12 @@ |
#include "base/synchronization/waitable_event.h" |
#include "base/threading/thread.h" |
#include "base/threading/thread_restrictions.h" |
+#include "third_party/skia/include/core/SkRegion.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
#include "ui/gfx/rect.h" |
#include "ui/gfx/size.h" |
+#include "ui/gfx/skia_util.h" |
#include "ui/gl/gl_bindings.h" |
using WebKit::WebGLId; |
@@ -751,4 +753,29 @@ void GLHelper::InitCopyTextToImpl() { |
} |
+void GLHelper::CopySubBufferDamage(WebKit::WebGLId texture, |
+ WebKit::WebGLId previous_texture, |
+ const gfx::Rect& new_damage, |
+ const gfx::Rect& old_damage) { |
+ SkRegion region(RectToSkIRect(old_damage)); |
+ region.op(RectToSkIRect(new_damage), SkRegion::kDifference_Op); |
jonathan.backer
2012/11/12 16:52:15
Can we early exit if the region is empty? A common
no sievers
2012/11/19 20:30:44
Done.
|
+ ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer()); |
+ ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( |
+ context_, dst_framebuffer); |
+ ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture); |
+ context_->framebufferTexture2D(GL_FRAMEBUFFER, |
+ GL_COLOR_ATTACHMENT0, |
+ GL_TEXTURE_2D, |
+ previous_texture, |
+ 0); |
+ for (SkRegion::Iterator it(region); !it.done(); it.next()) { |
+ const SkIRect& rect = it.rect(); |
+ context_->copyTexSubImage2D(GL_TEXTURE_2D, 0, |
+ rect.x(), rect.y(), |
+ rect.x(), rect.y(), |
+ rect.width(), rect.height()); |
+ } |
+ context_->flush(); |
+} |
+ |
} // namespace content |