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

Unified Diff: ui/gl/gl_gl_api_implementation.cc

Issue 104833007: Restore only modified texture state during virtual context switches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More cleanup Created 7 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
« no previous file with comments | « ui/gl/gl_gl_api_implementation.h ('k') | ui/gl/gl_state_restorer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_gl_api_implementation.cc
diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc
index eade3cedaf5e6df54041372b964335aa7937edca..01723b3d9c98565fb3a77a2767d585c89acfed91 100644
--- a/ui/gl/gl_gl_api_implementation.cc
+++ b/ui/gl/gl_gl_api_implementation.cc
@@ -254,7 +254,8 @@ TraceGLApi::~TraceGLApi() {
VirtualGLApi::VirtualGLApi()
: real_context_(NULL),
- current_context_(NULL) {
+ current_context_(NULL),
+ current_active_texture_unit_(GL_TEXTURE0) {
}
VirtualGLApi::~VirtualGLApi() {
@@ -306,15 +307,15 @@ bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) {
DCHECK_EQ(glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR));
current_context_ = virtual_context;
- // Set all state that is different from the real state
- // NOTE: !!! This is a temporary implementation that just restores all
- // state to let us test that it works.
- // TODO: ASAP, change this to something that only restores the state
- // needed for individual GL calls.
+ // Set all state that is different from the real state.
GLApi* temp = GetCurrentGLApi();
SetGLToRealGLApi();
- if (virtual_context->GetGLStateRestorer()->IsInitialized())
- virtual_context->GetGLStateRestorer()->RestoreState();
+ if (virtual_context->GetGLStateRestorer()->IsInitialized()) {
+ virtual_context->GetGLStateRestorer()->RestoreState(
+ &dirty_texture_state_);
+ // Clear our dirty state after restoring state.
+ ClearDirtyTextureState();
+ }
SetGLApi(temp);
}
SetGLApi(this);
@@ -328,8 +329,10 @@ bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) {
}
void VirtualGLApi::OnReleaseVirtuallyCurrent(GLContext* virtual_context) {
- if (current_context_ == virtual_context)
+ if (current_context_ == virtual_context) {
current_context_ = NULL;
+ ClearDirtyTextureState();
+ }
}
const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
@@ -341,4 +344,20 @@ const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
}
}
+void VirtualGLApi::glBindTextureFn(GLenum target, GLuint texture_id) {
+ dirty_texture_state_.AddBinding(current_active_texture_unit_, target);
+ driver_->fn.glBindTextureFn(target, texture_id);
+}
+
+void VirtualGLApi::glActiveTextureFn(GLenum texture_unit) {
+ current_active_texture_unit_ = texture_unit;
+ dirty_texture_state_.UpdateMaxTextureUnit(texture_unit);
+ driver_->fn.glActiveTextureFn(texture_unit);
+}
+
+void VirtualGLApi::ClearDirtyTextureState() {
+ current_active_texture_unit_ = GL_TEXTURE0;
+ dirty_texture_state_.Clear();
+}
+
} // namespace gfx
« no previous file with comments | « ui/gl/gl_gl_api_implementation.h ('k') | ui/gl/gl_state_restorer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698