| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 GLsizei primcount); | 1364 GLsizei primcount); |
| 1365 error::Error DoDrawElements( | 1365 error::Error DoDrawElements( |
| 1366 const char* function_name, | 1366 const char* function_name, |
| 1367 bool instanced, GLenum mode, GLsizei count, GLenum type, | 1367 bool instanced, GLenum mode, GLsizei count, GLenum type, |
| 1368 int32 offset, GLsizei primcount); | 1368 int32 offset, GLsizei primcount); |
| 1369 | 1369 |
| 1370 // Gets the buffer id for a given target. | 1370 // Gets the buffer id for a given target. |
| 1371 Buffer* GetBufferInfoForTarget(GLenum target) { | 1371 Buffer* GetBufferInfoForTarget(GLenum target) { |
| 1372 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER); | 1372 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER); |
| 1373 if (target == GL_ARRAY_BUFFER) { | 1373 if (target == GL_ARRAY_BUFFER) { |
| 1374 return state_.bound_array_buffer; | 1374 return state_.bound_array_buffer.get(); |
| 1375 } else { | 1375 } else { |
| 1376 return state_.vertex_attrib_manager->element_array_buffer(); | 1376 return state_.vertex_attrib_manager->element_array_buffer(); |
| 1377 } | 1377 } |
| 1378 } | 1378 } |
| 1379 | 1379 |
| 1380 // Gets the texture id for a given target. | 1380 // Gets the texture id for a given target. |
| 1381 TextureRef* GetTextureInfoForTarget(GLenum target) { | 1381 TextureRef* GetTextureInfoForTarget(GLenum target) { |
| 1382 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 1382 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
| 1383 TextureRef* texture = NULL; | 1383 TextureRef* texture = NULL; |
| 1384 switch (target) { | 1384 switch (target) { |
| 1385 case GL_TEXTURE_2D: | 1385 case GL_TEXTURE_2D: |
| 1386 texture = unit.bound_texture_2d; | 1386 texture = unit.bound_texture_2d.get(); |
| 1387 break; | 1387 break; |
| 1388 case GL_TEXTURE_CUBE_MAP: | 1388 case GL_TEXTURE_CUBE_MAP: |
| 1389 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: | 1389 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 1390 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: | 1390 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 1391 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: | 1391 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 1392 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: | 1392 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 1393 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: | 1393 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 1394 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: | 1394 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 1395 texture = unit.bound_texture_cube_map; | 1395 texture = unit.bound_texture_cube_map.get(); |
| 1396 break; | 1396 break; |
| 1397 case GL_TEXTURE_EXTERNAL_OES: | 1397 case GL_TEXTURE_EXTERNAL_OES: |
| 1398 texture = unit.bound_texture_external_oes; | 1398 texture = unit.bound_texture_external_oes.get(); |
| 1399 break; | 1399 break; |
| 1400 case GL_TEXTURE_RECTANGLE_ARB: | 1400 case GL_TEXTURE_RECTANGLE_ARB: |
| 1401 texture = unit.bound_texture_rectangle_arb; | 1401 texture = unit.bound_texture_rectangle_arb.get(); |
| 1402 break; | 1402 break; |
| 1403 default: | 1403 default: |
| 1404 NOTREACHED(); | 1404 NOTREACHED(); |
| 1405 return NULL; | 1405 return NULL; |
| 1406 } | 1406 } |
| 1407 return texture; | 1407 return texture; |
| 1408 } | 1408 } |
| 1409 | 1409 |
| 1410 TextureRef* GetTextureInfoForTargetUnlessDefault( | 1410 TextureRef* GetTextureInfoForTargetUnlessDefault( |
| 1411 GLenum target) { | 1411 GLenum target) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1434 NOTREACHED(); | 1434 NOTREACHED(); |
| 1435 return 0; | 1435 return 0; |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 // Gets the framebuffer info for a particular target. | 1438 // Gets the framebuffer info for a particular target. |
| 1439 Framebuffer* GetFramebufferInfoForTarget(GLenum target) { | 1439 Framebuffer* GetFramebufferInfoForTarget(GLenum target) { |
| 1440 Framebuffer* framebuffer = NULL; | 1440 Framebuffer* framebuffer = NULL; |
| 1441 switch (target) { | 1441 switch (target) { |
| 1442 case GL_FRAMEBUFFER: | 1442 case GL_FRAMEBUFFER: |
| 1443 case GL_DRAW_FRAMEBUFFER_EXT: | 1443 case GL_DRAW_FRAMEBUFFER_EXT: |
| 1444 framebuffer = state_.bound_draw_framebuffer; | 1444 framebuffer = state_.bound_draw_framebuffer.get(); |
| 1445 break; | 1445 break; |
| 1446 case GL_READ_FRAMEBUFFER_EXT: | 1446 case GL_READ_FRAMEBUFFER_EXT: |
| 1447 framebuffer = state_.bound_read_framebuffer; | 1447 framebuffer = state_.bound_read_framebuffer.get(); |
| 1448 break; | 1448 break; |
| 1449 default: | 1449 default: |
| 1450 NOTREACHED(); | 1450 NOTREACHED(); |
| 1451 break; | 1451 break; |
| 1452 } | 1452 } |
| 1453 return framebuffer; | 1453 return framebuffer; |
| 1454 } | 1454 } |
| 1455 | 1455 |
| 1456 Renderbuffer* GetRenderbufferInfoForTarget( | 1456 Renderbuffer* GetRenderbufferInfoForTarget( |
| 1457 GLenum target) { | 1457 GLenum target) { |
| 1458 Renderbuffer* renderbuffer = NULL; | 1458 Renderbuffer* renderbuffer = NULL; |
| 1459 switch (target) { | 1459 switch (target) { |
| 1460 case GL_RENDERBUFFER: | 1460 case GL_RENDERBUFFER: |
| 1461 renderbuffer = state_.bound_renderbuffer; | 1461 renderbuffer = state_.bound_renderbuffer.get(); |
| 1462 break; | 1462 break; |
| 1463 default: | 1463 default: |
| 1464 NOTREACHED(); | 1464 NOTREACHED(); |
| 1465 break; | 1465 break; |
| 1466 } | 1466 } |
| 1467 return renderbuffer; | 1467 return renderbuffer; |
| 1468 } | 1468 } |
| 1469 | 1469 |
| 1470 // Validates the program and location for a glGetUniform call and returns | 1470 // Validates the program and location for a glGetUniform call and returns |
| 1471 // a SizeResult setup to receive the result. Returns true if glGetUniform | 1471 // a SizeResult setup to receive the result. Returns true if glGetUniform |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 const FeatureInfo::FeatureFlags& features() const { | 1513 const FeatureInfo::FeatureFlags& features() const { |
| 1514 return feature_info_->feature_flags(); | 1514 return feature_info_->feature_flags(); |
| 1515 } | 1515 } |
| 1516 | 1516 |
| 1517 const FeatureInfo::Workarounds& workarounds() const { | 1517 const FeatureInfo::Workarounds& workarounds() const { |
| 1518 return feature_info_->workarounds(); | 1518 return feature_info_->workarounds(); |
| 1519 } | 1519 } |
| 1520 | 1520 |
| 1521 bool ShouldDeferDraws() { | 1521 bool ShouldDeferDraws() { |
| 1522 return !offscreen_target_frame_buffer_.get() && | 1522 return !offscreen_target_frame_buffer_.get() && |
| 1523 state_.bound_draw_framebuffer == NULL && | 1523 state_.bound_draw_framebuffer.get() == NULL && |
| 1524 surface_->DeferDraws(); | 1524 surface_->DeferDraws(); |
| 1525 } | 1525 } |
| 1526 | 1526 |
| 1527 bool ShouldDeferReads() { | 1527 bool ShouldDeferReads() { |
| 1528 return !offscreen_target_frame_buffer_.get() && | 1528 return !offscreen_target_frame_buffer_.get() && |
| 1529 state_.bound_read_framebuffer == NULL && | 1529 state_.bound_read_framebuffer.get() == NULL && |
| 1530 surface_->DeferDraws(); | 1530 surface_->DeferDraws(); |
| 1531 } | 1531 } |
| 1532 | 1532 |
| 1533 void ForceCompileShaderIfPending(Shader* shader); | 1533 void ForceCompileShaderIfPending(Shader* shader); |
| 1534 | 1534 |
| 1535 // Generate a member function prototype for each command in an automated and | 1535 // Generate a member function prototype for each command in an automated and |
| 1536 // typesafe way. | 1536 // typesafe way. |
| 1537 #define GLES2_CMD_OP(name) \ | 1537 #define GLES2_CMD_OP(name) \ |
| 1538 Error Handle ## name( \ | 1538 Error Handle ## name( \ |
| 1539 uint32 immediate_data_size, \ | 1539 uint32 immediate_data_size, \ |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 | 2208 |
| 2209 disallowed_features_ = disallowed_features; | 2209 disallowed_features_ = disallowed_features; |
| 2210 | 2210 |
| 2211 state_.attrib_values.resize(group_->max_vertex_attribs()); | 2211 state_.attrib_values.resize(group_->max_vertex_attribs()); |
| 2212 default_vertex_attrib_manager_ = new VertexAttribManager(); | 2212 default_vertex_attrib_manager_ = new VertexAttribManager(); |
| 2213 default_vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); | 2213 default_vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); |
| 2214 | 2214 |
| 2215 // vertex_attrib_manager is set to default_vertex_attrib_manager_ by this call | 2215 // vertex_attrib_manager is set to default_vertex_attrib_manager_ by this call |
| 2216 DoBindVertexArrayOES(0); | 2216 DoBindVertexArrayOES(0); |
| 2217 | 2217 |
| 2218 query_manager_.reset(new QueryManager(this, feature_info_)); | 2218 query_manager_.reset(new QueryManager(this, feature_info_.get())); |
| 2219 vertex_array_manager_.reset(new VertexArrayManager()); | 2219 vertex_array_manager_.reset(new VertexArrayManager()); |
| 2220 | 2220 |
| 2221 util_.set_num_compressed_texture_formats( | 2221 util_.set_num_compressed_texture_formats( |
| 2222 validators_->compressed_texture_format.GetValues().size()); | 2222 validators_->compressed_texture_format.GetValues().size()); |
| 2223 | 2223 |
| 2224 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 2224 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 2225 // We have to enable vertex array 0 on OpenGL or it won't render. Note that | 2225 // We have to enable vertex array 0 on OpenGL or it won't render. Note that |
| 2226 // OpenGL ES 2.0 does not have this issue. | 2226 // OpenGL ES 2.0 does not have this issue. |
| 2227 glEnableVertexAttribArray(0); | 2227 glEnableVertexAttribArray(0); |
| 2228 } | 2228 } |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2628 } | 2628 } |
| 2629 return true; | 2629 return true; |
| 2630 } | 2630 } |
| 2631 | 2631 |
| 2632 void GLES2DecoderImpl::DeleteBuffersHelper( | 2632 void GLES2DecoderImpl::DeleteBuffersHelper( |
| 2633 GLsizei n, const GLuint* client_ids) { | 2633 GLsizei n, const GLuint* client_ids) { |
| 2634 for (GLsizei ii = 0; ii < n; ++ii) { | 2634 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2635 Buffer* buffer = GetBuffer(client_ids[ii]); | 2635 Buffer* buffer = GetBuffer(client_ids[ii]); |
| 2636 if (buffer && !buffer->IsDeleted()) { | 2636 if (buffer && !buffer->IsDeleted()) { |
| 2637 state_.vertex_attrib_manager->Unbind(buffer); | 2637 state_.vertex_attrib_manager->Unbind(buffer); |
| 2638 if (state_.bound_array_buffer == buffer) { | 2638 if (state_.bound_array_buffer.get() == buffer) { |
| 2639 state_.bound_array_buffer = NULL; | 2639 state_.bound_array_buffer = NULL; |
| 2640 } | 2640 } |
| 2641 RemoveBuffer(client_ids[ii]); | 2641 RemoveBuffer(client_ids[ii]); |
| 2642 } | 2642 } |
| 2643 } | 2643 } |
| 2644 } | 2644 } |
| 2645 | 2645 |
| 2646 void GLES2DecoderImpl::DeleteFramebuffersHelper( | 2646 void GLES2DecoderImpl::DeleteFramebuffersHelper( |
| 2647 GLsizei n, const GLuint* client_ids) { | 2647 GLsizei n, const GLuint* client_ids) { |
| 2648 bool supports_separate_framebuffer_binds = | 2648 bool supports_separate_framebuffer_binds = |
| 2649 features().chromium_framebuffer_multisample; | 2649 features().chromium_framebuffer_multisample; |
| 2650 | 2650 |
| 2651 for (GLsizei ii = 0; ii < n; ++ii) { | 2651 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2652 Framebuffer* framebuffer = | 2652 Framebuffer* framebuffer = |
| 2653 GetFramebuffer(client_ids[ii]); | 2653 GetFramebuffer(client_ids[ii]); |
| 2654 if (framebuffer && !framebuffer->IsDeleted()) { | 2654 if (framebuffer && !framebuffer->IsDeleted()) { |
| 2655 if (framebuffer == state_.bound_draw_framebuffer) { | 2655 if (framebuffer == state_.bound_draw_framebuffer.get()) { |
| 2656 state_.bound_draw_framebuffer = NULL; | 2656 state_.bound_draw_framebuffer = NULL; |
| 2657 clear_state_dirty_ = true; | 2657 clear_state_dirty_ = true; |
| 2658 GLenum target = supports_separate_framebuffer_binds ? | 2658 GLenum target = supports_separate_framebuffer_binds ? |
| 2659 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | 2659 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; |
| 2660 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 2660 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
| 2661 } | 2661 } |
| 2662 if (framebuffer == state_.bound_read_framebuffer) { | 2662 if (framebuffer == state_.bound_read_framebuffer.get()) { |
| 2663 state_.bound_read_framebuffer = NULL; | 2663 state_.bound_read_framebuffer = NULL; |
| 2664 GLenum target = supports_separate_framebuffer_binds ? | 2664 GLenum target = supports_separate_framebuffer_binds ? |
| 2665 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | 2665 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; |
| 2666 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 2666 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
| 2667 } | 2667 } |
| 2668 OnFboChanged(); | 2668 OnFboChanged(); |
| 2669 RemoveFramebuffer(client_ids[ii]); | 2669 RemoveFramebuffer(client_ids[ii]); |
| 2670 } | 2670 } |
| 2671 } | 2671 } |
| 2672 } | 2672 } |
| 2673 | 2673 |
| 2674 void GLES2DecoderImpl::DeleteRenderbuffersHelper( | 2674 void GLES2DecoderImpl::DeleteRenderbuffersHelper( |
| 2675 GLsizei n, const GLuint* client_ids) { | 2675 GLsizei n, const GLuint* client_ids) { |
| 2676 bool supports_separate_framebuffer_binds = | 2676 bool supports_separate_framebuffer_binds = |
| 2677 features().chromium_framebuffer_multisample; | 2677 features().chromium_framebuffer_multisample; |
| 2678 for (GLsizei ii = 0; ii < n; ++ii) { | 2678 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2679 Renderbuffer* renderbuffer = | 2679 Renderbuffer* renderbuffer = |
| 2680 GetRenderbuffer(client_ids[ii]); | 2680 GetRenderbuffer(client_ids[ii]); |
| 2681 if (renderbuffer && !renderbuffer->IsDeleted()) { | 2681 if (renderbuffer && !renderbuffer->IsDeleted()) { |
| 2682 if (state_.bound_renderbuffer == renderbuffer) { | 2682 if (state_.bound_renderbuffer.get() == renderbuffer) { |
| 2683 state_.bound_renderbuffer = NULL; | 2683 state_.bound_renderbuffer = NULL; |
| 2684 } | 2684 } |
| 2685 // Unbind from current framebuffers. | 2685 // Unbind from current framebuffers. |
| 2686 if (supports_separate_framebuffer_binds) { | 2686 if (supports_separate_framebuffer_binds) { |
| 2687 if (state_.bound_read_framebuffer) { | 2687 if (state_.bound_read_framebuffer.get()) { |
| 2688 state_.bound_read_framebuffer->UnbindRenderbuffer( | 2688 state_.bound_read_framebuffer |
| 2689 GL_READ_FRAMEBUFFER_EXT, renderbuffer); | 2689 ->UnbindRenderbuffer(GL_READ_FRAMEBUFFER_EXT, renderbuffer); |
| 2690 } | 2690 } |
| 2691 if (state_.bound_draw_framebuffer) { | 2691 if (state_.bound_draw_framebuffer.get()) { |
| 2692 state_.bound_draw_framebuffer->UnbindRenderbuffer( | 2692 state_.bound_draw_framebuffer |
| 2693 GL_DRAW_FRAMEBUFFER_EXT, renderbuffer); | 2693 ->UnbindRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, renderbuffer); |
| 2694 } | 2694 } |
| 2695 } else { | 2695 } else { |
| 2696 if (state_.bound_draw_framebuffer) { | 2696 if (state_.bound_draw_framebuffer.get()) { |
| 2697 state_.bound_draw_framebuffer->UnbindRenderbuffer( | 2697 state_.bound_draw_framebuffer |
| 2698 GL_FRAMEBUFFER, renderbuffer); | 2698 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer); |
| 2699 } | 2699 } |
| 2700 } | 2700 } |
| 2701 clear_state_dirty_ = true; | 2701 clear_state_dirty_ = true; |
| 2702 RemoveRenderbuffer(client_ids[ii]); | 2702 RemoveRenderbuffer(client_ids[ii]); |
| 2703 } | 2703 } |
| 2704 } | 2704 } |
| 2705 } | 2705 } |
| 2706 | 2706 |
| 2707 void GLES2DecoderImpl::DeleteTexturesHelper( | 2707 void GLES2DecoderImpl::DeleteTexturesHelper( |
| 2708 GLsizei n, const GLuint* client_ids) { | 2708 GLsizei n, const GLuint* client_ids) { |
| 2709 bool supports_separate_framebuffer_binds = | 2709 bool supports_separate_framebuffer_binds = |
| 2710 features().chromium_framebuffer_multisample; | 2710 features().chromium_framebuffer_multisample; |
| 2711 for (GLsizei ii = 0; ii < n; ++ii) { | 2711 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2712 TextureRef* texture_ref = GetTexture(client_ids[ii]); | 2712 TextureRef* texture_ref = GetTexture(client_ids[ii]); |
| 2713 if (texture_ref) { | 2713 if (texture_ref) { |
| 2714 Texture* texture = texture_ref->texture(); | 2714 Texture* texture = texture_ref->texture(); |
| 2715 if (texture->IsAttachedToFramebuffer()) { | 2715 if (texture->IsAttachedToFramebuffer()) { |
| 2716 clear_state_dirty_ = true; | 2716 clear_state_dirty_ = true; |
| 2717 } | 2717 } |
| 2718 // Unbind texture_ref from texture_ref units. | 2718 // Unbind texture_ref from texture_ref units. |
| 2719 for (size_t jj = 0; jj < state_.texture_units.size(); ++jj) { | 2719 for (size_t jj = 0; jj < state_.texture_units.size(); ++jj) { |
| 2720 state_.texture_units[jj].Unbind(texture_ref); | 2720 state_.texture_units[jj].Unbind(texture_ref); |
| 2721 } | 2721 } |
| 2722 // Unbind from current framebuffers. | 2722 // Unbind from current framebuffers. |
| 2723 if (supports_separate_framebuffer_binds) { | 2723 if (supports_separate_framebuffer_binds) { |
| 2724 if (state_.bound_read_framebuffer) { | 2724 if (state_.bound_read_framebuffer.get()) { |
| 2725 state_.bound_read_framebuffer->UnbindTexture( | 2725 state_.bound_read_framebuffer |
| 2726 GL_READ_FRAMEBUFFER_EXT, texture_ref); | 2726 ->UnbindTexture(GL_READ_FRAMEBUFFER_EXT, texture_ref); |
| 2727 } | 2727 } |
| 2728 if (state_.bound_draw_framebuffer) { | 2728 if (state_.bound_draw_framebuffer.get()) { |
| 2729 state_.bound_draw_framebuffer->UnbindTexture( | 2729 state_.bound_draw_framebuffer |
| 2730 GL_DRAW_FRAMEBUFFER_EXT, texture_ref); | 2730 ->UnbindTexture(GL_DRAW_FRAMEBUFFER_EXT, texture_ref); |
| 2731 } | 2731 } |
| 2732 } else { | 2732 } else { |
| 2733 if (state_.bound_draw_framebuffer) { | 2733 if (state_.bound_draw_framebuffer.get()) { |
| 2734 state_.bound_draw_framebuffer->UnbindTexture(GL_FRAMEBUFFER, | 2734 state_.bound_draw_framebuffer |
| 2735 texture_ref); | 2735 ->UnbindTexture(GL_FRAMEBUFFER, texture_ref); |
| 2736 } | 2736 } |
| 2737 } | 2737 } |
| 2738 GLuint service_id = texture->service_id(); | 2738 GLuint service_id = texture->service_id(); |
| 2739 if (texture->IsStreamTexture() && stream_texture_manager_) { | 2739 if (texture->IsStreamTexture() && stream_texture_manager_) { |
| 2740 stream_texture_manager_->DestroyStreamTexture(service_id); | 2740 stream_texture_manager_->DestroyStreamTexture(service_id); |
| 2741 } | 2741 } |
| 2742 #if defined(OS_MACOSX) | 2742 #if defined(OS_MACOSX) |
| 2743 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { | 2743 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { |
| 2744 ReleaseIOSurfaceForTexture(service_id); | 2744 ReleaseIOSurfaceForTexture(service_id); |
| 2745 } | 2745 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2836 GL_DRAW_FRAMEBUFFER_EXT, | 2836 GL_DRAW_FRAMEBUFFER_EXT, |
| 2837 state_.bound_draw_framebuffer.get(), | 2837 state_.bound_draw_framebuffer.get(), |
| 2838 GetBackbufferServiceId()); | 2838 GetBackbufferServiceId()); |
| 2839 } | 2839 } |
| 2840 OnFboChanged(); | 2840 OnFboChanged(); |
| 2841 } | 2841 } |
| 2842 | 2842 |
| 2843 void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() { | 2843 void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() { |
| 2844 TextureUnit& info = state_.texture_units[0]; | 2844 TextureUnit& info = state_.texture_units[0]; |
| 2845 GLuint last_id; | 2845 GLuint last_id; |
| 2846 if (info.bound_texture_2d) { | 2846 if (info.bound_texture_2d.get()) { |
| 2847 last_id = info.bound_texture_2d->service_id(); | 2847 last_id = info.bound_texture_2d->service_id(); |
| 2848 } else { | 2848 } else { |
| 2849 last_id = 0; | 2849 last_id = 0; |
| 2850 } | 2850 } |
| 2851 | 2851 |
| 2852 glBindTexture(GL_TEXTURE_2D, last_id); | 2852 glBindTexture(GL_TEXTURE_2D, last_id); |
| 2853 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); | 2853 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); |
| 2854 } | 2854 } |
| 2855 | 2855 |
| 2856 bool GLES2DecoderImpl::CheckFramebufferValid( | 2856 bool GLES2DecoderImpl::CheckFramebufferValid( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2912 } | 2912 } |
| 2913 | 2913 |
| 2914 // NOTE: At this point we don't know if the framebuffer is complete but | 2914 // NOTE: At this point we don't know if the framebuffer is complete but |
| 2915 // we DO know that everything that needs to be cleared has been cleared. | 2915 // we DO know that everything that needs to be cleared has been cleared. |
| 2916 return true; | 2916 return true; |
| 2917 } | 2917 } |
| 2918 | 2918 |
| 2919 bool GLES2DecoderImpl::CheckBoundFramebuffersValid(const char* func_name) { | 2919 bool GLES2DecoderImpl::CheckBoundFramebuffersValid(const char* func_name) { |
| 2920 if (!features().chromium_framebuffer_multisample) { | 2920 if (!features().chromium_framebuffer_multisample) { |
| 2921 bool valid = CheckFramebufferValid( | 2921 bool valid = CheckFramebufferValid( |
| 2922 state_.bound_draw_framebuffer, GL_FRAMEBUFFER_EXT, func_name); | 2922 state_.bound_draw_framebuffer.get(), GL_FRAMEBUFFER_EXT, func_name); |
| 2923 | 2923 |
| 2924 if (valid) | 2924 if (valid) |
| 2925 OnUseFramebuffer(); | 2925 OnUseFramebuffer(); |
| 2926 | 2926 |
| 2927 return valid; | 2927 return valid; |
| 2928 } | 2928 } |
| 2929 return CheckFramebufferValid( | 2929 return CheckFramebufferValid(state_.bound_draw_framebuffer.get(), |
| 2930 state_.bound_draw_framebuffer, | 2930 GL_DRAW_FRAMEBUFFER_EXT, |
| 2931 GL_DRAW_FRAMEBUFFER_EXT, func_name) && | 2931 func_name) && |
| 2932 CheckFramebufferValid( | 2932 CheckFramebufferValid(state_.bound_read_framebuffer.get(), |
| 2933 state_.bound_read_framebuffer, | 2933 GL_READ_FRAMEBUFFER_EXT, |
| 2934 GL_READ_FRAMEBUFFER_EXT, func_name); | 2934 func_name); |
| 2935 } | 2935 } |
| 2936 | 2936 |
| 2937 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { | 2937 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { |
| 2938 Framebuffer* framebuffer = | 2938 Framebuffer* framebuffer = |
| 2939 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); | 2939 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); |
| 2940 if (framebuffer != NULL) { | 2940 if (framebuffer != NULL) { |
| 2941 const Framebuffer::Attachment* attachment = | 2941 const Framebuffer::Attachment* attachment = |
| 2942 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0); | 2942 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0); |
| 2943 if (attachment) { | 2943 if (attachment) { |
| 2944 return gfx::Size(attachment->width(), attachment->height()); | 2944 return gfx::Size(attachment->width(), attachment->height()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2977 | 2977 |
| 2978 void GLES2DecoderImpl::UpdateParentTextureInfo() { | 2978 void GLES2DecoderImpl::UpdateParentTextureInfo() { |
| 2979 if (parent_) { | 2979 if (parent_) { |
| 2980 // Update the info about the offscreen saved color texture in the parent. | 2980 // Update the info about the offscreen saved color texture in the parent. |
| 2981 // The reference to the parent is a weak pointer and will become null if the | 2981 // The reference to the parent is a weak pointer and will become null if the |
| 2982 // parent is later destroyed. | 2982 // parent is later destroyed. |
| 2983 GLenum target = offscreen_saved_color_texture_info_->texture()->target(); | 2983 GLenum target = offscreen_saved_color_texture_info_->texture()->target(); |
| 2984 TextureManager* parent_texture_manager = parent_->texture_manager(); | 2984 TextureManager* parent_texture_manager = parent_->texture_manager(); |
| 2985 glBindTexture(target, offscreen_saved_color_texture_info_->service_id()); | 2985 glBindTexture(target, offscreen_saved_color_texture_info_->service_id()); |
| 2986 parent_texture_manager->SetLevelInfo( | 2986 parent_texture_manager->SetLevelInfo( |
| 2987 offscreen_saved_color_texture_info_, | 2987 offscreen_saved_color_texture_info_.get(), |
| 2988 GL_TEXTURE_2D, | 2988 GL_TEXTURE_2D, |
| 2989 0, // level | 2989 0, // level |
| 2990 GL_RGBA, | 2990 GL_RGBA, |
| 2991 offscreen_size_.width(), | 2991 offscreen_size_.width(), |
| 2992 offscreen_size_.height(), | 2992 offscreen_size_.height(), |
| 2993 1, // depth | 2993 1, // depth |
| 2994 0, // border | 2994 0, // border |
| 2995 GL_RGBA, | 2995 GL_RGBA, |
| 2996 GL_UNSIGNED_BYTE, | 2996 GL_UNSIGNED_BYTE, |
| 2997 true); | 2997 true); |
| 2998 parent_texture_manager->SetParameter( | 2998 parent_texture_manager->SetParameter( |
| 2999 "UpdateParentTextureInfo", | 2999 "UpdateParentTextureInfo", |
| 3000 GetErrorState(), | 3000 GetErrorState(), |
| 3001 offscreen_saved_color_texture_info_, | 3001 offscreen_saved_color_texture_info_.get(), |
| 3002 GL_TEXTURE_MAG_FILTER, | 3002 GL_TEXTURE_MAG_FILTER, |
| 3003 GL_NEAREST); | 3003 GL_NEAREST); |
| 3004 parent_texture_manager->SetParameter( | 3004 parent_texture_manager->SetParameter( |
| 3005 "UpdateParentTextureInfo", | 3005 "UpdateParentTextureInfo", |
| 3006 GetErrorState(), | 3006 GetErrorState(), |
| 3007 offscreen_saved_color_texture_info_, | 3007 offscreen_saved_color_texture_info_.get(), |
| 3008 GL_TEXTURE_MIN_FILTER, | 3008 GL_TEXTURE_MIN_FILTER, |
| 3009 GL_NEAREST); | 3009 GL_NEAREST); |
| 3010 parent_texture_manager->SetParameter( | 3010 parent_texture_manager->SetParameter( |
| 3011 "UpdateParentTextureInfo", | 3011 "UpdateParentTextureInfo", |
| 3012 GetErrorState(), | 3012 GetErrorState(), |
| 3013 offscreen_saved_color_texture_info_, | 3013 offscreen_saved_color_texture_info_.get(), |
| 3014 GL_TEXTURE_WRAP_S, | 3014 GL_TEXTURE_WRAP_S, |
| 3015 GL_CLAMP_TO_EDGE); | 3015 GL_CLAMP_TO_EDGE); |
| 3016 parent_texture_manager->SetParameter( | 3016 parent_texture_manager->SetParameter( |
| 3017 "UpdateParentTextureInfo", | 3017 "UpdateParentTextureInfo", |
| 3018 GetErrorState(), | 3018 GetErrorState(), |
| 3019 offscreen_saved_color_texture_info_, | 3019 offscreen_saved_color_texture_info_.get(), |
| 3020 GL_TEXTURE_WRAP_T, | 3020 GL_TEXTURE_WRAP_T, |
| 3021 GL_CLAMP_TO_EDGE); | 3021 GL_CLAMP_TO_EDGE); |
| 3022 TextureRef* texture_ref = GetTextureInfoForTarget(target); | 3022 TextureRef* texture_ref = GetTextureInfoForTarget(target); |
| 3023 glBindTexture(target, texture_ref ? texture_ref->service_id() : 0); | 3023 glBindTexture(target, texture_ref ? texture_ref->service_id() : 0); |
| 3024 } else { | 3024 } else { |
| 3025 offscreen_saved_color_texture_info_ = NULL; | 3025 offscreen_saved_color_texture_info_ = NULL; |
| 3026 } | 3026 } |
| 3027 } | 3027 } |
| 3028 | 3028 |
| 3029 void GLES2DecoderImpl::SetResizeCallback( | 3029 void GLES2DecoderImpl::SetResizeCallback( |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3122 state_.bound_read_framebuffer = NULL; | 3122 state_.bound_read_framebuffer = NULL; |
| 3123 state_.bound_draw_framebuffer = NULL; | 3123 state_.bound_draw_framebuffer = NULL; |
| 3124 state_.bound_renderbuffer = NULL; | 3124 state_.bound_renderbuffer = NULL; |
| 3125 | 3125 |
| 3126 if (have_context) { | 3126 if (have_context) { |
| 3127 if (copy_texture_CHROMIUM_.get()) { | 3127 if (copy_texture_CHROMIUM_.get()) { |
| 3128 copy_texture_CHROMIUM_->Destroy(); | 3128 copy_texture_CHROMIUM_->Destroy(); |
| 3129 copy_texture_CHROMIUM_.reset(); | 3129 copy_texture_CHROMIUM_.reset(); |
| 3130 } | 3130 } |
| 3131 | 3131 |
| 3132 if (state_.current_program) { | 3132 if (state_.current_program.get()) { |
| 3133 program_manager()->UnuseProgram(shader_manager(), state_.current_program); | 3133 program_manager()->UnuseProgram(shader_manager(), |
| 3134 state_.current_program.get()); |
| 3134 state_.current_program = NULL; | 3135 state_.current_program = NULL; |
| 3135 } | 3136 } |
| 3136 | 3137 |
| 3137 if (attrib_0_buffer_id_) { | 3138 if (attrib_0_buffer_id_) { |
| 3138 glDeleteBuffersARB(1, &attrib_0_buffer_id_); | 3139 glDeleteBuffersARB(1, &attrib_0_buffer_id_); |
| 3139 } | 3140 } |
| 3140 if (fixed_attrib_buffer_id_) { | 3141 if (fixed_attrib_buffer_id_) { |
| 3141 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); | 3142 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); |
| 3142 } | 3143 } |
| 3143 | 3144 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3198 offscreen_target_stencil_render_buffer_.reset(); | 3199 offscreen_target_stencil_render_buffer_.reset(); |
| 3199 offscreen_saved_frame_buffer_.reset(); | 3200 offscreen_saved_frame_buffer_.reset(); |
| 3200 offscreen_saved_color_texture_.reset(); | 3201 offscreen_saved_color_texture_.reset(); |
| 3201 offscreen_resolved_frame_buffer_.reset(); | 3202 offscreen_resolved_frame_buffer_.reset(); |
| 3202 offscreen_resolved_color_texture_.reset(); | 3203 offscreen_resolved_color_texture_.reset(); |
| 3203 | 3204 |
| 3204 // Should destroy the transfer manager before the texture manager held | 3205 // Should destroy the transfer manager before the texture manager held |
| 3205 // by the context group. | 3206 // by the context group. |
| 3206 async_pixel_transfer_manager_.reset(); | 3207 async_pixel_transfer_manager_.reset(); |
| 3207 | 3208 |
| 3208 if (group_) { | 3209 if (group_.get()) { |
| 3209 group_->Destroy(this, have_context); | 3210 group_->Destroy(this, have_context); |
| 3210 group_ = NULL; | 3211 group_ = NULL; |
| 3211 } | 3212 } |
| 3212 | 3213 |
| 3213 if (context_.get()) { | 3214 if (context_.get()) { |
| 3214 context_->ReleaseCurrent(NULL); | 3215 context_->ReleaseCurrent(NULL); |
| 3215 context_ = NULL; | 3216 context_ = NULL; |
| 3216 } | 3217 } |
| 3217 | 3218 |
| 3218 #if defined(OS_MACOSX) | 3219 #if defined(OS_MACOSX) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3242 // already been destroyed. | 3243 // already been destroyed. |
| 3243 if (parent_) { | 3244 if (parent_) { |
| 3244 ChildList::iterator it = std::find( | 3245 ChildList::iterator it = std::find( |
| 3245 parent_->children_.begin(), | 3246 parent_->children_.begin(), |
| 3246 parent_->children_.end(), | 3247 parent_->children_.end(), |
| 3247 this); | 3248 this); |
| 3248 DCHECK(it != parent_->children_.end()); | 3249 DCHECK(it != parent_->children_.end()); |
| 3249 parent_->children_.erase(it); | 3250 parent_->children_.erase(it); |
| 3250 // First check the texture has been mapped into the parent. This might not | 3251 // First check the texture has been mapped into the parent. This might not |
| 3251 // be the case if initialization failed midway through. | 3252 // be the case if initialization failed midway through. |
| 3252 if (offscreen_saved_color_texture_info_ && | 3253 if (offscreen_saved_color_texture_info_.get() && |
| 3253 offscreen_saved_color_texture_info_->client_id()) { | 3254 offscreen_saved_color_texture_info_->client_id()) { |
| 3254 parent_->texture_manager()->RemoveTexture( | 3255 parent_->texture_manager()->RemoveTexture( |
| 3255 offscreen_saved_color_texture_info_->client_id()); | 3256 offscreen_saved_color_texture_info_->client_id()); |
| 3256 } | 3257 } |
| 3257 } | 3258 } |
| 3258 | 3259 |
| 3259 GLES2DecoderImpl* new_parent_impl = static_cast<GLES2DecoderImpl*>( | 3260 GLES2DecoderImpl* new_parent_impl = static_cast<GLES2DecoderImpl*>( |
| 3260 new_parent); | 3261 new_parent); |
| 3261 if (new_parent_impl) { | 3262 if (new_parent_impl) { |
| 3262 #ifndef NDEBUG | 3263 #ifndef NDEBUG |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3273 | 3274 |
| 3274 // Replace texture info when ID is already in use by parent. | 3275 // Replace texture info when ID is already in use by parent. |
| 3275 if (new_parent_impl->texture_manager()->GetTexture( | 3276 if (new_parent_impl->texture_manager()->GetTexture( |
| 3276 new_parent_texture_id)) | 3277 new_parent_texture_id)) |
| 3277 new_parent_impl->texture_manager()->RemoveTexture( | 3278 new_parent_impl->texture_manager()->RemoveTexture( |
| 3278 new_parent_texture_id); | 3279 new_parent_texture_id); |
| 3279 | 3280 |
| 3280 offscreen_saved_color_texture_info_ = | 3281 offscreen_saved_color_texture_info_ = |
| 3281 new_parent_impl->CreateTexture(new_parent_texture_id, service_id); | 3282 new_parent_impl->CreateTexture(new_parent_texture_id, service_id); |
| 3282 offscreen_saved_color_texture_info_->texture()->SetNotOwned(); | 3283 offscreen_saved_color_texture_info_->texture()->SetNotOwned(); |
| 3283 new_parent_impl->texture_manager()-> | 3284 new_parent_impl->texture_manager() |
| 3284 SetTarget(offscreen_saved_color_texture_info_, GL_TEXTURE_2D); | 3285 ->SetTarget(offscreen_saved_color_texture_info_.get(), GL_TEXTURE_2D); |
| 3285 | 3286 |
| 3286 parent_ = base::AsWeakPtr<GLES2DecoderImpl>(new_parent_impl); | 3287 parent_ = base::AsWeakPtr<GLES2DecoderImpl>(new_parent_impl); |
| 3287 | 3288 |
| 3288 UpdateParentTextureInfo(); | 3289 UpdateParentTextureInfo(); |
| 3289 } else { | 3290 } else { |
| 3290 parent_.reset(); | 3291 parent_.reset(); |
| 3291 offscreen_saved_color_texture_info_ = NULL; | 3292 offscreen_saved_color_texture_info_ = NULL; |
| 3292 } | 3293 } |
| 3293 | 3294 |
| 3294 return true; | 3295 return true; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3680 EnableDisable( | 3681 EnableDisable( |
| 3681 GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil); | 3682 GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil); |
| 3682 EnableDisable(GL_CULL_FACE, state_.enable_flags.cull_face); | 3683 EnableDisable(GL_CULL_FACE, state_.enable_flags.cull_face); |
| 3683 EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test); | 3684 EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test); |
| 3684 EnableDisable(GL_BLEND, state_.enable_flags.blend); | 3685 EnableDisable(GL_BLEND, state_.enable_flags.blend); |
| 3685 clear_state_dirty_ = false; | 3686 clear_state_dirty_ = false; |
| 3686 } | 3687 } |
| 3687 } | 3688 } |
| 3688 | 3689 |
| 3689 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { | 3690 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { |
| 3690 return (offscreen_target_frame_buffer_.get()) ? | 3691 return (offscreen_target_frame_buffer_.get()) |
| 3691 offscreen_target_frame_buffer_->id() : | 3692 ? offscreen_target_frame_buffer_->id() |
| 3692 (surface_ ? surface_->GetBackingFrameBufferObject() : 0); | 3693 : (surface_.get() ? surface_->GetBackingFrameBufferObject() : 0); |
| 3693 } | 3694 } |
| 3694 | 3695 |
| 3695 void GLES2DecoderImpl::RestoreState() const { | 3696 void GLES2DecoderImpl::RestoreState() const { |
| 3696 TRACE_EVENT1("gpu", "GLES2DecoderImpl::RestoreState", | 3697 TRACE_EVENT1("gpu", "GLES2DecoderImpl::RestoreState", |
| 3697 "context", logger_.GetLogPrefix()); | 3698 "context", logger_.GetLogPrefix()); |
| 3698 // Restore the Framebuffer first because of bugs in Intel drivers. | 3699 // Restore the Framebuffer first because of bugs in Intel drivers. |
| 3699 // Intel drivers incorrectly clip the viewport settings to | 3700 // Intel drivers incorrectly clip the viewport settings to |
| 3700 // the size of the current framebuffer object. | 3701 // the size of the current framebuffer object. |
| 3701 RestoreFramebufferBindings(); | 3702 RestoreFramebufferBindings(); |
| 3702 state_.RestoreState(); | 3703 state_.RestoreState(); |
| 3703 } | 3704 } |
| 3704 | 3705 |
| 3705 void GLES2DecoderImpl::RestoreFramebufferBindings() const { | 3706 void GLES2DecoderImpl::RestoreFramebufferBindings() const { |
| 3706 GLuint service_id = state_.bound_draw_framebuffer ? | 3707 GLuint service_id = state_.bound_draw_framebuffer.get() |
| 3707 state_.bound_draw_framebuffer->service_id() : | 3708 ? state_.bound_draw_framebuffer->service_id() |
| 3708 GetBackbufferServiceId(); | 3709 : GetBackbufferServiceId(); |
| 3709 if (!features().chromium_framebuffer_multisample) { | 3710 if (!features().chromium_framebuffer_multisample) { |
| 3710 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id); | 3711 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id); |
| 3711 } else { | 3712 } else { |
| 3712 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id); | 3713 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id); |
| 3713 service_id = state_.bound_read_framebuffer ? | 3714 service_id = state_.bound_read_framebuffer.get() |
| 3714 state_.bound_read_framebuffer->service_id() : | 3715 ? state_.bound_read_framebuffer->service_id() |
| 3715 GetBackbufferServiceId(); | 3716 : GetBackbufferServiceId(); |
| 3716 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id); | 3717 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id); |
| 3717 } | 3718 } |
| 3718 OnFboChanged(); | 3719 OnFboChanged(); |
| 3719 } | 3720 } |
| 3720 | 3721 |
| 3721 void GLES2DecoderImpl::RestoreTextureState(unsigned service_id) const { | 3722 void GLES2DecoderImpl::RestoreTextureState(unsigned service_id) const { |
| 3722 Texture* texture = texture_manager()->GetTextureForServiceId(service_id); | 3723 Texture* texture = texture_manager()->GetTextureForServiceId(service_id); |
| 3723 if (texture) { | 3724 if (texture) { |
| 3724 GLenum target = texture->target(); | 3725 GLenum target = texture->target(); |
| 3725 glBindTexture(target, service_id); | 3726 glBindTexture(target, service_id); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4159 return true; | 4160 return true; |
| 4160 case GL_SHADER_COMPILER: | 4161 case GL_SHADER_COMPILER: |
| 4161 *num_written = 1; | 4162 *num_written = 1; |
| 4162 if (params) { | 4163 if (params) { |
| 4163 *params = GL_TRUE; | 4164 *params = GL_TRUE; |
| 4164 } | 4165 } |
| 4165 return true; | 4166 return true; |
| 4166 case GL_ARRAY_BUFFER_BINDING: | 4167 case GL_ARRAY_BUFFER_BINDING: |
| 4167 *num_written = 1; | 4168 *num_written = 1; |
| 4168 if (params) { | 4169 if (params) { |
| 4169 if (state_.bound_array_buffer) { | 4170 if (state_.bound_array_buffer.get()) { |
| 4170 GLuint client_id = 0; | 4171 GLuint client_id = 0; |
| 4171 buffer_manager()->GetClientId(state_.bound_array_buffer->service_id(), | 4172 buffer_manager()->GetClientId(state_.bound_array_buffer->service_id(), |
| 4172 &client_id); | 4173 &client_id); |
| 4173 *params = client_id; | 4174 *params = client_id; |
| 4174 } else { | 4175 } else { |
| 4175 *params = 0; | 4176 *params = 0; |
| 4176 } | 4177 } |
| 4177 } | 4178 } |
| 4178 return true; | 4179 return true; |
| 4179 case GL_ELEMENT_ARRAY_BUFFER_BINDING: | 4180 case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4229 if (renderbuffer) { | 4230 if (renderbuffer) { |
| 4230 *params = renderbuffer->client_id(); | 4231 *params = renderbuffer->client_id(); |
| 4231 } else { | 4232 } else { |
| 4232 *params = 0; | 4233 *params = 0; |
| 4233 } | 4234 } |
| 4234 } | 4235 } |
| 4235 return true; | 4236 return true; |
| 4236 case GL_CURRENT_PROGRAM: | 4237 case GL_CURRENT_PROGRAM: |
| 4237 *num_written = 1; | 4238 *num_written = 1; |
| 4238 if (params) { | 4239 if (params) { |
| 4239 if (state_.current_program) { | 4240 if (state_.current_program.get()) { |
| 4240 GLuint client_id = 0; | 4241 GLuint client_id = 0; |
| 4241 program_manager()->GetClientId( | 4242 program_manager()->GetClientId( |
| 4242 state_.current_program->service_id(), &client_id); | 4243 state_.current_program->service_id(), &client_id); |
| 4243 *params = client_id; | 4244 *params = client_id; |
| 4244 } else { | 4245 } else { |
| 4245 *params = 0; | 4246 *params = 0; |
| 4246 } | 4247 } |
| 4247 } | 4248 } |
| 4248 return true; | 4249 return true; |
| 4249 case GL_VERTEX_ARRAY_BINDING_OES: | 4250 case GL_VERTEX_ARRAY_BINDING_OES: |
| 4250 *num_written = 1; | 4251 *num_written = 1; |
| 4251 if (params) { | 4252 if (params) { |
| 4252 if (state_.vertex_attrib_manager != default_vertex_attrib_manager_) { | 4253 if (state_.vertex_attrib_manager.get() != |
| 4254 default_vertex_attrib_manager_.get()) { |
| 4253 GLuint client_id = 0; | 4255 GLuint client_id = 0; |
| 4254 vertex_array_manager_->GetClientId( | 4256 vertex_array_manager_->GetClientId( |
| 4255 state_.vertex_attrib_manager->service_id(), &client_id); | 4257 state_.vertex_attrib_manager->service_id(), &client_id); |
| 4256 *params = client_id; | 4258 *params = client_id; |
| 4257 } else { | 4259 } else { |
| 4258 *params = 0; | 4260 *params = 0; |
| 4259 } | 4261 } |
| 4260 } | 4262 } |
| 4261 return true; | 4263 return true; |
| 4262 case GL_TEXTURE_BINDING_2D: | 4264 case GL_TEXTURE_BINDING_2D: |
| 4263 *num_written = 1; | 4265 *num_written = 1; |
| 4264 if (params) { | 4266 if (params) { |
| 4265 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 4267 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
| 4266 if (unit.bound_texture_2d) { | 4268 if (unit.bound_texture_2d.get()) { |
| 4267 *params = unit.bound_texture_2d->client_id(); | 4269 *params = unit.bound_texture_2d->client_id(); |
| 4268 } else { | 4270 } else { |
| 4269 *params = 0; | 4271 *params = 0; |
| 4270 } | 4272 } |
| 4271 } | 4273 } |
| 4272 return true; | 4274 return true; |
| 4273 case GL_TEXTURE_BINDING_CUBE_MAP: | 4275 case GL_TEXTURE_BINDING_CUBE_MAP: |
| 4274 *num_written = 1; | 4276 *num_written = 1; |
| 4275 if (params) { | 4277 if (params) { |
| 4276 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 4278 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
| 4277 if (unit.bound_texture_cube_map) { | 4279 if (unit.bound_texture_cube_map.get()) { |
| 4278 *params = unit.bound_texture_cube_map->client_id(); | 4280 *params = unit.bound_texture_cube_map->client_id(); |
| 4279 } else { | 4281 } else { |
| 4280 *params = 0; | 4282 *params = 0; |
| 4281 } | 4283 } |
| 4282 } | 4284 } |
| 4283 return true; | 4285 return true; |
| 4284 case GL_TEXTURE_BINDING_EXTERNAL_OES: | 4286 case GL_TEXTURE_BINDING_EXTERNAL_OES: |
| 4285 *num_written = 1; | 4287 *num_written = 1; |
| 4286 if (params) { | 4288 if (params) { |
| 4287 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 4289 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
| 4288 if (unit.bound_texture_external_oes) { | 4290 if (unit.bound_texture_external_oes.get()) { |
| 4289 *params = unit.bound_texture_external_oes->client_id(); | 4291 *params = unit.bound_texture_external_oes->client_id(); |
| 4290 } else { | 4292 } else { |
| 4291 *params = 0; | 4293 *params = 0; |
| 4292 } | 4294 } |
| 4293 } | 4295 } |
| 4294 return true; | 4296 return true; |
| 4295 case GL_TEXTURE_BINDING_RECTANGLE_ARB: | 4297 case GL_TEXTURE_BINDING_RECTANGLE_ARB: |
| 4296 *num_written = 1; | 4298 *num_written = 1; |
| 4297 if (params) { | 4299 if (params) { |
| 4298 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 4300 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
| 4299 if (unit.bound_texture_rectangle_arb) { | 4301 if (unit.bound_texture_rectangle_arb.get()) { |
| 4300 *params = unit.bound_texture_rectangle_arb->client_id(); | 4302 *params = unit.bound_texture_rectangle_arb->client_id(); |
| 4301 } else { | 4303 } else { |
| 4302 *params = 0; | 4304 *params = 0; |
| 4303 } | 4305 } |
| 4304 } | 4306 } |
| 4305 return true; | 4307 return true; |
| 4306 case GL_UNPACK_FLIP_Y_CHROMIUM: | 4308 case GL_UNPACK_FLIP_Y_CHROMIUM: |
| 4307 *num_written = 1; | 4309 *num_written = 1; |
| 4308 if (params) { | 4310 if (params) { |
| 4309 params[0] = unpack_flip_y_; | 4311 params[0] = unpack_flip_y_; |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4750 } | 4752 } |
| 4751 service_id = renderbuffer->service_id(); | 4753 service_id = renderbuffer->service_id(); |
| 4752 } | 4754 } |
| 4753 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); | 4755 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); |
| 4754 glFramebufferRenderbufferEXT( | 4756 glFramebufferRenderbufferEXT( |
| 4755 target, attachment, renderbuffertarget, service_id); | 4757 target, attachment, renderbuffertarget, service_id); |
| 4756 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); | 4758 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); |
| 4757 if (error == GL_NO_ERROR) { | 4759 if (error == GL_NO_ERROR) { |
| 4758 framebuffer->AttachRenderbuffer(attachment, renderbuffer); | 4760 framebuffer->AttachRenderbuffer(attachment, renderbuffer); |
| 4759 } | 4761 } |
| 4760 if (framebuffer == state_.bound_draw_framebuffer) { | 4762 if (framebuffer == state_.bound_draw_framebuffer.get()) { |
| 4761 clear_state_dirty_ = true; | 4763 clear_state_dirty_ = true; |
| 4762 } | 4764 } |
| 4763 OnFboChanged(); | 4765 OnFboChanged(); |
| 4764 } | 4766 } |
| 4765 | 4767 |
| 4766 void GLES2DecoderImpl::DoDisable(GLenum cap) { | 4768 void GLES2DecoderImpl::DoDisable(GLenum cap) { |
| 4767 if (SetCapabilityState(cap, false)) { | 4769 if (SetCapabilityState(cap, false)) { |
| 4768 glDisable(cap); | 4770 glDisable(cap); |
| 4769 } | 4771 } |
| 4770 } | 4772 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4895 "glFramebufferTexture2D", "level out of range"); | 4897 "glFramebufferTexture2D", "level out of range"); |
| 4896 return; | 4898 return; |
| 4897 } | 4899 } |
| 4898 | 4900 |
| 4899 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferTexture2D"); | 4901 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferTexture2D"); |
| 4900 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level); | 4902 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level); |
| 4901 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferTexture2D"); | 4903 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferTexture2D"); |
| 4902 if (error == GL_NO_ERROR) { | 4904 if (error == GL_NO_ERROR) { |
| 4903 framebuffer->AttachTexture(attachment, texture_ref, textarget, level); | 4905 framebuffer->AttachTexture(attachment, texture_ref, textarget, level); |
| 4904 } | 4906 } |
| 4905 if (framebuffer == state_.bound_draw_framebuffer) { | 4907 if (framebuffer == state_.bound_draw_framebuffer.get()) { |
| 4906 clear_state_dirty_ = true; | 4908 clear_state_dirty_ = true; |
| 4907 } | 4909 } |
| 4908 OnFboChanged(); | 4910 OnFboChanged(); |
| 4909 } | 4911 } |
| 4910 | 4912 |
| 4911 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( | 4913 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( |
| 4912 GLenum target, GLenum attachment, GLenum pname, GLint* params) { | 4914 GLenum target, GLenum attachment, GLenum pname, GLint* params) { |
| 4913 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 4915 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
| 4914 if (!framebuffer) { | 4916 if (!framebuffer) { |
| 4915 LOCAL_SET_GL_ERROR( | 4917 LOCAL_SET_GL_ERROR( |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5102 Program* program = GetProgramInfoNotShader( | 5104 Program* program = GetProgramInfoNotShader( |
| 5103 program_id, "glLinkProgram"); | 5105 program_id, "glLinkProgram"); |
| 5104 if (!program) { | 5106 if (!program) { |
| 5105 return; | 5107 return; |
| 5106 } | 5108 } |
| 5107 | 5109 |
| 5108 LogClientServiceForInfo(program, program_id, "glLinkProgram"); | 5110 LogClientServiceForInfo(program, program_id, "glLinkProgram"); |
| 5109 ShaderTranslator* vertex_translator = NULL; | 5111 ShaderTranslator* vertex_translator = NULL; |
| 5110 ShaderTranslator* fragment_translator = NULL; | 5112 ShaderTranslator* fragment_translator = NULL; |
| 5111 if (use_shader_translator_) { | 5113 if (use_shader_translator_) { |
| 5112 vertex_translator = vertex_translator_; | 5114 vertex_translator = vertex_translator_.get(); |
| 5113 fragment_translator = fragment_translator_; | 5115 fragment_translator = fragment_translator_.get(); |
| 5114 } | 5116 } |
| 5115 if (program->Link(shader_manager(), | 5117 if (program->Link(shader_manager(), |
| 5116 vertex_translator, | 5118 vertex_translator, |
| 5117 fragment_translator, | 5119 fragment_translator, |
| 5118 feature_info_, | 5120 feature_info_.get(), |
| 5119 shader_cache_callback_)) { | 5121 shader_cache_callback_)) { |
| 5120 if (program == state_.current_program.get()) { | 5122 if (program == state_.current_program.get()) { |
| 5121 if (workarounds().use_current_program_after_successful_link) { | 5123 if (workarounds().use_current_program_after_successful_link) { |
| 5122 glUseProgram(program->service_id()); | 5124 glUseProgram(program->service_id()); |
| 5123 } | 5125 } |
| 5124 program_manager()->ClearUniforms(program); | 5126 program_manager()->ClearUniforms(program); |
| 5125 } | 5127 } |
| 5126 } | 5128 } |
| 5127 }; | 5129 }; |
| 5128 | 5130 |
| 5129 void GLES2DecoderImpl::DoTexParameterf( | 5131 void GLES2DecoderImpl::DoTexParameterf( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5171 LOCAL_SET_GL_ERROR( | 5173 LOCAL_SET_GL_ERROR( |
| 5172 GL_INVALID_VALUE, "glTexParameteriv", "unknown texture"); | 5174 GL_INVALID_VALUE, "glTexParameteriv", "unknown texture"); |
| 5173 return; | 5175 return; |
| 5174 } | 5176 } |
| 5175 | 5177 |
| 5176 texture_manager()->SetParameter( | 5178 texture_manager()->SetParameter( |
| 5177 "glTexParameteriv", GetErrorState(), texture, pname, *params); | 5179 "glTexParameteriv", GetErrorState(), texture, pname, *params); |
| 5178 } | 5180 } |
| 5179 | 5181 |
| 5180 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { | 5182 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { |
| 5181 if (!state_.current_program) { | 5183 if (!state_.current_program.get()) { |
| 5182 // The program does not exist. | 5184 // The program does not exist. |
| 5183 LOCAL_SET_GL_ERROR( | 5185 LOCAL_SET_GL_ERROR( |
| 5184 GL_INVALID_OPERATION, function_name, "no program in use"); | 5186 GL_INVALID_OPERATION, function_name, "no program in use"); |
| 5185 return false; | 5187 return false; |
| 5186 } | 5188 } |
| 5187 if (!state_.current_program->InUse()) { | 5189 if (!state_.current_program->InUse()) { |
| 5188 LOCAL_SET_GL_ERROR( | 5190 LOCAL_SET_GL_ERROR( |
| 5189 GL_INVALID_OPERATION, function_name, "program not linked"); | 5191 GL_INVALID_OPERATION, function_name, "program not linked"); |
| 5190 return false; | 5192 return false; |
| 5191 } | 5193 } |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5567 return; | 5569 return; |
| 5568 } | 5570 } |
| 5569 if (!program->IsValid()) { | 5571 if (!program->IsValid()) { |
| 5570 // Program was not linked successfully. (ie, glLinkProgram) | 5572 // Program was not linked successfully. (ie, glLinkProgram) |
| 5571 LOCAL_SET_GL_ERROR( | 5573 LOCAL_SET_GL_ERROR( |
| 5572 GL_INVALID_OPERATION, "glUseProgram", "program not linked"); | 5574 GL_INVALID_OPERATION, "glUseProgram", "program not linked"); |
| 5573 return; | 5575 return; |
| 5574 } | 5576 } |
| 5575 service_id = program->service_id(); | 5577 service_id = program->service_id(); |
| 5576 } | 5578 } |
| 5577 if (state_.current_program) { | 5579 if (state_.current_program.get()) { |
| 5578 program_manager()->UnuseProgram(shader_manager(), state_.current_program); | 5580 program_manager()->UnuseProgram(shader_manager(), |
| 5581 state_.current_program.get()); |
| 5579 } | 5582 } |
| 5580 state_.current_program = program; | 5583 state_.current_program = program; |
| 5581 LogClientServiceMapping("glUseProgram", program_id, service_id); | 5584 LogClientServiceMapping("glUseProgram", program_id, service_id); |
| 5582 glUseProgram(service_id); | 5585 glUseProgram(service_id); |
| 5583 if (state_.current_program) { | 5586 if (state_.current_program.get()) { |
| 5584 program_manager()->UseProgram(state_.current_program); | 5587 program_manager()->UseProgram(state_.current_program.get()); |
| 5585 } | 5588 } |
| 5586 } | 5589 } |
| 5587 | 5590 |
| 5588 void GLES2DecoderImpl::RenderWarning( | 5591 void GLES2DecoderImpl::RenderWarning( |
| 5589 const char* filename, int line, const std::string& msg) { | 5592 const char* filename, int line, const std::string& msg) { |
| 5590 logger_.LogMessage(filename, line, std::string("RENDER WARNING: ") + msg); | 5593 logger_.LogMessage(filename, line, std::string("RENDER WARNING: ") + msg); |
| 5591 } | 5594 } |
| 5592 | 5595 |
| 5593 void GLES2DecoderImpl::PerformanceWarning( | 5596 void GLES2DecoderImpl::PerformanceWarning( |
| 5594 const char* filename, int line, const std::string& msg) { | 5597 const char* filename, int line, const std::string& msg) { |
| 5595 logger_.LogMessage(filename, line, | 5598 logger_.LogMessage(filename, line, |
| 5596 std::string("PERFORMANCE WARNING: ") + msg); | 5599 std::string("PERFORMANCE WARNING: ") + msg); |
| 5597 } | 5600 } |
| 5598 | 5601 |
| 5599 void GLES2DecoderImpl::ForceCompileShaderIfPending(Shader* shader) { | 5602 void GLES2DecoderImpl::ForceCompileShaderIfPending(Shader* shader) { |
| 5600 if (shader->compilation_status() == | 5603 if (shader->compilation_status() == |
| 5601 Shader::PENDING_DEFERRED_COMPILE) { | 5604 Shader::PENDING_DEFERRED_COMPILE) { |
| 5602 ShaderTranslator* translator = NULL; | 5605 ShaderTranslator* translator = NULL; |
| 5603 if (use_shader_translator_) { | 5606 if (use_shader_translator_) { |
| 5604 translator = shader->shader_type() == GL_VERTEX_SHADER ? | 5607 translator = shader->shader_type() == GL_VERTEX_SHADER ? |
| 5605 vertex_translator_.get() : fragment_translator_.get(); | 5608 vertex_translator_.get() : fragment_translator_.get(); |
| 5606 } | 5609 } |
| 5607 // We know there will be no errors, because we only defer compilation on | 5610 // We know there will be no errors, because we only defer compilation on |
| 5608 // shaders that were previously compiled successfully. | 5611 // shaders that were previously compiled successfully. |
| 5609 program_manager()->ForceCompileShader(shader->deferred_compilation_source(), | 5612 program_manager()->ForceCompileShader(shader->deferred_compilation_source(), |
| 5610 shader, | 5613 shader, |
| 5611 translator, | 5614 translator, |
| 5612 feature_info_); | 5615 feature_info_.get()); |
| 5613 } | 5616 } |
| 5614 } | 5617 } |
| 5615 | 5618 |
| 5616 bool GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures() { | 5619 bool GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures() { |
| 5617 DCHECK(state_.current_program); | 5620 DCHECK(state_.current_program.get()); |
| 5618 // Only check if there are some unrenderable textures. | 5621 // Only check if there are some unrenderable textures. |
| 5619 if (!texture_manager()->HaveUnrenderableTextures()) { | 5622 if (!texture_manager()->HaveUnrenderableTextures()) { |
| 5620 return false; | 5623 return false; |
| 5621 } | 5624 } |
| 5622 | 5625 |
| 5623 bool textures_set = false; | 5626 bool textures_set = false; |
| 5624 const Program::SamplerIndices& sampler_indices = | 5627 const Program::SamplerIndices& sampler_indices = |
| 5625 state_.current_program->sampler_indices(); | 5628 state_.current_program->sampler_indices(); |
| 5626 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 5629 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
| 5627 const Program::UniformInfo* uniform_info = | 5630 const Program::UniformInfo* uniform_info = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5647 "'texture complete'"); | 5650 "'texture complete'"); |
| 5648 } | 5651 } |
| 5649 } | 5652 } |
| 5650 // else: should this be an error? | 5653 // else: should this be an error? |
| 5651 } | 5654 } |
| 5652 } | 5655 } |
| 5653 return textures_set; | 5656 return textures_set; |
| 5654 } | 5657 } |
| 5655 | 5658 |
| 5656 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() { | 5659 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() { |
| 5657 DCHECK(state_.current_program); | 5660 DCHECK(state_.current_program.get()); |
| 5658 const Program::SamplerIndices& sampler_indices = | 5661 const Program::SamplerIndices& sampler_indices = |
| 5659 state_.current_program->sampler_indices(); | 5662 state_.current_program->sampler_indices(); |
| 5660 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 5663 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
| 5661 const Program::UniformInfo* uniform_info = | 5664 const Program::UniformInfo* uniform_info = |
| 5662 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 5665 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
| 5663 DCHECK(uniform_info); | 5666 DCHECK(uniform_info); |
| 5664 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 5667 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
| 5665 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 5668 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
| 5666 if (texture_unit_index < state_.texture_units.size()) { | 5669 if (texture_unit_index < state_.texture_units.size()) { |
| 5667 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 5670 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
| 5668 TextureRef* texture_ref = uniform_info->type == GL_SAMPLER_2D ? | 5671 TextureRef* texture_ref = |
| 5669 texture_unit.bound_texture_2d : | 5672 uniform_info->type == GL_SAMPLER_2D |
| 5670 texture_unit.bound_texture_cube_map; | 5673 ? texture_unit.bound_texture_2d.get() |
| 5674 : texture_unit.bound_texture_cube_map.get(); |
| 5671 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { | 5675 if (!texture_ref || !texture_manager()->CanRender(texture_ref)) { |
| 5672 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 5676 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
| 5673 // Get the texture_ref info that was previously bound here. | 5677 // Get the texture_ref info that was previously bound here. |
| 5674 texture_ref = texture_unit.bind_target == GL_TEXTURE_2D ? | 5678 texture_ref = texture_unit.bind_target == GL_TEXTURE_2D |
| 5675 texture_unit.bound_texture_2d : | 5679 ? texture_unit.bound_texture_2d.get() |
| 5676 texture_unit.bound_texture_cube_map; | 5680 : texture_unit.bound_texture_cube_map.get(); |
| 5677 glBindTexture(texture_unit.bind_target, | 5681 glBindTexture(texture_unit.bind_target, |
| 5678 texture_ref ? texture_ref->service_id() : 0); | 5682 texture_ref ? texture_ref->service_id() : 0); |
| 5679 } | 5683 } |
| 5680 } | 5684 } |
| 5681 } | 5685 } |
| 5682 } | 5686 } |
| 5683 // Set the active texture back to whatever the user had it as. | 5687 // Set the active texture back to whatever the user had it as. |
| 5684 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); | 5688 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); |
| 5685 } | 5689 } |
| 5686 | 5690 |
| 5687 bool GLES2DecoderImpl::ClearUnclearedTextures() { | 5691 bool GLES2DecoderImpl::ClearUnclearedTextures() { |
| 5688 // Only check if there are some uncleared textures. | 5692 // Only check if there are some uncleared textures. |
| 5689 if (!texture_manager()->HaveUnsafeTextures()) { | 5693 if (!texture_manager()->HaveUnsafeTextures()) { |
| 5690 return true; | 5694 return true; |
| 5691 } | 5695 } |
| 5692 | 5696 |
| 5693 // 1: Check all textures we are about to render with. | 5697 // 1: Check all textures we are about to render with. |
| 5694 if (state_.current_program) { | 5698 if (state_.current_program.get()) { |
| 5695 const Program::SamplerIndices& sampler_indices = | 5699 const Program::SamplerIndices& sampler_indices = |
| 5696 state_.current_program->sampler_indices(); | 5700 state_.current_program->sampler_indices(); |
| 5697 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 5701 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
| 5698 const Program::UniformInfo* uniform_info = | 5702 const Program::UniformInfo* uniform_info = |
| 5699 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 5703 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
| 5700 DCHECK(uniform_info); | 5704 DCHECK(uniform_info); |
| 5701 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 5705 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
| 5702 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 5706 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
| 5703 if (texture_unit_index < state_.texture_units.size()) { | 5707 if (texture_unit_index < state_.texture_units.size()) { |
| 5704 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 5708 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
| 5705 TextureRef* texture_ref = | 5709 TextureRef* texture_ref = |
| 5706 texture_unit.GetInfoForSamplerType(uniform_info->type); | 5710 texture_unit.GetInfoForSamplerType(uniform_info->type); |
| 5707 if (texture_ref && !texture_ref->texture()->SafeToRenderFrom()) { | 5711 if (texture_ref && !texture_ref->texture()->SafeToRenderFrom()) { |
| 5708 if (!texture_manager()->ClearRenderableLevels(this, texture_ref)) { | 5712 if (!texture_manager()->ClearRenderableLevels(this, texture_ref)) { |
| 5709 return false; | 5713 return false; |
| 5710 } | 5714 } |
| 5711 } | 5715 } |
| 5712 } | 5716 } |
| 5713 } | 5717 } |
| 5714 } | 5718 } |
| 5715 } | 5719 } |
| 5716 return true; | 5720 return true; |
| 5717 } | 5721 } |
| 5718 | 5722 |
| 5719 bool GLES2DecoderImpl::IsDrawValid( | 5723 bool GLES2DecoderImpl::IsDrawValid( |
| 5720 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount) { | 5724 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount) { |
| 5721 // NOTE: We specifically do not check current_program->IsValid() because | 5725 // NOTE: We specifically do not check current_program->IsValid() because |
| 5722 // it could never be invalid since glUseProgram would have failed. While | 5726 // it could never be invalid since glUseProgram would have failed. While |
| 5723 // glLinkProgram could later mark the program as invalid the previous | 5727 // glLinkProgram could later mark the program as invalid the previous |
| 5724 // valid program will still function if it is still the current program. | 5728 // valid program will still function if it is still the current program. |
| 5725 if (!state_.current_program) { | 5729 if (!state_.current_program.get()) { |
| 5726 // The program does not exist. | 5730 // The program does not exist. |
| 5727 // But GL says no ERROR. | 5731 // But GL says no ERROR. |
| 5728 LOCAL_RENDER_WARNING("Drawing with no current shader program."); | 5732 LOCAL_RENDER_WARNING("Drawing with no current shader program."); |
| 5729 return false; | 5733 return false; |
| 5730 } | 5734 } |
| 5731 | 5735 |
| 5732 return state_.vertex_attrib_manager->ValidateBindings( | 5736 return state_.vertex_attrib_manager |
| 5733 function_name, | 5737 ->ValidateBindings(function_name, |
| 5734 this, | 5738 this, |
| 5735 feature_info_.get(), | 5739 feature_info_.get(), |
| 5736 state_.current_program, | 5740 state_.current_program.get(), |
| 5737 max_vertex_accessed, | 5741 max_vertex_accessed, |
| 5738 primcount); | 5742 primcount); |
| 5739 } | 5743 } |
| 5740 | 5744 |
| 5741 bool GLES2DecoderImpl::SimulateAttrib0( | 5745 bool GLES2DecoderImpl::SimulateAttrib0( |
| 5742 const char* function_name, GLuint max_vertex_accessed, bool* simulated) { | 5746 const char* function_name, GLuint max_vertex_accessed, bool* simulated) { |
| 5743 DCHECK(simulated); | 5747 DCHECK(simulated); |
| 5744 *simulated = false; | 5748 *simulated = false; |
| 5745 | 5749 |
| 5746 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) | 5750 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) |
| 5747 return true; | 5751 return true; |
| 5748 | 5752 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5815 const void* ptr = reinterpret_cast<const void*>(attrib->offset()); | 5819 const void* ptr = reinterpret_cast<const void*>(attrib->offset()); |
| 5816 Buffer* buffer = attrib->buffer(); | 5820 Buffer* buffer = attrib->buffer(); |
| 5817 glBindBuffer(GL_ARRAY_BUFFER, buffer ? buffer->service_id() : 0); | 5821 glBindBuffer(GL_ARRAY_BUFFER, buffer ? buffer->service_id() : 0); |
| 5818 glVertexAttribPointer( | 5822 glVertexAttribPointer( |
| 5819 attrib_index, attrib->size(), attrib->type(), attrib->normalized(), | 5823 attrib_index, attrib->size(), attrib->type(), attrib->normalized(), |
| 5820 attrib->gl_stride(), ptr); | 5824 attrib->gl_stride(), ptr); |
| 5821 if (attrib->divisor()) | 5825 if (attrib->divisor()) |
| 5822 glVertexAttribDivisorANGLE(attrib_index, attrib->divisor()); | 5826 glVertexAttribDivisorANGLE(attrib_index, attrib->divisor()); |
| 5823 glBindBuffer( | 5827 glBindBuffer( |
| 5824 GL_ARRAY_BUFFER, | 5828 GL_ARRAY_BUFFER, |
| 5825 state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0); | 5829 state_.bound_array_buffer.get() ? state_.bound_array_buffer->service_id() |
| 5830 : 0); |
| 5826 | 5831 |
| 5827 // Never touch vertex attribute 0's state (in particular, never | 5832 // Never touch vertex attribute 0's state (in particular, never |
| 5828 // disable it) when running on desktop GL because it will never be | 5833 // disable it) when running on desktop GL because it will never be |
| 5829 // re-enabled. | 5834 // re-enabled. |
| 5830 if (attrib_index != 0 || | 5835 if (attrib_index != 0 || |
| 5831 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { | 5836 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { |
| 5832 if (attrib->enabled()) { | 5837 if (attrib->enabled()) { |
| 5833 glEnableVertexAttribArray(attrib_index); | 5838 glEnableVertexAttribArray(attrib_index); |
| 5834 } else { | 5839 } else { |
| 5835 glDisableVertexAttribArray(attrib_index); | 5840 glDisableVertexAttribArray(attrib_index); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5946 } | 5951 } |
| 5947 *simulated = true; | 5952 *simulated = true; |
| 5948 return true; | 5953 return true; |
| 5949 } | 5954 } |
| 5950 | 5955 |
| 5951 void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() { | 5956 void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() { |
| 5952 // There's no need to call glVertexAttribPointer because we shadow all the | 5957 // There's no need to call glVertexAttribPointer because we shadow all the |
| 5953 // settings and passing GL_FIXED to it will not work. | 5958 // settings and passing GL_FIXED to it will not work. |
| 5954 glBindBuffer( | 5959 glBindBuffer( |
| 5955 GL_ARRAY_BUFFER, | 5960 GL_ARRAY_BUFFER, |
| 5956 state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0); | 5961 state_.bound_array_buffer.get() ? state_.bound_array_buffer->service_id() |
| 5962 : 0); |
| 5957 } | 5963 } |
| 5958 | 5964 |
| 5959 error::Error GLES2DecoderImpl::DoDrawArrays( | 5965 error::Error GLES2DecoderImpl::DoDrawArrays( |
| 5960 const char* function_name, | 5966 const char* function_name, |
| 5961 bool instanced, | 5967 bool instanced, |
| 5962 GLenum mode, | 5968 GLenum mode, |
| 5963 GLint first, | 5969 GLint first, |
| 5964 GLsizei count, | 5970 GLsizei count, |
| 5965 GLsizei primcount) { | 5971 GLsizei primcount) { |
| 5966 if (ShouldDeferDraws()) | 5972 if (ShouldDeferDraws()) |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6266 Shader* shader = GetShaderInfoNotProgram(client_id, "glCompileShader"); | 6272 Shader* shader = GetShaderInfoNotProgram(client_id, "glCompileShader"); |
| 6267 if (!shader) { | 6273 if (!shader) { |
| 6268 return; | 6274 return; |
| 6269 } | 6275 } |
| 6270 ShaderTranslator* translator = NULL; | 6276 ShaderTranslator* translator = NULL; |
| 6271 if (use_shader_translator_) { | 6277 if (use_shader_translator_) { |
| 6272 translator = shader->shader_type() == GL_VERTEX_SHADER ? | 6278 translator = shader->shader_type() == GL_VERTEX_SHADER ? |
| 6273 vertex_translator_.get() : fragment_translator_.get(); | 6279 vertex_translator_.get() : fragment_translator_.get(); |
| 6274 } | 6280 } |
| 6275 | 6281 |
| 6276 program_manager()->DoCompileShader(shader, translator, feature_info_); | 6282 program_manager()->DoCompileShader(shader, translator, feature_info_.get()); |
| 6277 }; | 6283 }; |
| 6278 | 6284 |
| 6279 void GLES2DecoderImpl::DoGetShaderiv( | 6285 void GLES2DecoderImpl::DoGetShaderiv( |
| 6280 GLuint shader_id, GLenum pname, GLint* params) { | 6286 GLuint shader_id, GLenum pname, GLint* params) { |
| 6281 Shader* shader = GetShaderInfoNotProgram(shader_id, "glGetShaderiv"); | 6287 Shader* shader = GetShaderInfoNotProgram(shader_id, "glGetShaderiv"); |
| 6282 if (!shader) { | 6288 if (!shader) { |
| 6283 return; | 6289 return; |
| 6284 } | 6290 } |
| 6285 switch (pname) { | 6291 switch (pname) { |
| 6286 case GL_SHADER_SOURCE_LENGTH: | 6292 case GL_SHADER_SOURCE_LENGTH: |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6607 | 6613 |
| 6608 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { | 6614 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { |
| 6609 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { | 6615 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { |
| 6610 glVertexAttrib4fv(index, v); | 6616 glVertexAttrib4fv(index, v); |
| 6611 } | 6617 } |
| 6612 } | 6618 } |
| 6613 | 6619 |
| 6614 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( | 6620 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( |
| 6615 uint32 immediate_data_size, const cmds::VertexAttribPointer& c) { | 6621 uint32 immediate_data_size, const cmds::VertexAttribPointer& c) { |
| 6616 | 6622 |
| 6617 if (!state_.bound_array_buffer || state_.bound_array_buffer->IsDeleted()) { | 6623 if (!state_.bound_array_buffer.get() || |
| 6618 if (state_.vertex_attrib_manager == default_vertex_attrib_manager_) { | 6624 state_.bound_array_buffer->IsDeleted()) { |
| 6625 if (state_.vertex_attrib_manager.get() == |
| 6626 default_vertex_attrib_manager_.get()) { |
| 6619 LOCAL_SET_GL_ERROR( | 6627 LOCAL_SET_GL_ERROR( |
| 6620 GL_INVALID_VALUE, "glVertexAttribPointer", "no array buffer bound"); | 6628 GL_INVALID_VALUE, "glVertexAttribPointer", "no array buffer bound"); |
| 6621 return error::kNoError; | 6629 return error::kNoError; |
| 6622 } else if (c.offset != 0) { | 6630 } else if (c.offset != 0) { |
| 6623 LOCAL_SET_GL_ERROR( | 6631 LOCAL_SET_GL_ERROR( |
| 6624 GL_INVALID_VALUE, | 6632 GL_INVALID_VALUE, |
| 6625 "glVertexAttribPointer", "client side arrays are not allowed"); | 6633 "glVertexAttribPointer", "client side arrays are not allowed"); |
| 6626 return error::kNoError; | 6634 return error::kNoError; |
| 6627 } | 6635 } |
| 6628 } | 6636 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6670 GL_INVALID_OPERATION, | 6678 GL_INVALID_OPERATION, |
| 6671 "glVertexAttribPointer", "offset not valid for type"); | 6679 "glVertexAttribPointer", "offset not valid for type"); |
| 6672 return error::kNoError; | 6680 return error::kNoError; |
| 6673 } | 6681 } |
| 6674 if (stride % component_size > 0) { | 6682 if (stride % component_size > 0) { |
| 6675 LOCAL_SET_GL_ERROR( | 6683 LOCAL_SET_GL_ERROR( |
| 6676 GL_INVALID_OPERATION, | 6684 GL_INVALID_OPERATION, |
| 6677 "glVertexAttribPointer", "stride not valid for type"); | 6685 "glVertexAttribPointer", "stride not valid for type"); |
| 6678 return error::kNoError; | 6686 return error::kNoError; |
| 6679 } | 6687 } |
| 6680 state_.vertex_attrib_manager->SetAttribInfo( | 6688 state_.vertex_attrib_manager |
| 6681 indx, | 6689 ->SetAttribInfo(indx, |
| 6682 state_.bound_array_buffer, | 6690 state_.bound_array_buffer.get(), |
| 6683 size, | 6691 size, |
| 6684 type, | 6692 type, |
| 6685 normalized, | 6693 normalized, |
| 6686 stride, | 6694 stride, |
| 6687 stride != 0 ? stride : component_size * size, | 6695 stride != 0 ? stride : component_size * size, |
| 6688 offset); | 6696 offset); |
| 6689 if (type != GL_FIXED) { | 6697 if (type != GL_FIXED) { |
| 6690 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); | 6698 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); |
| 6691 } | 6699 } |
| 6692 return error::kNoError; | 6700 return error::kNoError; |
| 6693 } | 6701 } |
| 6694 | 6702 |
| 6695 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, | 6703 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, |
| 6696 GLsizei height) { | 6704 GLsizei height) { |
| 6697 state_.viewport_x = x; | 6705 state_.viewport_x = x; |
| 6698 state_.viewport_y = y; | 6706 state_.viewport_y = y; |
| (...skipping 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9070 } | 9078 } |
| 9071 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT | 9079 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT |
| 9072 return true; | 9080 return true; |
| 9073 } | 9081 } |
| 9074 | 9082 |
| 9075 void GLES2DecoderImpl::DeleteQueriesEXTHelper( | 9083 void GLES2DecoderImpl::DeleteQueriesEXTHelper( |
| 9076 GLsizei n, const GLuint* client_ids) { | 9084 GLsizei n, const GLuint* client_ids) { |
| 9077 for (GLsizei ii = 0; ii < n; ++ii) { | 9085 for (GLsizei ii = 0; ii < n; ++ii) { |
| 9078 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]); | 9086 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]); |
| 9079 if (query && !query->IsDeleted()) { | 9087 if (query && !query->IsDeleted()) { |
| 9080 if (query == state_.current_query) { | 9088 if (query == state_.current_query.get()) { |
| 9081 state_.current_query = NULL; | 9089 state_.current_query = NULL; |
| 9082 } | 9090 } |
| 9083 query->Destroy(true); | 9091 query->Destroy(true); |
| 9084 query_manager_->RemoveQuery(client_ids[ii]); | 9092 query_manager_->RemoveQuery(client_ids[ii]); |
| 9085 } | 9093 } |
| 9086 } | 9094 } |
| 9087 } | 9095 } |
| 9088 | 9096 |
| 9089 bool GLES2DecoderImpl::ProcessPendingQueries() { | 9097 bool GLES2DecoderImpl::ProcessPendingQueries() { |
| 9090 if (query_manager_.get() == NULL) { | 9098 if (query_manager_.get() == NULL) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9123 default: | 9131 default: |
| 9124 if (!features().occlusion_query_boolean) { | 9132 if (!features().occlusion_query_boolean) { |
| 9125 LOCAL_SET_GL_ERROR( | 9133 LOCAL_SET_GL_ERROR( |
| 9126 GL_INVALID_OPERATION, "glBeginQueryEXT", | 9134 GL_INVALID_OPERATION, "glBeginQueryEXT", |
| 9127 "not enabled for occlusion queries"); | 9135 "not enabled for occlusion queries"); |
| 9128 return error::kNoError; | 9136 return error::kNoError; |
| 9129 } | 9137 } |
| 9130 break; | 9138 break; |
| 9131 } | 9139 } |
| 9132 | 9140 |
| 9133 if (state_.current_query) { | 9141 if (state_.current_query.get()) { |
| 9134 LOCAL_SET_GL_ERROR( | 9142 LOCAL_SET_GL_ERROR( |
| 9135 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress"); | 9143 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress"); |
| 9136 return error::kNoError; | 9144 return error::kNoError; |
| 9137 } | 9145 } |
| 9138 | 9146 |
| 9139 if (client_id == 0) { | 9147 if (client_id == 0) { |
| 9140 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0"); | 9148 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0"); |
| 9141 return error::kNoError; | 9149 return error::kNoError; |
| 9142 } | 9150 } |
| 9143 | 9151 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9181 | 9189 |
| 9182 state_.current_query = query; | 9190 state_.current_query = query; |
| 9183 return error::kNoError; | 9191 return error::kNoError; |
| 9184 } | 9192 } |
| 9185 | 9193 |
| 9186 error::Error GLES2DecoderImpl::HandleEndQueryEXT( | 9194 error::Error GLES2DecoderImpl::HandleEndQueryEXT( |
| 9187 uint32 immediate_data_size, const cmds::EndQueryEXT& c) { | 9195 uint32 immediate_data_size, const cmds::EndQueryEXT& c) { |
| 9188 GLenum target = static_cast<GLenum>(c.target); | 9196 GLenum target = static_cast<GLenum>(c.target); |
| 9189 uint32 submit_count = static_cast<GLuint>(c.submit_count); | 9197 uint32 submit_count = static_cast<GLuint>(c.submit_count); |
| 9190 | 9198 |
| 9191 if (!state_.current_query) { | 9199 if (!state_.current_query.get()) { |
| 9192 LOCAL_SET_GL_ERROR( | 9200 LOCAL_SET_GL_ERROR( |
| 9193 GL_INVALID_OPERATION, "glEndQueryEXT", "No active query"); | 9201 GL_INVALID_OPERATION, "glEndQueryEXT", "No active query"); |
| 9194 return error::kNoError; | 9202 return error::kNoError; |
| 9195 } | 9203 } |
| 9196 if (state_.current_query->target() != target) { | 9204 if (state_.current_query->target() != target) { |
| 9197 LOCAL_SET_GL_ERROR( | 9205 LOCAL_SET_GL_ERROR( |
| 9198 GL_INVALID_OPERATION, | 9206 GL_INVALID_OPERATION, |
| 9199 "glEndQueryEXT", "target does not match active query"); | 9207 "glEndQueryEXT", "target does not match active query"); |
| 9200 return error::kNoError; | 9208 return error::kNoError; |
| 9201 } | 9209 } |
| 9202 | 9210 |
| 9203 if (!query_manager_->EndQuery(state_.current_query, submit_count)) { | 9211 if (!query_manager_->EndQuery(state_.current_query.get(), submit_count)) { |
| 9204 return error::kOutOfBounds; | 9212 return error::kOutOfBounds; |
| 9205 } | 9213 } |
| 9206 | 9214 |
| 9207 query_manager_->ProcessPendingTransferQueries(); | 9215 query_manager_->ProcessPendingTransferQueries(); |
| 9208 | 9216 |
| 9209 state_.current_query = NULL; | 9217 state_.current_query = NULL; |
| 9210 return error::kNoError; | 9218 return error::kNoError; |
| 9211 } | 9219 } |
| 9212 | 9220 |
| 9213 bool GLES2DecoderImpl::GenVertexArraysOESHelper( | 9221 bool GLES2DecoderImpl::GenVertexArraysOESHelper( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 9234 | 9242 |
| 9235 return true; | 9243 return true; |
| 9236 } | 9244 } |
| 9237 | 9245 |
| 9238 void GLES2DecoderImpl::DeleteVertexArraysOESHelper( | 9246 void GLES2DecoderImpl::DeleteVertexArraysOESHelper( |
| 9239 GLsizei n, const GLuint* client_ids) { | 9247 GLsizei n, const GLuint* client_ids) { |
| 9240 for (GLsizei ii = 0; ii < n; ++ii) { | 9248 for (GLsizei ii = 0; ii < n; ++ii) { |
| 9241 VertexAttribManager* vao = | 9249 VertexAttribManager* vao = |
| 9242 GetVertexAttribManager(client_ids[ii]); | 9250 GetVertexAttribManager(client_ids[ii]); |
| 9243 if (vao && !vao->IsDeleted()) { | 9251 if (vao && !vao->IsDeleted()) { |
| 9244 if (state_.vertex_attrib_manager == vao) { | 9252 if (state_.vertex_attrib_manager.get() == vao) { |
| 9245 state_.vertex_attrib_manager = default_vertex_attrib_manager_; | 9253 state_.vertex_attrib_manager = default_vertex_attrib_manager_; |
| 9246 } | 9254 } |
| 9247 RemoveVertexAttribManager(client_ids[ii]); | 9255 RemoveVertexAttribManager(client_ids[ii]); |
| 9248 } | 9256 } |
| 9249 } | 9257 } |
| 9250 } | 9258 } |
| 9251 | 9259 |
| 9252 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) { | 9260 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) { |
| 9253 VertexAttribManager* vao = NULL; | 9261 VertexAttribManager* vao = NULL; |
| 9254 GLuint service_id = 0; | 9262 GLuint service_id = 0; |
| 9255 if (client_id != 0) { | 9263 if (client_id != 0) { |
| 9256 vao = GetVertexAttribManager(client_id); | 9264 vao = GetVertexAttribManager(client_id); |
| 9257 if (!vao) { | 9265 if (!vao) { |
| 9258 // Unlike most Bind* methods, the spec explicitly states that VertexArray | 9266 // Unlike most Bind* methods, the spec explicitly states that VertexArray |
| 9259 // only allows names that have been previously generated. As such, we do | 9267 // only allows names that have been previously generated. As such, we do |
| 9260 // not generate new names here. | 9268 // not generate new names here. |
| 9261 LOCAL_SET_GL_ERROR( | 9269 LOCAL_SET_GL_ERROR( |
| 9262 GL_INVALID_OPERATION, | 9270 GL_INVALID_OPERATION, |
| 9263 "glBindVertexArrayOES", "bad vertex array id."); | 9271 "glBindVertexArrayOES", "bad vertex array id."); |
| 9264 current_decoder_error_ = error::kNoError; | 9272 current_decoder_error_ = error::kNoError; |
| 9265 return; | 9273 return; |
| 9266 } else { | 9274 } else { |
| 9267 service_id = vao->service_id(); | 9275 service_id = vao->service_id(); |
| 9268 } | 9276 } |
| 9269 } else { | 9277 } else { |
| 9270 vao = default_vertex_attrib_manager_; | 9278 vao = default_vertex_attrib_manager_.get(); |
| 9271 } | 9279 } |
| 9272 | 9280 |
| 9273 // Only set the VAO state if it's changed | 9281 // Only set the VAO state if it's changed |
| 9274 if (state_.vertex_attrib_manager != vao) { | 9282 if (state_.vertex_attrib_manager.get() != vao) { |
| 9275 state_.vertex_attrib_manager = vao; | 9283 state_.vertex_attrib_manager = vao; |
| 9276 if (!features().native_vertex_array_object) { | 9284 if (!features().native_vertex_array_object) { |
| 9277 EmulateVertexArrayState(); | 9285 EmulateVertexArrayState(); |
| 9278 } else { | 9286 } else { |
| 9279 glBindVertexArrayOES(service_id); | 9287 glBindVertexArrayOES(service_id); |
| 9280 } | 9288 } |
| 9281 } | 9289 } |
| 9282 } | 9290 } |
| 9283 | 9291 |
| 9284 // Used when OES_vertex_array_object isn't natively supported | 9292 // Used when OES_vertex_array_object isn't natively supported |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9850 } | 9858 } |
| 9851 | 9859 |
| 9852 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, | 9860 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, |
| 9853 const GLbyte* mailbox) { | 9861 const GLbyte* mailbox) { |
| 9854 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", | 9862 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", |
| 9855 "context", logger_.GetLogPrefix(), | 9863 "context", logger_.GetLogPrefix(), |
| 9856 "mailbox[0]", static_cast<unsigned char>(mailbox[0])); | 9864 "mailbox[0]", static_cast<unsigned char>(mailbox[0])); |
| 9857 | 9865 |
| 9858 scoped_refptr<TextureRef> texture_ref = | 9866 scoped_refptr<TextureRef> texture_ref = |
| 9859 GetTextureInfoForTargetUnlessDefault(target); | 9867 GetTextureInfoForTargetUnlessDefault(target); |
| 9860 if (!texture_ref) { | 9868 if (!texture_ref.get()) { |
| 9861 LOCAL_SET_GL_ERROR( | 9869 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
| 9862 GL_INVALID_OPERATION, | 9870 "glConsumeTextureCHROMIUM", |
| 9863 "glConsumeTextureCHROMIUM", "unknown texture for target"); | 9871 "unknown texture for target"); |
| 9864 return; | 9872 return; |
| 9865 } | 9873 } |
| 9866 GLuint client_id = texture_ref->client_id(); | 9874 GLuint client_id = texture_ref->client_id(); |
| 9867 if (!client_id) { | 9875 if (!client_id) { |
| 9868 LOCAL_SET_GL_ERROR( | 9876 LOCAL_SET_GL_ERROR( |
| 9869 GL_INVALID_OPERATION, | 9877 GL_INVALID_OPERATION, |
| 9870 "glConsumeTextureCHROMIUM", "unknown texture for target"); | 9878 "glConsumeTextureCHROMIUM", "unknown texture for target"); |
| 9871 return; | 9879 return; |
| 9872 } | 9880 } |
| 9873 Texture* texture = | 9881 Texture* texture = |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10346 return error::kNoError; | 10354 return error::kNoError; |
| 10347 } | 10355 } |
| 10348 | 10356 |
| 10349 // Include the auto-generated part of this file. We split this because it means | 10357 // Include the auto-generated part of this file. We split this because it means |
| 10350 // we can easily edit the non-auto generated parts right here in this file | 10358 // we can easily edit the non-auto generated parts right here in this file |
| 10351 // instead of having to edit some template or the code generator. | 10359 // instead of having to edit some template or the code generator. |
| 10352 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10360 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10353 | 10361 |
| 10354 } // namespace gles2 | 10362 } // namespace gles2 |
| 10355 } // namespace gpu | 10363 } // namespace gpu |
| OLD | NEW |