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

Unified Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 2558933003: Cache GL's viewport on the GPU command buffer client side. (Closed)
Patch Set: fix Created 4 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/client/gles2_implementation.cc
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 0f12cd4c93d2c81f807d469a9a670f165c6b5f50..82d2e9bd6e0a4694cff6a61d4d27b7b5ec9986c0 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -804,6 +804,15 @@ bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) {
case GL_MAX_VERTEX_UNIFORM_VECTORS:
*params = capabilities_.max_vertex_uniform_vectors;
return true;
+ case GL_MAX_VIEWPORT_DIMS:
+ if (capabilities_.max_viewport_width > 0 &&
+ capabilities_.max_viewport_height > 0) {
+ params[0] = capabilities_.max_viewport_width;
+ params[1] = capabilities_.max_viewport_height;
+ return true;
+ }
+ // If they are not cached on the client side yet, query the service side.
+ return false;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
*params = capabilities_.num_compressed_texture_formats;
return true;
@@ -847,6 +856,23 @@ bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) {
*params = static_cast<GLint>(query_tracker_->CheckAndResetDisjoint());
return true;
+ case GL_VIEWPORT:
+ if (state_.viewport_width > 0 &&
+ state_.viewport_height > 0 &&
+ capabilities_.max_viewport_width > 0 &&
+ capabilities_.max_viewport_height > 0) {
+ params[0] = state_.viewport_x;
+ params[1] = state_.viewport_y;
+ params[2] = std::min(state_.viewport_width,
+ capabilities_.max_viewport_width);
+ params[3] = std::min(state_.viewport_height,
+ capabilities_.max_viewport_height);
+ return true;
+ }
+ // If they haven't been cached on the client side, go to service side
+ // to query the underlying driver.
+ return false;
+
// Non-cached parameters.
case GL_ALIASED_LINE_WIDTH_RANGE:
case GL_ALIASED_POINT_SIZE_RANGE:
@@ -879,7 +905,6 @@ bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) {
case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
case GL_IMPLEMENTATION_COLOR_READ_TYPE:
case GL_LINE_WIDTH:
- case GL_MAX_VIEWPORT_DIMS:
case GL_PACK_ALIGNMENT:
case GL_POLYGON_OFFSET_FACTOR:
case GL_POLYGON_OFFSET_FILL:
@@ -914,7 +939,6 @@ bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) {
case GL_STENCIL_WRITEMASK:
case GL_SUBPIXEL_BITS:
case GL_UNPACK_ALIGNMENT:
- case GL_VIEWPORT:
return false;
default:
break;
@@ -7030,6 +7054,22 @@ void GLES2Implementation::InvalidateCachedExtensions() {
cached_extensions_.clear();
}
+void GLES2Implementation::Viewport(GLint x,
+ GLint y,
+ GLsizei width,
+ GLsizei height) {
+ GPU_CLIENT_SINGLE_THREAD_CHECK();
+ GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glViewport(" << x << ", " << y
+ << ", " << width << ", " << height << ")");
+ if (width < 0 || height < 0) {
+ SetGLError(GL_INVALID_VALUE, "glViewport", "negative width/height");
+ return;
+ }
+ state_.SetViewport(x, y, width, height);
+ helper_->Viewport(x, y, width, height);
+ CheckGLError();
+}
+
// Include the auto-generated part of this file. We split this because it means
// we can easily edit the non-auto generated parts right here in this file
// instead of having to edit some template or the code generator.
« no previous file with comments | « gpu/command_buffer/client/client_context_state.cc ('k') | gpu/command_buffer/client/gles2_implementation_impl_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698