| 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 |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 glPixelStorei(GL_PACK_ROW_LENGTH, 0); | 454 glPixelStorei(GL_PACK_ROW_LENGTH, 0); |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 | 457 |
| 458 void ContextState::UpdateUnpackParameters() const { | 458 void ContextState::UpdateUnpackParameters() const { |
| 459 if (!feature_info_->IsES3Capable()) | 459 if (!feature_info_->IsES3Capable()) |
| 460 return; | 460 return; |
| 461 if (bound_pixel_unpack_buffer.get()) { | 461 if (bound_pixel_unpack_buffer.get()) { |
| 462 glPixelStorei(GL_UNPACK_ROW_LENGTH, unpack_row_length); | 462 glPixelStorei(GL_UNPACK_ROW_LENGTH, unpack_row_length); |
| 463 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, unpack_image_height); | 463 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, unpack_image_height); |
| 464 glPixelStorei(GL_UNPACK_SKIP_PIXELS, unpack_skip_pixels); | |
| 465 glPixelStorei(GL_UNPACK_SKIP_ROWS, unpack_skip_rows); | |
| 466 glPixelStorei(GL_UNPACK_SKIP_IMAGES, unpack_skip_images); | |
| 467 } else { | 464 } else { |
| 468 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | 465 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); |
| 469 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0); | 466 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0); |
| 470 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); | |
| 471 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); | |
| 472 glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0); | |
| 473 } | 467 } |
| 474 } | 468 } |
| 475 | 469 |
| 476 void ContextState::SetBoundBuffer(GLenum target, Buffer* buffer) { | 470 void ContextState::SetBoundBuffer(GLenum target, Buffer* buffer) { |
| 477 switch (target) { | 471 switch (target) { |
| 478 case GL_ARRAY_BUFFER: | 472 case GL_ARRAY_BUFFER: |
| 479 bound_array_buffer = buffer; | 473 bound_array_buffer = buffer; |
| 480 break; | 474 break; |
| 481 case GL_ELEMENT_ARRAY_BUFFER: | 475 case GL_ELEMENT_ARRAY_BUFFER: |
| 482 vertex_attrib_manager->SetElementArrayBuffer(buffer); | 476 vertex_attrib_manager->SetElementArrayBuffer(buffer); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 void ContextState::UnbindSampler(Sampler* sampler) { | 586 void ContextState::UnbindSampler(Sampler* sampler) { |
| 593 for (size_t jj = 0; jj < sampler_units.size(); ++jj) { | 587 for (size_t jj = 0; jj < sampler_units.size(); ++jj) { |
| 594 if (sampler_units[jj].get() == sampler) { | 588 if (sampler_units[jj].get() == sampler) { |
| 595 sampler_units[jj] = nullptr; | 589 sampler_units[jj] = nullptr; |
| 596 glBindSampler(jj, 0); | 590 glBindSampler(jj, 0); |
| 597 } | 591 } |
| 598 } | 592 } |
| 599 } | 593 } |
| 600 | 594 |
| 601 PixelStoreParams ContextState::GetPackParams() { | 595 PixelStoreParams ContextState::GetPackParams() { |
| 596 DCHECK_EQ(0, pack_skip_pixels); |
| 597 DCHECK_EQ(0, pack_skip_rows); |
| 602 PixelStoreParams params; | 598 PixelStoreParams params; |
| 603 params.alignment = pack_alignment; | 599 params.alignment = pack_alignment; |
| 604 params.row_length = pack_row_length; | 600 params.row_length = pack_row_length; |
| 605 params.skip_pixels = pack_skip_pixels; | |
| 606 params.skip_rows = pack_skip_rows; | |
| 607 return params; | 601 return params; |
| 608 } | 602 } |
| 609 | 603 |
| 610 PixelStoreParams ContextState::GetUnpackParams(Dimension dimension) { | 604 PixelStoreParams ContextState::GetUnpackParams(Dimension dimension) { |
| 605 DCHECK_EQ(0, unpack_skip_pixels); |
| 606 DCHECK_EQ(0, unpack_skip_rows); |
| 607 DCHECK_EQ(0, unpack_skip_images); |
| 611 PixelStoreParams params; | 608 PixelStoreParams params; |
| 612 params.alignment = unpack_alignment; | 609 params.alignment = unpack_alignment; |
| 613 params.row_length = unpack_row_length; | 610 params.row_length = unpack_row_length; |
| 614 params.skip_pixels = unpack_skip_pixels; | |
| 615 params.skip_rows = unpack_skip_rows; | |
| 616 if (dimension == k3D) { | 611 if (dimension == k3D) { |
| 617 params.image_height = unpack_image_height; | 612 params.image_height = unpack_image_height; |
| 618 params.skip_images = unpack_skip_images; | |
| 619 } | 613 } |
| 620 return params; | 614 return params; |
| 621 } | 615 } |
| 622 | 616 |
| 623 void ContextState::InitStateManual(const ContextState*) const { | 617 void ContextState::InitStateManual(const ContextState*) const { |
| 624 // Here we always reset the states whether it's different from previous ones. | 618 // Here we always reset the states whether it's different from previous ones. |
| 625 // We have very limited states here; also, once we switch to MANGLE, MANGLE | 619 // We have very limited states here; also, once we switch to MANGLE, MANGLE |
| 626 // will opmitize this. | 620 // will opmitize this. |
| 627 UpdatePackParameters(); | 621 UpdatePackParameters(); |
| 628 UpdateUnpackParameters(); | 622 UpdateUnpackParameters(); |
| 629 } | 623 } |
| 630 | 624 |
| 631 // Include the auto-generated part of this file. We split this because it means | 625 // Include the auto-generated part of this file. We split this because it means |
| 632 // we can easily edit the non-auto generated parts right here in this file | 626 // we can easily edit the non-auto generated parts right here in this file |
| 633 // instead of having to edit some template or the code generator. | 627 // instead of having to edit some template or the code generator. |
| 634 #include "gpu/command_buffer/service/context_state_impl_autogen.h" | 628 #include "gpu/command_buffer/service/context_state_impl_autogen.h" |
| 635 | 629 |
| 636 } // namespace gles2 | 630 } // namespace gles2 |
| 637 } // namespace gpu | 631 } // namespace gpu |
| OLD | NEW |