| Index: ui/gl/dirty_texture_state.cc
|
| diff --git a/ui/gl/dirty_texture_state.cc b/ui/gl/dirty_texture_state.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1672167a42a6457b1e17a400b2f1d708980cb80b
|
| --- /dev/null
|
| +++ b/ui/gl/dirty_texture_state.cc
|
| @@ -0,0 +1,56 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/gl/dirty_texture_state.h"
|
| +
|
| +namespace gfx {
|
| +
|
| +const size_t kMaxTextureUnits = 64;
|
| +
|
| +DirtyTextureState::DirtyTextureState()
|
| + : bindings_(),
|
| + max_texture_unit_(GL_TEXTURE0) {
|
| + bindings_.resize(kMaxTextureUnits);
|
| +}
|
| +
|
| +DirtyTextureState::~DirtyTextureState() {
|
| +}
|
| +
|
| +void DirtyTextureState::UpdateMaxTextureUnit(GLenum current_unit) {
|
| + max_texture_unit_ = std::max(current_unit, max_texture_unit_);
|
| +}
|
| +
|
| +void DirtyTextureState::AddBinding(GLenum current_unit, GLenum target) {
|
| + int current_unit_index = current_unit - GL_TEXTURE0;
|
| + DCHECK(current_unit_index >= 0);
|
| + DCHECK(static_cast<size_t>(current_unit_index) < kMaxTextureUnits);
|
| + DirtyTextureBindings binding_for_texture = bindings_[current_unit_index];
|
| +
|
| + switch (target) {
|
| + case GL_TEXTURE_2D:
|
| + binding_for_texture.binding_2d = true;
|
| + break;
|
| + case GL_TEXTURE_CUBE_MAP:
|
| + binding_for_texture.binding_cube_map = true;
|
| + break;
|
| + case GL_TEXTURE_EXTERNAL_OES:
|
| + binding_for_texture.binding_external_oes = true;
|
| + break;
|
| + case GL_TEXTURE_RECTANGLE_ARB:
|
| + binding_for_texture.binding_rectangle_arb = true;
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + }
|
| +
|
| + bindings_[current_unit_index] = binding_for_texture;
|
| +}
|
| +
|
| +void DirtyTextureState::Clear() {
|
| + max_texture_unit_ = GL_TEXTURE0;
|
| + bindings_.clear();
|
| + bindings_.resize(kMaxTextureUnits);
|
| +}
|
| +
|
| +} // namespace gfx
|
|
|