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