OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/gl/dirty_texture_state.h" |
| 6 |
| 7 namespace gfx { |
| 8 |
| 9 const size_t kMaxTextureUnits = 64; |
| 10 |
| 11 DirtyTextureState::DirtyTextureState() |
| 12 : bindings_(), |
| 13 max_texture_unit_(GL_TEXTURE0) { |
| 14 bindings_.resize(kMaxTextureUnits); |
| 15 } |
| 16 |
| 17 DirtyTextureState::~DirtyTextureState() { |
| 18 } |
| 19 |
| 20 void DirtyTextureState::UpdateMaxTextureUnit(GLenum current_unit) { |
| 21 max_texture_unit_ = std::max(current_unit, max_texture_unit_); |
| 22 } |
| 23 |
| 24 void DirtyTextureState::AddBinding(GLenum current_unit, GLenum target) { |
| 25 int current_unit_index = current_unit - GL_TEXTURE0; |
| 26 DCHECK(current_unit_index >= 0); |
| 27 DCHECK(static_cast<size_t>(current_unit_index) < kMaxTextureUnits); |
| 28 DirtyTextureBindings binding_for_texture = bindings_[current_unit_index]; |
| 29 |
| 30 switch (target) { |
| 31 case GL_TEXTURE_2D: |
| 32 binding_for_texture.binding_2d = true; |
| 33 break; |
| 34 case GL_TEXTURE_CUBE_MAP: |
| 35 binding_for_texture.binding_cube_map = true; |
| 36 break; |
| 37 case GL_TEXTURE_EXTERNAL_OES: |
| 38 binding_for_texture.binding_external_oes = true; |
| 39 break; |
| 40 case GL_TEXTURE_RECTANGLE_ARB: |
| 41 binding_for_texture.binding_rectangle_arb = true; |
| 42 break; |
| 43 default: |
| 44 NOTREACHED(); |
| 45 } |
| 46 |
| 47 bindings_[current_unit_index] = binding_for_texture; |
| 48 } |
| 49 |
| 50 void DirtyTextureState::Clear() { |
| 51 max_texture_unit_ = GL_TEXTURE0; |
| 52 bindings_.clear(); |
| 53 bindings_.resize(kMaxTextureUnits); |
| 54 } |
| 55 |
| 56 } // namespace gfx |
OLD | NEW |