| 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 <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 10 #include "gpu/command_buffer/service/buffer_manager.h" | 10 #include "gpu/command_buffer/service/buffer_manager.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, GetBufferId(element_array_buffer)); | 263 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, GetBufferId(element_array_buffer)); |
| 264 } | 264 } |
| 265 glBindBuffer(GL_ARRAY_BUFFER, GetBufferId(bound_array_buffer.get())); | 265 glBindBuffer(GL_ARRAY_BUFFER, GetBufferId(bound_array_buffer.get())); |
| 266 if (feature_info_->IsES3Capable()) { | 266 if (feature_info_->IsES3Capable()) { |
| 267 glBindBuffer(GL_COPY_READ_BUFFER, | 267 glBindBuffer(GL_COPY_READ_BUFFER, |
| 268 GetBufferId(bound_copy_read_buffer.get())); | 268 GetBufferId(bound_copy_read_buffer.get())); |
| 269 glBindBuffer(GL_COPY_WRITE_BUFFER, | 269 glBindBuffer(GL_COPY_WRITE_BUFFER, |
| 270 GetBufferId(bound_copy_write_buffer.get())); | 270 GetBufferId(bound_copy_write_buffer.get())); |
| 271 glBindBuffer(GL_PIXEL_PACK_BUFFER, | 271 glBindBuffer(GL_PIXEL_PACK_BUFFER, |
| 272 GetBufferId(bound_pixel_pack_buffer.get())); | 272 GetBufferId(bound_pixel_pack_buffer.get())); |
| 273 UpdatePackParameters(); | |
| 274 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, | 273 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, |
| 275 GetBufferId(bound_pixel_unpack_buffer.get())); | 274 GetBufferId(bound_pixel_unpack_buffer.get())); |
| 276 UpdateUnpackParameters(); | |
| 277 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, | 275 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, |
| 278 GetBufferId(bound_transform_feedback_buffer.get())); | 276 GetBufferId(bound_transform_feedback_buffer.get())); |
| 279 glBindBuffer(GL_UNIFORM_BUFFER, GetBufferId(bound_uniform_buffer.get())); | 277 glBindBuffer(GL_UNIFORM_BUFFER, GetBufferId(bound_uniform_buffer.get())); |
| 280 } | 278 } |
| 281 } | 279 } |
| 282 | 280 |
| 283 void ContextState::RestoreRenderbufferBindings() { | 281 void ContextState::RestoreRenderbufferBindings() { |
| 284 // Require Renderbuffer rebind. | 282 // Require Renderbuffer rebind. |
| 285 bound_renderbuffer_valid = false; | 283 bound_renderbuffer_valid = false; |
| 286 } | 284 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 if (feature_info_->feature_flags().emulate_primitive_restart_fixed_index) | 435 if (feature_info_->feature_flags().emulate_primitive_restart_fixed_index) |
| 438 pname = GL_PRIMITIVE_RESTART; | 436 pname = GL_PRIMITIVE_RESTART; |
| 439 } | 437 } |
| 440 if (enable) { | 438 if (enable) { |
| 441 glEnable(pname); | 439 glEnable(pname); |
| 442 } else { | 440 } else { |
| 443 glDisable(pname); | 441 glDisable(pname); |
| 444 } | 442 } |
| 445 } | 443 } |
| 446 | 444 |
| 447 void ContextState::UpdatePackParameters() const { | |
| 448 if (!feature_info_->IsES3Capable()) | |
| 449 return; | |
| 450 if (bound_pixel_pack_buffer.get()) { | |
| 451 glPixelStorei(GL_PACK_ROW_LENGTH, pack_row_length); | |
| 452 glPixelStorei(GL_PACK_SKIP_PIXELS, pack_skip_pixels); | |
| 453 glPixelStorei(GL_PACK_SKIP_ROWS, pack_skip_rows); | |
| 454 } else { | |
| 455 glPixelStorei(GL_PACK_ROW_LENGTH, 0); | |
| 456 glPixelStorei(GL_PACK_SKIP_PIXELS, 0); | |
| 457 glPixelStorei(GL_PACK_SKIP_ROWS, 0); | |
| 458 } | |
| 459 } | |
| 460 | |
| 461 void ContextState::UpdateUnpackParameters() const { | |
| 462 if (!feature_info_->IsES3Capable()) | |
| 463 return; | |
| 464 if (bound_pixel_unpack_buffer.get()) { | |
| 465 glPixelStorei(GL_UNPACK_ROW_LENGTH, unpack_row_length); | |
| 466 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, unpack_image_height); | |
| 467 glPixelStorei(GL_UNPACK_SKIP_PIXELS, unpack_skip_pixels); | |
| 468 glPixelStorei(GL_UNPACK_SKIP_ROWS, unpack_skip_rows); | |
| 469 glPixelStorei(GL_UNPACK_SKIP_IMAGES, unpack_skip_images); | |
| 470 } else { | |
| 471 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | |
| 472 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0); | |
| 473 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); | |
| 474 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); | |
| 475 glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0); | |
| 476 } | |
| 477 } | |
| 478 | |
| 479 void ContextState::SetBoundBuffer(GLenum target, Buffer* buffer) { | 445 void ContextState::SetBoundBuffer(GLenum target, Buffer* buffer) { |
| 480 switch (target) { | 446 switch (target) { |
| 481 case GL_ARRAY_BUFFER: | 447 case GL_ARRAY_BUFFER: |
| 482 bound_array_buffer = buffer; | 448 bound_array_buffer = buffer; |
| 483 break; | 449 break; |
| 484 case GL_ELEMENT_ARRAY_BUFFER: | 450 case GL_ELEMENT_ARRAY_BUFFER: |
| 485 vertex_attrib_manager->SetElementArrayBuffer(buffer); | 451 vertex_attrib_manager->SetElementArrayBuffer(buffer); |
| 486 break; | 452 break; |
| 487 case GL_COPY_READ_BUFFER: | 453 case GL_COPY_READ_BUFFER: |
| 488 bound_copy_read_buffer = buffer; | 454 bound_copy_read_buffer = buffer; |
| 489 break; | 455 break; |
| 490 case GL_COPY_WRITE_BUFFER: | 456 case GL_COPY_WRITE_BUFFER: |
| 491 bound_copy_write_buffer = buffer; | 457 bound_copy_write_buffer = buffer; |
| 492 break; | 458 break; |
| 493 case GL_PIXEL_PACK_BUFFER: | 459 case GL_PIXEL_PACK_BUFFER: |
| 494 bound_pixel_pack_buffer = buffer; | 460 bound_pixel_pack_buffer = buffer; |
| 495 UpdatePackParameters(); | |
| 496 break; | 461 break; |
| 497 case GL_PIXEL_UNPACK_BUFFER: | 462 case GL_PIXEL_UNPACK_BUFFER: |
| 498 bound_pixel_unpack_buffer = buffer; | 463 bound_pixel_unpack_buffer = buffer; |
| 499 UpdateUnpackParameters(); | |
| 500 break; | 464 break; |
| 501 case GL_TRANSFORM_FEEDBACK_BUFFER: | 465 case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 502 bound_transform_feedback_buffer = buffer; | 466 bound_transform_feedback_buffer = buffer; |
| 503 break; | 467 break; |
| 504 case GL_UNIFORM_BUFFER: | 468 case GL_UNIFORM_BUFFER: |
| 505 bound_uniform_buffer = buffer; | 469 bound_uniform_buffer = buffer; |
| 506 break; | 470 break; |
| 507 default: | 471 default: |
| 508 NOTREACHED(); | 472 NOTREACHED(); |
| 509 break; | 473 break; |
| 510 } | 474 } |
| 511 } | 475 } |
| 512 | 476 |
| 513 void ContextState::RemoveBoundBuffer(Buffer* buffer) { | 477 void ContextState::RemoveBoundBuffer(Buffer* buffer) { |
| 514 DCHECK(buffer); | 478 DCHECK(buffer); |
| 515 vertex_attrib_manager->Unbind(buffer); | 479 vertex_attrib_manager->Unbind(buffer); |
| 516 if (bound_array_buffer.get() == buffer) { | 480 if (bound_array_buffer.get() == buffer) { |
| 517 bound_array_buffer = nullptr; | 481 bound_array_buffer = nullptr; |
| 518 } | 482 } |
| 519 if (bound_copy_read_buffer.get() == buffer) { | 483 if (bound_copy_read_buffer.get() == buffer) { |
| 520 bound_copy_read_buffer = nullptr; | 484 bound_copy_read_buffer = nullptr; |
| 521 } | 485 } |
| 522 if (bound_copy_write_buffer.get() == buffer) { | 486 if (bound_copy_write_buffer.get() == buffer) { |
| 523 bound_copy_write_buffer = nullptr; | 487 bound_copy_write_buffer = nullptr; |
| 524 } | 488 } |
| 525 if (bound_pixel_pack_buffer.get() == buffer) { | 489 if (bound_pixel_pack_buffer.get() == buffer) { |
| 526 bound_pixel_pack_buffer = nullptr; | 490 bound_pixel_pack_buffer = nullptr; |
| 527 UpdatePackParameters(); | |
| 528 } | 491 } |
| 529 if (bound_pixel_unpack_buffer.get() == buffer) { | 492 if (bound_pixel_unpack_buffer.get() == buffer) { |
| 530 bound_pixel_unpack_buffer = nullptr; | 493 bound_pixel_unpack_buffer = nullptr; |
| 531 UpdateUnpackParameters(); | |
| 532 } | 494 } |
| 533 if (bound_transform_feedback_buffer.get() == buffer) { | 495 if (bound_transform_feedback_buffer.get() == buffer) { |
| 534 bound_transform_feedback_buffer = nullptr; | 496 bound_transform_feedback_buffer = nullptr; |
| 535 } | 497 } |
| 536 if (bound_uniform_buffer.get() == buffer) { | 498 if (bound_uniform_buffer.get() == buffer) { |
| 537 bound_uniform_buffer = nullptr; | 499 bound_uniform_buffer = nullptr; |
| 538 } | 500 } |
| 539 } | 501 } |
| 540 | 502 |
| 541 void ContextState::UnbindTexture(TextureRef* texture) { | 503 void ContextState::UnbindTexture(TextureRef* texture) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 } | 547 } |
| 586 } | 548 } |
| 587 | 549 |
| 588 // Include the auto-generated part of this file. We split this because it means | 550 // Include the auto-generated part of this file. We split this because it means |
| 589 // we can easily edit the non-auto generated parts right here in this file | 551 // we can easily edit the non-auto generated parts right here in this file |
| 590 // instead of having to edit some template or the code generator. | 552 // instead of having to edit some template or the code generator. |
| 591 #include "gpu/command_buffer/service/context_state_impl_autogen.h" | 553 #include "gpu/command_buffer/service/context_state_impl_autogen.h" |
| 592 | 554 |
| 593 } // namespace gles2 | 555 } // namespace gles2 |
| 594 } // namespace gpu | 556 } // namespace gpu |
| OLD | NEW |