| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 "sky/compositor/texture_cache.h" | |
| 6 | |
| 7 #include "mojo/converters/geometry/geometry_type_converters.h" | |
| 8 #include "mojo/gpu/gl_texture.h" | |
| 9 | |
| 10 namespace sky { | |
| 11 | |
| 12 TextureCache::TextureCache() { | |
| 13 } | |
| 14 | |
| 15 TextureCache::~TextureCache() { | |
| 16 } | |
| 17 | |
| 18 scoped_ptr<mojo::GLTexture> TextureCache::GetTexture(const gfx::Size& size) { | |
| 19 if (size != size_) { | |
| 20 available_textures_.clear(); | |
| 21 size_ = size; | |
| 22 } | |
| 23 if (available_textures_.empty()) | |
| 24 return nullptr; | |
| 25 scoped_ptr<mojo::GLTexture> texture(available_textures_.back()); | |
| 26 available_textures_.back() = nullptr; | |
| 27 available_textures_.pop_back(); | |
| 28 return texture.Pass(); | |
| 29 } | |
| 30 | |
| 31 void TextureCache::PutTexture(scoped_ptr<mojo::GLTexture> texture) { | |
| 32 if (texture->size() != size_) | |
| 33 return; | |
| 34 available_textures_.push_back(texture.release()); | |
| 35 } | |
| 36 | |
| 37 } // namespace sky | |
| OLD | NEW |