summaryrefslogtreecommitdiffstats
path: root/content/common/gpu/client
diff options
context:
space:
mode:
Diffstat (limited to 'content/common/gpu/client')
-rw-r--r--content/common/gpu/client/gl_helper.cc35
-rw-r--r--content/common/gpu/client/gl_helper.h13
2 files changed, 48 insertions, 0 deletions
diff --git a/content/common/gpu/client/gl_helper.cc b/content/common/gpu/client/gl_helper.cc
index 849998c..2ce57d9 100644
--- a/content/common/gpu/client/gl_helper.cc
+++ b/content/common/gpu/client/gl_helper.cc
@@ -634,6 +634,41 @@ void GLHelper::CopySubBufferDamage(WebKit::WebGLId texture,
}
}
+WebKit::WebGLId GLHelper::CreateTexture() {
+ WebKit::WebGLId texture = context_->createTexture();
+ content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_,
+ texture);
+ context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ return texture;
+}
+
+void GLHelper::ResizeTexture(WebKit::WebGLId texture, const gfx::Size& size) {
+ content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture);
+ context_->texImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+ size.width(), size.height(), 0,
+ GL_RGB, GL_UNSIGNED_BYTE, NULL);
+}
+
+void GLHelper::CopyTextureSubImage(WebKit::WebGLId texture,
+ const gfx::Rect& rect) {
+ content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture);
+ context_->copyTexSubImage2D(GL_TEXTURE_2D, 0,
+ rect.x(), rect.y(),
+ rect.x(), rect.y(), rect.width(), rect.height());
+}
+
+void GLHelper::CopyTextureFullImage(WebKit::WebGLId texture,
+ const gfx::Size& size) {
+ content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture);
+ context_->copyTexImage2D(GL_TEXTURE_2D, 0,
+ GL_RGB,
+ 0, 0,
+ size.width(), size.height(), 0);
+}
+
void GLHelper::CopyTextureToImpl::ReadbackPlane(
TextureFrameBufferPair* source,
media::VideoFrame* target,
diff --git a/content/common/gpu/client/gl_helper.h b/content/common/gpu/client/gl_helper.h
index c312b9d..849ffc2 100644
--- a/content/common/gpu/client/gl_helper.h
+++ b/content/common/gpu/client/gl_helper.h
@@ -262,6 +262,19 @@ class CONTENT_EXPORT GLHelper {
const SkRegion& new_damage,
const SkRegion& old_damage);
+ // Simply creates a texture.
+ WebKit::WebGLId CreateTexture();
+
+ // Resizes the texture's size to |size|.
+ void ResizeTexture(WebKit::WebGLId texture, const gfx::Size& size);
+
+ // Copies the framebuffer data given in |rect| to |texture|.
+ void CopyTextureSubImage(WebKit::WebGLId texture, const gfx::Rect& rect);
+
+ // Copies the all framebuffer data to |texture|. |size| specifies the
+ // size of the framebuffer.
+ void CopyTextureFullImage(WebKit::WebGLId texture, const gfx::Size& size);
+
// A scaler will cache all intermediate textures and programs
// needed to scale from a specified size to a destination size.
// If the source or destination sizes changes, you must create