Index: gpu/command_buffer/service/context_state.h |
diff --git a/gpu/command_buffer/service/context_state.h b/gpu/command_buffer/service/context_state.h |
index 83818e9b0511a4cbed1666a0d80ba1534e551e65..e436e74e280a4a65636beefc1989feadc4d67ee4 100644 |
--- a/gpu/command_buffer/service/context_state.h |
+++ b/gpu/command_buffer/service/context_state.h |
@@ -101,6 +101,10 @@ struct GPU_EXPORT ContextState { |
void Initialize(); |
+ 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; |
@@ -126,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" |
@@ -162,6 +204,7 @@ struct GPU_EXPORT ContextState { |
QueryMap current_queries; |
bool pack_reverse_row_order; |
+ bool ignore_cached_state; |
mutable bool fbo_binding_for_scissor_workaround_dirty_; |
FeatureInfo* feature_info_; |