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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 9968113: Addition of GL_CHROMIUM_copy_texture extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Adding extension implementation files. Created 8 years, 9 months 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/service/gles2_cmd_decoder.cc
===================================================================
--- gpu/command_buffer/service/gles2_cmd_decoder.cc (revision 128216)
+++ gpu/command_buffer/service/gles2_cmd_decoder.cc (working copy)
@@ -33,6 +33,7 @@
#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/framebuffer_manager.h"
#include "gpu/command_buffer/service/gl_utils.h"
+#include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
#include "gpu/command_buffer/service/gles2_cmd_validation.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/command_buffer/service/program_manager.h"
@@ -821,6 +822,12 @@
GLuint io_surface_id,
GLuint plane);
+ void DoCopyTextureCHROMIUM(
+ GLenum target,
+ GLuint source_id,
+ GLuint target_id,
+ GLint level);
+
// Wrapper for TexStorage2DEXT.
void DoTexStorage2DEXT(
GLenum target,
@@ -1227,6 +1234,9 @@
void DoVertexAttrib3fv(GLuint index, const GLfloat *v);
void DoVertexAttrib4fv(GLuint index, const GLfloat *v);
+ // Wrapper for glViewport
+ void DoViewport(GLint x, GLint y, GLsizei width, GLsizei height);
+
// Wrapper for glUseProgram
void DoUseProgram(GLuint program);
@@ -1427,6 +1437,12 @@
// unpack alignment as last set by glPixelStorei
GLint unpack_alignment_;
+ // unpack flip y as last set by glPixelStorei
+ bool unpack_flip_y_;
+
+ // unpack premultiply alpha as last set by glPixelStorei
+ bool unpack_premultiply_alpha_;
+
// The currently bound array buffer. If this is 0 it is illegal to call
// glVertexAttribPointer.
BufferManager::BufferInfo::Ref bound_array_buffer_;
@@ -1479,6 +1495,7 @@
GLuint mask_stencil_back_;
GLclampf clear_depth_;
GLboolean mask_depth_;
+ bool enable_cull_face_;
bool enable_scissor_test_;
bool enable_depth_test_;
bool enable_stencil_test_;
@@ -1582,6 +1599,12 @@
typedef std::vector<GLES2DecoderImpl*> ChildList;
ChildList children_;
+ scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_;
+
+ // Cached values of the currently assigned viewport dimensions.
+ GLint viewport_x_, viewport_y_;
+ GLsizei viewport_width_, viewport_height_;
+
DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl);
};
@@ -1924,6 +1947,8 @@
error_bits_(0),
pack_alignment_(4),
unpack_alignment_(4),
+ unpack_flip_y_(false),
+ unpack_premultiply_alpha_(false),
attrib_0_buffer_id_(0),
attrib_0_buffer_matches_value_(true),
attrib_0_size_(0),
@@ -1943,6 +1968,7 @@
mask_stencil_back_(-1),
clear_depth_(1.0f),
mask_depth_(true),
+ enable_cull_face_(false),
enable_scissor_test_(false),
enable_depth_test_(false),
enable_stencil_test_(false),
@@ -1971,7 +1997,11 @@
needs_glsl_built_in_function_emulation_(false),
force_webgl_glsl_validation_(false),
derivatives_explicitly_enabled_(false),
- compile_shader_always_succeeds_(false) {
+ compile_shader_always_succeeds_(false),
+ viewport_x_(0),
+ viewport_y_(0),
+ viewport_width_(0),
+ viewport_height_(0) {
DCHECK(group);
attrib_0_value_.v[0] = 0.0f;
@@ -2046,8 +2076,12 @@
Destroy();
return false;
}
+ CHECK_GL_ERROR();
+ copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
+ copy_texture_CHROMIUM_->Initialize();
CHECK_GL_ERROR();
+
disallowed_features_ = disallowed_features;
vertex_attrib_manager_.reset(new VertexAttribManager());
@@ -2270,6 +2304,13 @@
return false;
}
+ GLint viewport_params[4];
+ glGetIntegerv(GL_VIEWPORT, viewport_params);
+ viewport_x_ = viewport_params[0];
+ viewport_y_ = viewport_params[1];
+ viewport_width_ = viewport_params[2];
+ viewport_height_ = viewport_params[3];
+
return true;
}
@@ -3295,6 +3336,8 @@
glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0);
glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0);
EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil);
+ EnableDisable(GL_CULL_FACE, enable_cull_face_);
+ EnableDisable(GL_SCISSOR_TEST, enable_scissor_test_);
state_dirty_ = false;
}
}
@@ -4097,6 +4140,9 @@
bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) {
switch (cap) {
+ case GL_CULL_FACE:
+ enable_cull_face_ = enabled;
+ return true;
case GL_SCISSOR_TEST:
enable_scissor_test_ = enabled;
return true;
@@ -6020,6 +6066,15 @@
return error::kNoError;
}
+void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width,
+ GLsizei height) {
+ viewport_x_ = x;
greggman 2012/04/04 20:12:24 The viewport will be clipped to the max size and I
Jeff Timanus 2012/04/04 22:34:14 The arguments are validated against 0 in the auto-
+ viewport_y_ = y;
+ viewport_width_ = width;
+ viewport_height_ = height;
+ glViewport(x, y, width, height);
+}
+
error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE(
uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) {
if (!feature_info_->feature_flags().angle_instanced_arrays) {
@@ -6232,6 +6287,12 @@
case GL_UNPACK_ALIGNMENT:
unpack_alignment_ = param;
break;
+ case GL_UNPACK_FLIP_Y_CHROMIUM:
+ unpack_flip_y_ = (param != 0);
+ break;
+ case GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM:
+ unpack_premultiply_alpha_ = (param != 0);
+ break;
default:
// Validation should have prevented us from getting here.
NOTREACHED();
@@ -8311,6 +8372,61 @@
}
}
+void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
+ GLenum target, GLuint source_id, GLuint dest_id, GLint level) {
+ TextureManager::TextureInfo* dest_info = GetTextureInfo(dest_id);
+ TextureManager::TextureInfo* source_info = GetTextureInfo(source_id);
+
+ if (!source_info || !dest_info) {
+ SetGLError(GL_INVALID_VALUE, "");
greggman 2012/04/04 20:12:24 Do you mind filling out the "" here and below?
Jeff Timanus 2012/04/04 22:34:14 Done.
+ return;
+ }
+
+ if (GL_TEXTURE_2D != target) {
+ SetGLError(GL_INVALID_VALUE, "");
+ return;
+ }
+
+ int source_width, source_height, dest_width, dest_height;
+ if (!source_info->GetLevelSize(GL_TEXTURE_2D, level, &source_width,
+ &source_height)) {
+ SetGLError(GL_INVALID_VALUE, "");
+ return;
+ }
+
+ if (!dest_info->GetLevelSize(GL_TEXTURE_2D, level, &dest_width,
+ &dest_height)) {
+ SetGLError(GL_INVALID_VALUE, "");
+ return;
+ }
+
+ if (dest_width != source_width && dest_height != source_height) {
greggman 2012/04/04 20:12:24 Should it be ok to copy to a new size? CopyTexImag
Jeff Timanus 2012/04/04 22:34:14 It should be ok to copy to a new size. I'm lookin
+ SetGLError(GL_INVALID_VALUE, "");
+ return;
+ }
+
+ state_dirty_ = true;
+ glViewport(0, 0, dest_width, dest_height);
+ copy_texture_CHROMIUM_->DoCopyTexture(target, source_info->service_id(),
+ dest_info->service_id(), level,
+ unpack_flip_y_,
+ unpack_premultiply_alpha_);
+ glViewport(viewport_x_, viewport_y_, viewport_width_, viewport_height_);
+
+ // Restore all of the state touched by the extension.
+ if (current_program_)
+ glUseProgram(current_program_->service_id());
+
+ RestoreCurrentFramebufferBindings();
+
+ if (!bound_array_buffer_)
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ else
+ glBindBuffer(GL_ARRAY_BUFFER, bound_array_buffer_->service_id());
+
+ ApplyDirtyState();
greggman 2012/04/04 20:12:24 I get the impression more things need to be restor
Jeff Timanus 2012/04/04 22:34:14 Ongoing. I'll add the extra state tracking to dou
+}
+
static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) {
switch (internalformat) {
case GL_RGB565:

Powered by Google App Engine
This is Rietveld 408576698