| Index: gpu/command_buffer/service/gles2_cmd_clear_framebuffer.cc
|
| diff --git a/gpu/command_buffer/service/gles2_cmd_clear_framebuffer.cc b/gpu/command_buffer/service/gles2_cmd_clear_framebuffer.cc
|
| index 6a21c49fd9a05c5f9b8afb82cb66e26a3efa1024..d42dd195820396f04de09b9a9db43d3ef6f87fc0 100644
|
| --- a/gpu/command_buffer/service/gles2_cmd_clear_framebuffer.cc
|
| +++ b/gpu/command_buffer/service/gles2_cmd_clear_framebuffer.cc
|
| @@ -56,9 +56,10 @@ void CompileShader(GLuint shader, const char* shader_source) {
|
| namespace gpu {
|
|
|
| ClearFramebufferResourceManager::ClearFramebufferResourceManager(
|
| - const gles2::GLES2Decoder* decoder)
|
| - : initialized_(false), program_(0u), buffer_id_(0u) {
|
| - Initialize(decoder);
|
| + const gles2::GLES2Decoder* decoder,
|
| + const gles2::FeatureInfo::FeatureFlags& feature_flags)
|
| + : initialized_(false), program_(0u), vao_(0), buffer_id_(0u) {
|
| + Initialize(decoder, feature_flags);
|
| }
|
|
|
| ClearFramebufferResourceManager::~ClearFramebufferResourceManager() {
|
| @@ -67,12 +68,13 @@ ClearFramebufferResourceManager::~ClearFramebufferResourceManager() {
|
| }
|
|
|
| void ClearFramebufferResourceManager::Initialize(
|
| - const gles2::GLES2Decoder* decoder) {
|
| + const gles2::GLES2Decoder* decoder,
|
| + const gles2::FeatureInfo::FeatureFlags& feature_flags) {
|
| static_assert(
|
| kVertexPositionAttrib == 0u,
|
| "kVertexPositionAttrib must be 0");
|
| - DCHECK(!buffer_id_);
|
|
|
| + DCHECK(!buffer_id_);
|
| glGenBuffersARB(1, &buffer_id_);
|
| glBindBuffer(GL_ARRAY_BUFFER, buffer_id_);
|
| const GLfloat kQuadVertices[] = {-1.0f, -1.0f,
|
| @@ -81,6 +83,19 @@ void ClearFramebufferResourceManager::Initialize(
|
| -1.0f, 1.0f};
|
| glBufferData(
|
| GL_ARRAY_BUFFER, sizeof(kQuadVertices), kQuadVertices, GL_STATIC_DRAW);
|
| +
|
| + DCHECK(!vao_);
|
| +
|
| + if (feature_flags.native_vertex_array_object) {
|
| + glGenVertexArraysOES(1, &vao_);
|
| +
|
| + glBindVertexArrayOES(vao_);
|
| + glEnableVertexAttribArray(kVertexPositionAttrib);
|
| + glVertexAttribPointer(kVertexPositionAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
| +
|
| + decoder->RestoreAllAttributes();
|
| + }
|
| +
|
| decoder->RestoreBufferBindings();
|
| initialized_ = true;
|
| }
|
| @@ -90,6 +105,12 @@ void ClearFramebufferResourceManager::Destroy() {
|
| return;
|
|
|
| glDeleteProgram(program_);
|
| +
|
| + if (vao_ != 0) {
|
| + glDeleteVertexArraysOES(1, &vao_);
|
| + vao_ = 0;
|
| + }
|
| +
|
| glDeleteBuffersARB(1, &buffer_id_);
|
| buffer_id_ = 0;
|
| }
|
| @@ -140,11 +161,14 @@ void ClearFramebufferResourceManager::ClearFramebuffer(
|
| DLOG(ERROR) << "Invalid shader.";
|
| #endif
|
|
|
| - decoder->ClearAllAttributes();
|
| - glEnableVertexAttribArray(kVertexPositionAttrib);
|
| -
|
| - glBindBuffer(GL_ARRAY_BUFFER, buffer_id_);
|
| - glVertexAttribPointer(kVertexPositionAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
| + if (vao_) {
|
| + glBindVertexArrayOES(vao_);
|
| + } else {
|
| + decoder->ClearAllAttributes();
|
| + glBindBuffer(GL_ARRAY_BUFFER, buffer_id_);
|
| + glEnableVertexAttribArray(kVertexPositionAttrib);
|
| + glVertexAttribPointer(kVertexPositionAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
| + }
|
|
|
| glUniform1f(depth_handle_, clear_depth_value);
|
| glUniform4f(color_handle_, clear_color_red, clear_color_green,
|
| @@ -179,9 +203,11 @@ void ClearFramebufferResourceManager::ClearFramebuffer(
|
| glViewport(0, 0, framebuffer_size.width(), framebuffer_size.height());
|
| glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
|
|
| + if (vao_ == 0) {
|
| + decoder->RestoreBufferBindings();
|
| + }
|
| decoder->RestoreAllAttributes();
|
| decoder->RestoreProgramBindings();
|
| - decoder->RestoreBufferBindings();
|
| decoder->RestoreGlobalState();
|
| }
|
|
|
|
|