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

Unified Diff: src/gpu/gl/GrGpuGL.cpp

Issue 17027003: Add flag bits for partial GrContext reset (Closed)
Patch Set: add flags for partial resetContext Created 7 years, 6 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
« include/gpu/GrContext.h ('K') | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGpuGL.cpp
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index a2ff1fd57618af1709d989c854be164beefd3701..0c3045808dc99778dd0d382f5969a8125aad343f 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -284,88 +284,111 @@ bool GrGpuGL::fullReadPixelsIsFasterThanPartial() const {
return SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL);
}
-void GrGpuGL::onResetContext() {
+void GrGpuGL::onResetContext(int resetBits) {
// we don't use the zb at all
- GL_CALL(Disable(GR_GL_DEPTH_TEST));
- GL_CALL(DepthMask(GR_GL_FALSE));
-
- fHWDrawFace = GrDrawState::kInvalid_DrawFace;
- fHWDitherEnabled = kUnknown_TriState;
-
- if (kDesktop_GrGLBinding == this->glBinding()) {
- // Desktop-only state that we never change
- if (!this->glCaps().isCoreProfile()) {
- GL_CALL(Disable(GR_GL_POINT_SMOOTH));
- GL_CALL(Disable(GR_GL_LINE_SMOOTH));
- GL_CALL(Disable(GR_GL_POLYGON_SMOOTH));
- GL_CALL(Disable(GR_GL_POLYGON_STIPPLE));
- GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP));
- GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP));
- }
- // The windows NVIDIA driver has GL_ARB_imaging in the extension string when using a core
- // profile. This seems like a bug since the core spec removes any mention of GL_ARB_imaging.
- if (this->glCaps().imagingSupport() && !this->glCaps().isCoreProfile()) {
- GL_CALL(Disable(GR_GL_COLOR_TABLE));
+ if (resetBits & GrContext::kGrState_Misc) {
+ GL_CALL(Disable(GR_GL_DEPTH_TEST));
+ GL_CALL(DepthMask(GR_GL_FALSE));
+
+ fHWDrawFace = GrDrawState::kInvalid_DrawFace;
+ fHWDitherEnabled = kUnknown_TriState;
+
+ if (kDesktop_GrGLBinding == this->glBinding()) {
+ // Desktop-only state that we never change
+ if (!this->glCaps().isCoreProfile()) {
+ GL_CALL(Disable(GR_GL_POINT_SMOOTH));
+ GL_CALL(Disable(GR_GL_LINE_SMOOTH));
+ GL_CALL(Disable(GR_GL_POLYGON_SMOOTH));
+ GL_CALL(Disable(GR_GL_POLYGON_STIPPLE));
+ GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP));
+ GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP));
+ }
+ // The windows NVIDIA driver has GL_ARB_imaging in the extension string when using a core
+ // profile. This seems like a bug since the core spec removes any mention of GL_ARB_imaging.
+ if (this->glCaps().imagingSupport() && !this->glCaps().isCoreProfile()) {
+ GL_CALL(Disable(GR_GL_COLOR_TABLE));
+ }
+ GL_CALL(Disable(GR_GL_POLYGON_OFFSET_FILL));
+ // Since ES doesn't support glPointSize at all we always use the VS to
+ // set the point size
+ GL_CALL(Enable(GR_GL_VERTEX_PROGRAM_POINT_SIZE));
+
+ // We should set glPolygonMode(FRONT_AND_BACK,FILL) here, too. It isn't
+ // currently part of our gl interface. There are probably others as
+ // well.
}
- GL_CALL(Disable(GR_GL_POLYGON_OFFSET_FILL));
- // Since ES doesn't support glPointSize at all we always use the VS to
- // set the point size
- GL_CALL(Enable(GR_GL_VERTEX_PROGRAM_POINT_SIZE));
-
- // We should set glPolygonMode(FRONT_AND_BACK,FILL) here, too. It isn't
- // currently part of our gl interface. There are probably others as
- // well.
+ fHWWriteToColor = kUnknown_TriState;
+ // we only ever use lines in hairline mode
+ GL_CALL(LineWidth(1));
}
- fHWAAState.invalidate();
- fHWWriteToColor = kUnknown_TriState;
- // we only ever use lines in hairline mode
- GL_CALL(LineWidth(1));
+ if (resetBits & GrContext::kGrState_AA)
+ fHWAAState.invalidate();
// invalid
- fHWActiveTextureUnitIdx = -1;
-
- fHWBlendState.invalidate();
-
- for (int s = 0; s < fHWBoundTextures.count(); ++s) {
- fHWBoundTextures[s] = NULL;
+ if (resetBits & GrContext::kGrState_Texture) {
+ fHWActiveTextureUnitIdx = -1;
+ for (int s = 0; s < fHWBoundTextures.count(); ++s) {
+ fHWBoundTextures[s] = NULL;
+ }
}
- fHWScissorSettings.invalidate();
+ if (resetBits & GrContext::kGrState_Blend)
+ fHWBlendState.invalidate();
- fHWViewport.invalidate();
+ if (resetBits & GrContext::kGrState_View) {
+ fHWScissorSettings.invalidate();
+ fHWViewport.invalidate();
+ }
- fHWStencilSettings.invalidate();
- fHWStencilTestEnabled = kUnknown_TriState;
+ if (resetBits & GrContext::kGrState_Stencil) {
+ fHWStencilSettings.invalidate();
+ fHWStencilTestEnabled = kUnknown_TriState;
+ }
- fHWGeometryState.invalidate();
+ // Vertex
+ if (resetBits & GrContext::kGrState_Vertex)
+ fHWGeometryState.invalidate();
- fHWBoundRenderTarget = NULL;
+ if (resetBits & GrContext::kGrState_RenderTarget)
+ fHWBoundRenderTarget = NULL;
- fHWPathStencilMatrixState.invalidate();
- if (this->caps()->pathStencilingSupport()) {
- // we don't use the model view matrix.
- GL_CALL(MatrixMode(GR_GL_MODELVIEW));
- GL_CALL(LoadIdentity());
+ if (resetBits & GrContext::kGrState_PathStencil) {
+ fHWPathStencilMatrixState.invalidate();
+ if (this->caps()->pathStencilingSupport()) {
+ // we don't use the model view matrix.
+ GL_CALL(MatrixMode(GR_GL_MODELVIEW));
+ GL_CALL(LoadIdentity());
+ }
}
// we assume these values
- if (this->glCaps().unpackRowLengthSupport()) {
- GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
- }
- if (this->glCaps().packRowLengthSupport()) {
- GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0));
- }
- if (this->glCaps().unpackFlipYSupport()) {
- GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE));
+ if (resetBits & GrContext::kGrState_PixelStore) {
+ if (this->glCaps().unpackRowLengthSupport()) {
+ GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
+ }
+ if (this->glCaps().packRowLengthSupport()) {
+ GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0));
+ }
+ if (this->glCaps().unpackFlipYSupport()) {
+ GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE));
+ }
+ if (this->glCaps().packFlipYSupport()) {
+ GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, GR_GL_FALSE));
+ }
}
- if (this->glCaps().packFlipYSupport()) {
- GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, GR_GL_FALSE));
+
+ if (resetBits & GrContext::kGrState_Program) {
+ fHWProgramID = 0;
+ fSharedGLProgramState.invalidate();
}
+}
- fHWProgramID = 0;
- fSharedGLProgramState.invalidate();
+void GrGpuGL::resetTextureBinding() {
+ for (int s = 0; s < fHWBoundTextures.count(); ++s) {
+ fHWBoundTextures[s] = NULL;
+ }
}
namespace {
« include/gpu/GrContext.h ('K') | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698