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

Unified Diff: android_webview/browser/scoped_app_gl_state_restore.cc

Issue 273703008: aw: Refactor hardware init (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more refactoring Created 6 years, 7 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: android_webview/browser/scoped_app_gl_state_restore.cc
diff --git a/android_webview/browser/scoped_app_gl_state_restore.cc b/android_webview/browser/scoped_app_gl_state_restore.cc
index f7987dab8211f86772e210548b364a8d098c3282..71a5711a26f7967fdbef4830738e810a673b98c3 100644
--- a/android_webview/browser/scoped_app_gl_state_restore.cc
+++ b/android_webview/browser/scoped_app_gl_state_restore.cc
@@ -8,6 +8,7 @@
#include "base/debug/trace_event.h"
#include "base/lazy_instance.h"
+#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface_stub.h"
@@ -56,7 +57,94 @@ bool g_supports_oes_vertex_array_object = false;
} // namespace
-ScopedAppGLStateRestore::ScopedAppGLStateRestore(CallMode mode) : mode_(mode) {
+namespace internal {
+
+class ScopedAppGLStateRestoreImpl {
+ public:
+ ScopedAppGLStateRestoreImpl(ScopedAppGLStateRestore::CallMode mode);
+ ~ScopedAppGLStateRestoreImpl();
+
+ bool stencil_enabled() const { return stencil_test_; }
+ GLint framebuffer_binding_ext() const { return framebuffer_binding_ext_; }
+
+ private:
+ const ScopedAppGLStateRestore::CallMode mode_;
+
+ GLint pack_alignment_;
+ GLint unpack_alignment_;
+
+ struct {
+ GLint enabled;
+ GLint size;
+ GLint type;
+ GLint normalized;
+ GLint stride;
+ GLvoid* pointer;
+ GLint vertex_attrib_array_buffer_binding;
+ GLfloat current_vertex_attrib[4];
+ } vertex_attrib_[3];
+
+ GLint vertex_array_buffer_binding_;
+ GLint index_array_buffer_binding_;
+
+ GLboolean depth_test_;
+ GLboolean cull_face_;
+ GLint cull_face_mode_;
+ GLboolean color_mask_[4];
+ GLfloat color_clear_[4];
+ GLfloat depth_clear_;
+ GLint current_program_;
+ GLint depth_func_;
+ GLboolean depth_mask_;
+ GLfloat depth_rage_[2];
+ GLint front_face_;
+ GLint hint_generate_mipmap_;
+ GLfloat line_width_;
+ GLfloat polygon_offset_factor_;
+ GLfloat polygon_offset_units_;
+ GLfloat sample_coverage_value_;
+ GLboolean sample_coverage_invert_;
+
+ GLboolean enable_dither_;
+ GLboolean enable_polygon_offset_fill_;
+ GLboolean enable_sample_alpha_to_coverage_;
+ GLboolean enable_sample_coverage_;
+
+ // Not saved/restored in MODE_DRAW.
+ GLboolean blend_enabled_;
+ GLint blend_src_rgb_;
+ GLint blend_src_alpha_;
+ GLint blend_dest_rgb_;
+ GLint blend_dest_alpha_;
+ GLint active_texture_;
+ GLint viewport_[4];
+ GLboolean scissor_test_;
+ GLint scissor_box_[4];
+
+ GLboolean stencil_test_;
+ GLint stencil_func_;
+ GLint stencil_mask_;
+ GLint stencil_ref_;
+
+ GLint framebuffer_binding_ext_;
+
+ struct TextureBindings {
+ GLint texture_2d;
+ GLint texture_cube_map;
+ GLint texture_external_oes;
+ // TODO(boliu): TEXTURE_RECTANGLE_ARB
+ };
+
+ std::vector<TextureBindings> texture_bindings_;
+
+ GLint vertex_array_bindings_oes_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedAppGLStateRestoreImpl);
+};
+
+ScopedAppGLStateRestoreImpl::ScopedAppGLStateRestoreImpl(
+ ScopedAppGLStateRestore::CallMode mode)
+ : mode_(mode) {
TRACE_EVENT0("android_webview", "AppGLStateSave");
MakeAppContextCurrent();
@@ -76,11 +164,11 @@ ScopedAppGLStateRestore::ScopedAppGLStateRestore(CallMode mode) : mode_(mode) {
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &index_array_buffer_binding_);
switch(mode_) {
- case MODE_DRAW:
+ case ScopedAppGLStateRestore::MODE_DRAW:
DCHECK_EQ(0, vertex_array_buffer_binding_);
DCHECK_EQ(0, index_array_buffer_binding_);
break;
- case MODE_RESOURCE_MANAGEMENT:
+ case ScopedAppGLStateRestore::MODE_RESOURCE_MANAGEMENT:
glGetBooleanv(GL_BLEND, &blend_enabled_);
glGetIntegerv(GL_BLEND_SRC_RGB, &blend_src_rgb_);
glGetIntegerv(GL_BLEND_SRC_ALPHA, &blend_src_alpha_);
@@ -165,7 +253,7 @@ ScopedAppGLStateRestore::ScopedAppGLStateRestore(CallMode mode) : mode_(mode) {
}
}
-ScopedAppGLStateRestore::~ScopedAppGLStateRestore() {
+ScopedAppGLStateRestoreImpl::~ScopedAppGLStateRestoreImpl() {
TRACE_EVENT0("android_webview", "AppGLStateRestore");
MakeAppContextCurrent();
@@ -240,10 +328,10 @@ ScopedAppGLStateRestore::~ScopedAppGLStateRestore() {
GLEnableDisable(GL_SAMPLE_COVERAGE, enable_sample_coverage_);
switch(mode_) {
- case MODE_DRAW:
+ case ScopedAppGLStateRestore::MODE_DRAW:
// No-op.
break;
- case MODE_RESOURCE_MANAGEMENT:
+ case ScopedAppGLStateRestore::MODE_RESOURCE_MANAGEMENT:
GLEnableDisable(GL_BLEND, blend_enabled_);
glBlendFuncSeparate(
blend_src_rgb_, blend_dest_rgb_, blend_src_alpha_, blend_dest_alpha_);
@@ -261,4 +349,19 @@ ScopedAppGLStateRestore::~ScopedAppGLStateRestore() {
glStencilFunc(stencil_func_, stencil_mask_, stencil_ref_);
}
+} // namespace internal
+
+ScopedAppGLStateRestore::ScopedAppGLStateRestore(CallMode mode)
+ : impl_(new internal::ScopedAppGLStateRestoreImpl(mode)) {
+}
+
+ScopedAppGLStateRestore::~ScopedAppGLStateRestore() {}
+
+bool ScopedAppGLStateRestore::stencil_enabled() const {
+ return impl_->stencil_enabled();
+}
+int ScopedAppGLStateRestore::framebuffer_binding_ext() const {
+ return impl_->framebuffer_binding_ext();
+}
+
} // namespace android_webview

Powered by Google App Engine
This is Rietveld 408576698