summaryrefslogtreecommitdiffstats
path: root/chromium/gpu/command_buffer/service/context_state.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/gpu/command_buffer/service/context_state.h')
-rw-r--r--chromium/gpu/command_buffer/service/context_state.h72
1 files changed, 63 insertions, 9 deletions
diff --git a/chromium/gpu/command_buffer/service/context_state.h b/chromium/gpu/command_buffer/service/context_state.h
index 8d5edcaea61..e436e74e280 100644
--- a/chromium/gpu/command_buffer/service/context_state.h
+++ b/chromium/gpu/command_buffer/service/context_state.h
@@ -22,6 +22,7 @@ namespace gles2 {
class Buffer;
class ErrorState;
+class ErrorStateClient;
class FeatureInfo;
class Framebuffer;
class Program;
@@ -93,23 +94,34 @@ struct Vec4 {
};
struct GPU_EXPORT ContextState {
- ContextState(FeatureInfo* feature_info, Logger* logger);
+ ContextState(FeatureInfo* feature_info,
+ ErrorStateClient* error_state_client,
+ Logger* logger);
~ContextState();
void Initialize();
- void RestoreState() const;
- void InitCapabilities() const;
- void InitState() const;
+ void SetIgnoreCachedStateForTest(bool ignore) {
+ ignore_cached_state = ignore;
+ }
+
+ void RestoreState(const ContextState* prev_state) const;
+ void InitCapabilities(const ContextState* prev_state) const;
+ void InitState(const ContextState* prev_state) const;
void RestoreActiveTexture() const;
- void RestoreAllTextureUnitBindings() const;
- void RestoreAttribute(GLuint index) const;
+ void RestoreAllTextureUnitBindings(const ContextState* prev_state) const;
+ void RestoreActiveTextureUnitBinding(unsigned int target) const;
+ void RestoreVertexAttribValues() const;
+ void RestoreVertexAttribArrays(
+ const scoped_refptr<VertexAttribManager> attrib_manager) const;
+ void RestoreVertexAttribs() const;
void RestoreBufferBindings() const;
- void RestoreGlobalState() const;
+ void RestoreGlobalState(const ContextState* prev_state) const;
void RestoreProgramBindings() const;
void RestoreRenderbufferBindings() const;
- void RestoreTextureUnitBindings(GLuint unit) const;
+ void RestoreTextureUnitBindings(
+ GLuint unit, const ContextState* prev_state) const;
// Helper for getting cached state.
bool GetStateAsGLint(
@@ -118,6 +130,44 @@ struct GPU_EXPORT ContextState {
GLenum pname, GLfloat* params, GLsizei* num_written) const;
bool GetEnabled(GLenum cap) const;
+ inline void SetDeviceColorMask(GLboolean red,
+ GLboolean green,
+ GLboolean blue,
+ GLboolean alpha) {
+ if (cached_color_mask_red == red && cached_color_mask_green == green &&
+ cached_color_mask_blue == blue && cached_color_mask_alpha == alpha &&
+ !ignore_cached_state)
+ return;
+ cached_color_mask_red = red;
+ cached_color_mask_green = green;
+ cached_color_mask_blue = blue;
+ cached_color_mask_alpha = alpha;
+ glColorMask(red, green, blue, alpha);
+ }
+
+ inline void SetDeviceDepthMask(GLboolean mask) {
+ if (cached_depth_mask == mask && !ignore_cached_state)
+ return;
+ cached_depth_mask = mask;
+ glDepthMask(mask);
+ }
+
+ inline void SetDeviceStencilMaskSeparate(GLenum op, GLuint mask) {
+ if (op == GL_FRONT) {
+ if (cached_stencil_front_writemask == mask && !ignore_cached_state)
+ return;
+ cached_stencil_front_writemask = mask;
+ } else if (op == GL_BACK) {
+ if (cached_stencil_back_writemask == mask && !ignore_cached_state)
+ return;
+ cached_stencil_back_writemask = mask;
+ } else {
+ NOTREACHED();
+ return;
+ }
+ glStencilMaskSeparate(op, mask);
+ }
+
ErrorState* GetErrorState();
#include "gpu/command_buffer/service/context_state_autogen.h"
@@ -141,6 +191,7 @@ struct GPU_EXPORT ContextState {
// Class that manages vertex attribs.
scoped_refptr<VertexAttribManager> vertex_attrib_manager;
+ scoped_refptr<VertexAttribManager> default_vertex_attrib_manager;
// The program in use by glUseProgram
scoped_refptr<Program> current_program;
@@ -148,9 +199,12 @@ struct GPU_EXPORT ContextState {
// The currently bound renderbuffer
scoped_refptr<Renderbuffer> bound_renderbuffer;
- scoped_refptr<QueryManager::Query> current_query;
+ // A map of of target -> Query for current queries
+ typedef std::map<GLuint, scoped_refptr<QueryManager::Query> > QueryMap;
+ QueryMap current_queries;
bool pack_reverse_row_order;
+ bool ignore_cached_state;
mutable bool fbo_binding_for_scissor_workaround_dirty_;
FeatureInfo* feature_info_;