summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-11 14:15:28 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-11 14:15:28 +0000
commit1c75a370ce5ea49e230cae711a0b1d17dc072763 (patch)
treeb3612370e93b34c7ce4d631cf22cafb4d71329ea
parent9e814828186b00d3ead0edd3884e3185067875d5 (diff)
downloadchromium_src-1c75a370ce5ea49e230cae711a0b1d17dc072763.zip
chromium_src-1c75a370ce5ea49e230cae711a0b1d17dc072763.tar.gz
chromium_src-1c75a370ce5ea49e230cae711a0b1d17dc072763.tar.bz2
Plumb through EGL_NV_post_sub_buffer and GLX_MESA_copy_sub_buffer.
These two extensions allow a partial swap: just pushing part of the backbuffer to the front buffer. This will allow the WK compositor to push a partial update to the screen instead of a full frame update (https://bugs.webkit.org/show_bug.cgi?id=70533). We should be able to do something similar for TOUCHUI ImageTransportSurfaces (hence the hooks into GLSurface and the glPostSubBufferCHROMIUM command). Review URL: http://codereview.chromium.org/8512005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109625 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc14
-rw-r--r--content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h1
-rw-r--r--gpu/GLES2/gl2ext.h13
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py9
-rw-r--r--gpu/command_buffer/client/gles2_c_lib_autogen.h3
-rw-r--r--gpu/command_buffer/client/gles2_cmd_helper_autogen.h6
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc16
-rw-r--r--gpu/command_buffer/client/gles2_implementation_autogen.h2
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_autogen.h46
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_test_autogen.h19
-rw-r--r--gpu/command_buffer/common/gles2_cmd_ids_autogen.h1
-rw-r--r--gpu/command_buffer/service/feature_info.cc7
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc14
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h1
-rw-r--r--ui/gfx/gl/generate_bindings.py6
-rw-r--r--ui/gfx/gl/gl_surface.cc8
-rw-r--r--ui/gfx/gl/gl_surface.h4
-rw-r--r--ui/gfx/gl/gl_surface_egl.cc34
-rw-r--r--ui/gfx/gl/gl_surface_egl.h5
-rw-r--r--ui/gfx/gl/gl_surface_glx.cc11
-rw-r--r--ui/gfx/gl/gl_surface_glx.h2
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc5
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h1
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_impl.cc6
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_impl.h1
25 files changed, 232 insertions, 3 deletions
diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc
index ab7379c..39dfc04 100644
--- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc
+++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc
@@ -292,6 +292,20 @@ void WebGraphicsContext3DCommandBufferImpl::prepareTexture() {
#endif
}
+void WebGraphicsContext3DCommandBufferImpl::postSubBufferCHROMIUM(
+ int x, int y, int width, int height) {
+ // Same flow control as WebGraphicsContext3DCommandBufferImpl::prepareTexture
+ // (see above).
+ RenderViewImpl* renderview =
+ web_view_ ? RenderViewImpl::FromWebView(web_view_) : NULL;
+ if (renderview)
+ renderview->OnViewContextSwapBuffersPosted();
+ gl_->PostSubBufferCHROMIUM(x, y, width, height);
+ context_->Echo(base::Bind(
+ &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) {
cached_width_ = width;
cached_height_ = height;
diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h
index d5871ce..6b052aa 100644
--- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h
+++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h
@@ -79,6 +79,7 @@ class WebGraphicsContext3DCommandBufferImpl
virtual WebGLId getPlatformTextureId();
virtual void prepareTexture();
+ virtual void postSubBufferCHROMIUM(int x, int y, int width, int height);
virtual void activeTexture(WGC3Denum texture);
virtual void attachShader(WebGLId program, WebGLId shader);
diff --git a/gpu/GLES2/gl2ext.h b/gpu/GLES2/gl2ext.h
index 71a3df0..28b3119 100644
--- a/gpu/GLES2/gl2ext.h
+++ b/gpu/GLES2/gl2ext.h
@@ -1349,6 +1349,19 @@ typedef void (GL_APIENTRYP PFNGLENABLEFEATURECHROMIUM) (const GLchar *feature);
#endif
#endif
+/* GL_CHROMIUM_post_sub_buffer */
+#ifndef GL_CHROMIUM_post_sub_buffer
+#define GL_CHROMIUM_post_sub_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+#define glPostSubBufferCHROMIUM GLES2_GET_FUN(PostSubBufferCHROMIUM)
+#if !defined(GLES2_USE_CPP_BINDINGS)
+GL_APICALL void GL_APIENTRY glPostSubBufferCHROMIUM (GLint x, GLint y, GLint width, GLint height);
+#endif
+#else
+typedef void (GL_APIENTRYP PFNGLPOSTSUBBUFFERCHROMIUM) (GLint x, GLint y, GLint width, GLint height);
+#endif
+#endif
+
/* GL_ARB_robustness */
/* This extension is subsetted for the moment, incorporating only the
* enums necessary to describe the reasons that we might encounter for
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index e1051b4..36dad3f 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -224,6 +224,7 @@ GL_APICALL GLuint GL_APIENTRY glCreateStreamTextureCHROMIUM (GLuint textur
GL_APICALL void GL_APIENTRY glDestroyStreamTextureCHROMIUM (GLuint texture);
GL_APICALL void GL_APIENTRY glPlaceholder453CHROMIUM (void);
GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLidShader shader, GLsizeiNotNegative bufsize, GLsizei* length, char* source);
+GL_APICALL void GL_APIENTRY glPostSubBufferCHROMIUM (GLint x, GLint y, GLint width, GLint height);
"""
# This is the list of all commmands that will be generated and their Id.
@@ -433,6 +434,7 @@ _CMD_ID_TABLE = {
'GetMultipleIntegervCHROMIUM': 454,
'GetProgramInfoCHROMIUM': 455,
'GetTranslatedShaderSourceANGLE': 456,
+ 'PostSubBufferCHROMIUM': 457,
}
# This is a list of enum names and their valid values. It is used to map
@@ -1517,6 +1519,13 @@ _FUNCTION_INFO = {
'chromium': True,
},
'PixelStorei': {'type': 'Manual'},
+ 'PostSubBufferCHROMIUM': {
+ 'type': 'Custom',
+ 'impl_func': False,
+ 'unit_test': False,
+ 'extension': True,
+ 'chromium': True,
+ },
'RenderbufferStorage': {
'decoder_func': 'DoRenderbufferStorage',
'gl_test_func': 'glRenderbufferStorageEXT',
diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h
index e046662..40c7102 100644
--- a/gpu/command_buffer/client/gles2_c_lib_autogen.h
+++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h
@@ -586,6 +586,9 @@ void GLES2GetTranslatedShaderSourceANGLE(
gles2::GetGLContext()->GetTranslatedShaderSourceANGLE(
shader, bufsize, length, source);
}
+void GLES2PostSubBufferCHROMIUM(GLint x, GLint y, GLint width, GLint height) {
+ gles2::GetGLContext()->PostSubBufferCHROMIUM(x, y, width, height);
+}
#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_C_LIB_AUTOGEN_H_
diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
index 0705fb3..2a5d6d7 100644
--- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
+++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
@@ -1247,5 +1247,11 @@
c.Init(shader, bucket_id);
}
+ void PostSubBufferCHROMIUM(GLint x, GLint y, GLint width, GLint height) {
+ gles2::PostSubBufferCHROMIUM& c =
+ GetCmdSpace<gles2::PostSubBufferCHROMIUM>();
+ c.Init(x, y, width, height);
+ }
+
#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_AUTOGEN_H_
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 5fce838..6d402c5 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -2649,5 +2649,21 @@ void GLES2Implementation::DestroyStreamTextureCHROMIUM(GLuint texture) {
helper_->DestroyStreamTextureCHROMIUM(texture);
}
+void GLES2Implementation::PostSubBufferCHROMIUM(
+ GLint x, GLint y, GLint width, GLint height) {
+ GPU_CLIENT_LOG("[" << this << "] PostSubBufferCHROMIUM("
+ << x << ", " << y << ", " << width << ", " << height << ")");
+ TRACE_EVENT0("gpu", "GLES2::PostSubBufferCHROMIUM");
+
+ // Same flow control as GLES2Implementation::SwapBuffers (see comments there).
+ swap_buffers_tokens_.push(helper_->InsertToken());
+ helper_->PostSubBufferCHROMIUM(x, y, width, height);
+ helper_->CommandBufferHelper::Flush();
+ if (swap_buffers_tokens_.size() > kMaxSwapBuffers + 1) {
+ helper_->WaitForToken(swap_buffers_tokens_.front());
+ swap_buffers_tokens_.pop();
+ }
+}
+
} // namespace gles2
} // namespace gpu
diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h
index d8f6a5c..0721c79 100644
--- a/gpu/command_buffer/client/gles2_implementation_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_autogen.h
@@ -1303,5 +1303,7 @@ void GetTranslatedShaderSourceANGLE(
*length = max_size;
}
}
+void PostSubBufferCHROMIUM(GLint x, GLint y, GLint width, GLint height);
+
#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_AUTOGEN_H_
diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
index ef34bad..cb54dda 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
@@ -9165,6 +9165,52 @@ COMPILE_ASSERT(offsetof(GetTranslatedShaderSourceANGLE, shader) == 4,
COMPILE_ASSERT(offsetof(GetTranslatedShaderSourceANGLE, bucket_id) == 8,
OffsetOf_GetTranslatedShaderSourceANGLE_bucket_id_not_8);
+struct PostSubBufferCHROMIUM {
+ typedef PostSubBufferCHROMIUM ValueType;
+ static const CommandId kCmdId = kPostSubBufferCHROMIUM;
+ static const cmd::ArgFlags kArgFlags = cmd::kFixed;
+
+ static uint32 ComputeSize() {
+ return static_cast<uint32>(sizeof(ValueType)); // NOLINT
+ }
+
+ void SetHeader() {
+ header.SetCmd<ValueType>();
+ }
+
+ void Init(GLint _x, GLint _y, GLint _width, GLint _height) {
+ SetHeader();
+ x = _x;
+ y = _y;
+ width = _width;
+ height = _height;
+ }
+
+ void* Set(void* cmd, GLint _x, GLint _y, GLint _width, GLint _height) {
+ static_cast<ValueType*>(cmd)->Init(_x, _y, _width, _height);
+ return NextCmdAddress<ValueType>(cmd);
+ }
+
+ gpu::CommandHeader header;
+ int32 x;
+ int32 y;
+ int32 width;
+ int32 height;
+};
+
+COMPILE_ASSERT(sizeof(PostSubBufferCHROMIUM) == 20,
+ Sizeof_PostSubBufferCHROMIUM_is_not_20);
+COMPILE_ASSERT(offsetof(PostSubBufferCHROMIUM, header) == 0,
+ OffsetOf_PostSubBufferCHROMIUM_header_not_0);
+COMPILE_ASSERT(offsetof(PostSubBufferCHROMIUM, x) == 4,
+ OffsetOf_PostSubBufferCHROMIUM_x_not_4);
+COMPILE_ASSERT(offsetof(PostSubBufferCHROMIUM, y) == 8,
+ OffsetOf_PostSubBufferCHROMIUM_y_not_8);
+COMPILE_ASSERT(offsetof(PostSubBufferCHROMIUM, width) == 12,
+ OffsetOf_PostSubBufferCHROMIUM_width_not_12);
+COMPILE_ASSERT(offsetof(PostSubBufferCHROMIUM, height) == 16,
+ OffsetOf_PostSubBufferCHROMIUM_height_not_16);
+
#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_
diff --git a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
index a150a58..9c414a9 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
@@ -3559,5 +3559,24 @@ TEST_F(GLES2FormatTest, GetTranslatedShaderSourceANGLE) {
next_cmd, sizeof(cmd));
}
+TEST_F(GLES2FormatTest, PostSubBufferCHROMIUM) {
+ PostSubBufferCHROMIUM& cmd = *GetBufferAs<PostSubBufferCHROMIUM>();
+ void* next_cmd = cmd.Set(
+ &cmd,
+ static_cast<GLint>(11),
+ static_cast<GLint>(12),
+ static_cast<GLint>(13),
+ static_cast<GLint>(14));
+ EXPECT_EQ(static_cast<uint32>(PostSubBufferCHROMIUM::kCmdId),
+ cmd.header.command);
+ EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
+ EXPECT_EQ(static_cast<GLint>(11), cmd.x);
+ EXPECT_EQ(static_cast<GLint>(12), cmd.y);
+ EXPECT_EQ(static_cast<GLint>(13), cmd.width);
+ EXPECT_EQ(static_cast<GLint>(14), cmd.height);
+ CheckBytesWrittenMatchesExpectedSize(
+ next_cmd, sizeof(cmd));
+}
+
#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_
diff --git a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
index 0c9aa01..498c625 100644
--- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
@@ -211,6 +211,7 @@
OP(GetMultipleIntegervCHROMIUM) /* 454 */ \
OP(GetProgramInfoCHROMIUM) /* 455 */ \
OP(GetTranslatedShaderSourceANGLE) /* 456 */ \
+ OP(PostSubBufferCHROMIUM) /* 457 */ \
enum CommandId {
kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this.
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc
index 5d6fe74..64c7222 100644
--- a/gpu/command_buffer/service/feature_info.cc
+++ b/gpu/command_buffer/service/feature_info.cc
@@ -7,6 +7,7 @@
#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "ui/gfx/gl/gl_implementation.h"
+#include "ui/gfx/gl/gl_surface.h"
namespace gpu {
namespace gles2 {
@@ -357,6 +358,12 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
feature_flags_.enable_texture_half_float_linear =
enable_texture_half_float_linear;
feature_flags_.npot_ok = npot_ok;
+
+ if (ext.Desire("GL_CHROMIUM_post_sub_buffer") &&
+ gfx::GLSurface::GetCurrent() &&
+ gfx::GLSurface::GetCurrent()->SupportsPostSubBuffer()) {
+ AddExtensionString("GL_CHROMIUM_post_sub_buffer");
+ }
}
void FeatureInfo::AddExtensionString(const std::string& str) {
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index f31effa..fc12352 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -5740,6 +5740,20 @@ error::Error GLES2DecoderImpl::HandlePixelStorei(
return error::kNoError;
}
+error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM(
+ uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) {
+ TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM");
+ if (!surface_->SupportsPostSubBuffer()) {
+ SetGLError(GL_INVALID_OPERATION,
+ "glPostSubBufferCHROMIUM: command not supported by surface");
+ return error::kNoError;
+ }
+ if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height))
+ return error::kNoError;
+ else
+ return error::kLostContext;
+}
+
error::Error GLES2DecoderImpl::GetAttribLocationHelper(
GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
const std::string& name_str) {
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h
index e5b9d40..c60e869 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h
@@ -15,5 +15,6 @@
// TODO(gman): DestroyStreamTextureCHROMIUM
// TODO(gman): GetTranslatedShaderSourceANGLE
+// TODO(gman): PostSubBufferCHROMIUM
#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_3_AUTOGEN_H_
diff --git a/ui/gfx/gl/generate_bindings.py b/ui/gfx/gl/generate_bindings.py
index 2e1a1e0..4207533 100644
--- a/ui/gfx/gl/generate_bindings.py
+++ b/ui/gfx/gl/generate_bindings.py
@@ -363,6 +363,9 @@ EGL_FUNCTIONS = [
'EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target'],
['__eglMustCastToProperFunctionPointerType', ['eglGetProcAddress'],
'const char* procname'],
+['EGLBoolean', ['eglPostSubBufferNV'],
+ 'EGLDisplay dpy, EGLSurface surface, '
+ 'EGLint x, EGLint y, EGLint width, EGLint height'],
['EGLBoolean', ['eglQuerySurfacePointerANGLE'],
'EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value'],
]
@@ -396,6 +399,9 @@ WGL_FUNCTIONS = [
GLX_FUNCTIONS = [
['XVisualInfo*', ['glXChooseVisual'],
'Display* dpy, int screen, int* attribList'],
+['void', ['glXCopySubBufferMESA'],
+ 'Display* dpy, GLXDrawable drawable, '
+ 'int x, int y, int width, int height'],
['GLXContext', ['glXCreateContext'],
'Display* dpy, XVisualInfo* vis, GLXContext shareList, int direct'],
['void', ['glXBindTexImageEXT'],
diff --git a/ui/gfx/gl/gl_surface.cc b/ui/gfx/gl/gl_surface.cc
index 34d4464..78cada4 100644
--- a/ui/gfx/gl/gl_surface.cc
+++ b/ui/gfx/gl/gl_surface.cc
@@ -94,6 +94,14 @@ unsigned int GLSurface::GetBackingFrameBufferObject() {
return 0;
}
+bool GLSurface::SupportsPostSubBuffer() {
+ return false;
+}
+
+bool GLSurface::PostSubBuffer(int x, int y, int width, int height) {
+ return false;
+}
+
bool GLSurface::OnMakeCurrent(GLContext* context) {
return true;
}
diff --git a/ui/gfx/gl/gl_surface.h b/ui/gfx/gl/gl_surface.h
index 5843a9c..150182e 100644
--- a/ui/gfx/gl/gl_surface.h
+++ b/ui/gfx/gl/gl_surface.h
@@ -50,6 +50,10 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
// FBO. Otherwise returns 0.
virtual unsigned int GetBackingFrameBufferObject();
+ // Copy part of the backbuffer to the frontbuffer.
+ virtual bool SupportsPostSubBuffer();
+ virtual bool PostSubBuffer(int x, int y, int width, int height);
+
static bool InitializeOneOff();
// Called after a context is made current with this surface. Returns false
diff --git a/ui/gfx/gl/gl_surface_egl.cc b/ui/gfx/gl/gl_surface_egl.cc
index 6f6d630..8301bc4 100644
--- a/ui/gfx/gl/gl_surface_egl.cc
+++ b/ui/gfx/gl/gl_surface_egl.cc
@@ -173,7 +173,8 @@ EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() {
NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software,
gfx::PluginWindowHandle window)
: window_(window),
- surface_(NULL)
+ surface_(NULL),
+ supports_post_sub_buffer_(false)
{
software_ = software;
}
@@ -190,11 +191,18 @@ bool NativeViewGLSurfaceEGL::Initialize() {
return false;
}
+ static const EGLint egl_window_attributes_sub_buffer[] = {
+ EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE,
+ EGL_NONE
+ };
+
// Create a surface for the native window.
surface_ = eglCreateWindowSurface(GetDisplay(),
GetConfig(),
window_,
- NULL);
+ gfx::g_EGL_NV_post_sub_buffer ?
+ egl_window_attributes_sub_buffer :
+ NULL);
if (!surface_) {
LOG(ERROR) << "eglCreateWindowSurface failed with error "
@@ -203,6 +211,13 @@ bool NativeViewGLSurfaceEGL::Initialize() {
return false;
}
+ EGLint surfaceVal;
+ EGLBoolean retVal = eglQuerySurface(GetDisplay(),
+ surface_,
+ EGL_POST_SUB_BUFFER_SUPPORTED_NV,
+ &surfaceVal);
+ supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE;
+
return true;
}
@@ -247,6 +262,21 @@ EGLSurface NativeViewGLSurfaceEGL::GetHandle() {
return surface_;
}
+bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() {
+ return supports_post_sub_buffer_;
+}
+
+bool NativeViewGLSurfaceEGL::PostSubBuffer(
+ int x, int y, int width, int height) {
+ DCHECK(supports_post_sub_buffer_);
+ if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) {
+ VLOG(1) << "eglPostSubBufferNV failed with error "
+ << GetLastEGLErrorString();
+ return false;
+ }
+ return true;
+}
+
PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(bool software, const gfx::Size& size)
: size_(size),
surface_(NULL) {
diff --git a/ui/gfx/gl/gl_surface_egl.h b/ui/gfx/gl/gl_surface_egl.h
index de68fc8..352c052 100644
--- a/ui/gfx/gl/gl_surface_egl.h
+++ b/ui/gfx/gl/gl_surface_egl.h
@@ -43,7 +43,7 @@ class GL_EXPORT GLSurfaceEGL : public GLSurface {
static EGLDisplay GetSoftwareDisplay();
static EGLNativeDisplayType GetNativeDisplay();
-protected:
+ protected:
bool software_;
private:
@@ -63,10 +63,13 @@ class NativeViewGLSurfaceEGL : public GLSurfaceEGL {
virtual bool SwapBuffers();
virtual gfx::Size GetSize();
virtual EGLSurface GetHandle();
+ virtual bool SupportsPostSubBuffer();
+ virtual bool PostSubBuffer(int x, int y, int width, int height);
private:
gfx::PluginWindowHandle window_;
EGLSurface surface_;
+ bool supports_post_sub_buffer_;
DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL);
};
diff --git a/ui/gfx/gl/gl_surface_glx.cc b/ui/gfx/gl/gl_surface_glx.cc
index 2f2380f..373bc85 100644
--- a/ui/gfx/gl/gl_surface_glx.cc
+++ b/ui/gfx/gl/gl_surface_glx.cc
@@ -203,6 +203,17 @@ void* NativeViewGLSurfaceGLX::GetConfig() {
return config_;
}
+bool NativeViewGLSurfaceGLX::SupportsPostSubBuffer() {
+ return g_GLX_MESA_copy_sub_buffer;
+}
+
+bool NativeViewGLSurfaceGLX::PostSubBuffer(
+ int x, int y, int width, int height) {
+ DCHECK(SupportsPostSubBuffer());
+ glXCopySubBufferMESA(g_display, window_, x, y, width, height);
+ return true;
+}
+
PbufferGLSurfaceGLX::PbufferGLSurfaceGLX(const gfx::Size& size)
: size_(size),
config_(NULL),
diff --git a/ui/gfx/gl/gl_surface_glx.h b/ui/gfx/gl/gl_surface_glx.h
index 7784a79..f880b66 100644
--- a/ui/gfx/gl/gl_surface_glx.h
+++ b/ui/gfx/gl/gl_surface_glx.h
@@ -53,6 +53,8 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX {
virtual gfx::Size GetSize();
virtual void* GetHandle();
virtual void* GetConfig();
+ virtual bool SupportsPostSubBuffer();
+ virtual bool PostSubBuffer(int x, int y, int width, int height);
protected:
NativeViewGLSurfaceGLX();
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
index 71a8a70..4f8044b 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
+++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
@@ -758,6 +758,11 @@ void WebGraphicsContext3DInProcessCommandBufferImpl::prepareTexture() {
context_->SwapBuffers();
}
+void WebGraphicsContext3DInProcessCommandBufferImpl::postSubBufferCHROMIUM(
+ int x, int y, int width, int height) {
+ gl_->PostSubBufferCHROMIUM(x, y, width, height);
+}
+
void WebGraphicsContext3DInProcessCommandBufferImpl::reshape(
int width, int height) {
cached_width_ = width;
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
index 9a65ae9..1ba8624 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
+++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
@@ -77,6 +77,7 @@ class WebGraphicsContext3DInProcessCommandBufferImpl
virtual WebGLId getPlatformTextureId();
virtual void prepareTexture();
+ virtual void postSubBufferCHROMIUM(int x, int y, int width, int height);
virtual void activeTexture(WGC3Denum texture);
virtual void attachShader(WebGLId program, WebGLId shader);
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc
index 835bd61..a1c8fef 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc
+++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc
@@ -333,6 +333,12 @@ void WebGraphicsContext3DInProcessImpl::prepareTexture() {
}
}
+void WebGraphicsContext3DInProcessImpl::postSubBufferCHROMIUM(
+ int x, int y, int width, int height) {
+ DCHECK(gl_surface_->SupportsPostSubBuffer());
+ gl_surface_->PostSubBuffer(x, y, width, height);
+}
+
namespace {
int CreateTextureObject(GLenum target) {
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_impl.h
index ac23af4..49ae61f 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_impl.h
+++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.h
@@ -82,6 +82,7 @@ class WebGraphicsContext3DInProcessImpl : public WebGraphicsContext3D {
virtual WebGLId getPlatformTextureId();
virtual void prepareTexture();
+ virtual void postSubBufferCHROMIUM(int x, int y, int width, int height);
virtual void synthesizeGLError(WGC3Denum error);
virtual void* mapBufferSubDataCHROMIUM(WGC3Denum target, WGC3Dintptr offset,