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/context_state.h" | 5 #include "gpu/command_buffer/service/context_state.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 | 10 |
11 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 11 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
12 #include "gpu/command_buffer/service/buffer_manager.h" | 12 #include "gpu/command_buffer/service/buffer_manager.h" |
13 #include "gpu/command_buffer/service/error_state.h" | 13 #include "gpu/command_buffer/service/error_state.h" |
14 #include "gpu/command_buffer/service/framebuffer_manager.h" | 14 #include "gpu/command_buffer/service/framebuffer_manager.h" |
15 #include "gpu/command_buffer/service/program_manager.h" | 15 #include "gpu/command_buffer/service/program_manager.h" |
16 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 16 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 17 #include "gpu/command_buffer/service/transform_feedback_manager.h" |
17 #include "ui/gl/gl_bindings.h" | 18 #include "ui/gl/gl_bindings.h" |
18 #include "ui/gl/gl_implementation.h" | 19 #include "ui/gl/gl_implementation.h" |
19 #include "ui/gl/gl_version_info.h" | 20 #include "ui/gl/gl_version_info.h" |
20 | 21 |
21 namespace gpu { | 22 namespace gpu { |
22 namespace gles2 { | 23 namespace gles2 { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 GLuint Get2dServiceId(const TextureUnit& unit) { | 27 GLuint Get2dServiceId(const TextureUnit& unit) { |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 287 |
287 void ContextState::RestoreRenderbufferBindings() { | 288 void ContextState::RestoreRenderbufferBindings() { |
288 // Require Renderbuffer rebind. | 289 // Require Renderbuffer rebind. |
289 bound_renderbuffer_valid = false; | 290 bound_renderbuffer_valid = false; |
290 } | 291 } |
291 | 292 |
292 void ContextState::RestoreProgramBindings() const { | 293 void ContextState::RestoreProgramBindings() const { |
293 glUseProgram(current_program.get() ? current_program->service_id() : 0); | 294 glUseProgram(current_program.get() ? current_program->service_id() : 0); |
294 } | 295 } |
295 | 296 |
| 297 void ContextState::RestoreTransformFeedbackBindings( |
| 298 const ContextState* prev_state) { |
| 299 if (!feature_info_->IsES3Capable()) |
| 300 return; |
| 301 if (prev_state) { |
| 302 if (prev_state->bound_transform_feedback.get() && |
| 303 prev_state->bound_transform_feedback->active() && |
| 304 !prev_state->bound_transform_feedback->paused()) { |
| 305 glPauseTransformFeedback(); |
| 306 } |
| 307 } |
| 308 if (bound_transform_feedback.get()) { |
| 309 bound_transform_feedback->DoBindTransformFeedback( |
| 310 feature_info_->gl_version_info(), GL_TRANSFORM_FEEDBACK); |
| 311 } else { |
| 312 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
| 313 } |
| 314 } |
| 315 |
296 void ContextState::RestoreActiveTexture() const { | 316 void ContextState::RestoreActiveTexture() const { |
297 glActiveTexture(GL_TEXTURE0 + active_texture_unit); | 317 glActiveTexture(GL_TEXTURE0 + active_texture_unit); |
298 } | 318 } |
299 | 319 |
300 void ContextState::RestoreAllTextureUnitBindings( | 320 void ContextState::RestoreAllTextureUnitBindings( |
301 const ContextState* prev_state) const { | 321 const ContextState* prev_state) const { |
302 // Restore Texture state. | 322 // Restore Texture state. |
303 for (size_t ii = 0; ii < texture_units.size(); ++ii) { | 323 for (size_t ii = 0; ii < texture_units.size(); ++ii) { |
304 RestoreTextureUnitBindings(ii, prev_state); | 324 RestoreTextureUnitBindings(ii, prev_state); |
305 } | 325 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 InitCapabilities(prev_state); | 439 InitCapabilities(prev_state); |
420 InitState(prev_state); | 440 InitState(prev_state); |
421 } | 441 } |
422 | 442 |
423 void ContextState::RestoreState(const ContextState* prev_state) { | 443 void ContextState::RestoreState(const ContextState* prev_state) { |
424 RestoreAllTextureUnitBindings(prev_state); | 444 RestoreAllTextureUnitBindings(prev_state); |
425 RestoreVertexAttribs(); | 445 RestoreVertexAttribs(); |
426 RestoreBufferBindings(); | 446 RestoreBufferBindings(); |
427 RestoreRenderbufferBindings(); | 447 RestoreRenderbufferBindings(); |
428 RestoreProgramBindings(); | 448 RestoreProgramBindings(); |
| 449 RestoreTransformFeedbackBindings(prev_state); |
429 RestoreGlobalState(prev_state); | 450 RestoreGlobalState(prev_state); |
430 } | 451 } |
431 | 452 |
432 ErrorState* ContextState::GetErrorState() { | 453 ErrorState* ContextState::GetErrorState() { |
433 return error_state_.get(); | 454 return error_state_.get(); |
434 } | 455 } |
435 | 456 |
436 void ContextState::EnableDisable(GLenum pname, bool enable) const { | 457 void ContextState::EnableDisable(GLenum pname, bool enable) const { |
437 if (pname == GL_PRIMITIVE_RESTART_FIXED_INDEX && | 458 if (pname == GL_PRIMITIVE_RESTART_FIXED_INDEX && |
438 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { | 459 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 if (bound_pixel_unpack_buffer.get() == buffer) { | 542 if (bound_pixel_unpack_buffer.get() == buffer) { |
522 bound_pixel_unpack_buffer = nullptr; | 543 bound_pixel_unpack_buffer = nullptr; |
523 UpdateUnpackParameters(); | 544 UpdateUnpackParameters(); |
524 } | 545 } |
525 if (bound_transform_feedback_buffer.get() == buffer) { | 546 if (bound_transform_feedback_buffer.get() == buffer) { |
526 bound_transform_feedback_buffer = nullptr; | 547 bound_transform_feedback_buffer = nullptr; |
527 } | 548 } |
528 if (bound_uniform_buffer.get() == buffer) { | 549 if (bound_uniform_buffer.get() == buffer) { |
529 bound_uniform_buffer = nullptr; | 550 bound_uniform_buffer = nullptr; |
530 } | 551 } |
| 552 if (default_transform_feedback.get()) { |
| 553 default_transform_feedback->RemoveBoundBuffer(buffer); |
| 554 } |
531 } | 555 } |
532 | 556 |
533 void ContextState::UnbindTexture(TextureRef* texture) { | 557 void ContextState::UnbindTexture(TextureRef* texture) { |
534 GLuint active_unit = active_texture_unit; | 558 GLuint active_unit = active_texture_unit; |
535 for (size_t jj = 0; jj < texture_units.size(); ++jj) { | 559 for (size_t jj = 0; jj < texture_units.size(); ++jj) { |
536 TextureUnit& unit = texture_units[jj]; | 560 TextureUnit& unit = texture_units[jj]; |
537 if (unit.bound_texture_2d.get() == texture) { | 561 if (unit.bound_texture_2d.get() == texture) { |
538 unit.bound_texture_2d = NULL; | 562 unit.bound_texture_2d = NULL; |
539 if (active_unit != jj) { | 563 if (active_unit != jj) { |
540 glActiveTexture(GL_TEXTURE0 + jj); | 564 glActiveTexture(GL_TEXTURE0 + jj); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 UpdateUnpackParameters(); | 647 UpdateUnpackParameters(); |
624 } | 648 } |
625 | 649 |
626 // Include the auto-generated part of this file. We split this because it means | 650 // Include the auto-generated part of this file. We split this because it means |
627 // we can easily edit the non-auto generated parts right here in this file | 651 // we can easily edit the non-auto generated parts right here in this file |
628 // instead of having to edit some template or the code generator. | 652 // instead of having to edit some template or the code generator. |
629 #include "gpu/command_buffer/service/context_state_impl_autogen.h" | 653 #include "gpu/command_buffer/service/context_state_impl_autogen.h" |
630 | 654 |
631 } // namespace gles2 | 655 } // namespace gles2 |
632 } // namespace gpu | 656 } // namespace gpu |
OLD | NEW |