flutter_flutter/viewer/compositor/texture_cache.cc
Adam Barth ce5baf1e9d Move //sky/compositor to //sky/viewer/compositor
This library is logically part of //sky/viewer and shouldn't clutter up the
top-level //sky directory.

TBR=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1213683004.
2015-06-27 00:26:52 -07:00

38 lines
967 B
C++

// Copyright 2015 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 "sky/viewer/compositor/texture_cache.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/gpu/gl_texture.h"
namespace sky {
TextureCache::TextureCache() {
}
TextureCache::~TextureCache() {
}
scoped_ptr<mojo::GLTexture> TextureCache::GetTexture(const gfx::Size& size) {
if (size != size_) {
available_textures_.clear();
size_ = size;
}
if (available_textures_.empty())
return nullptr;
scoped_ptr<mojo::GLTexture> texture(available_textures_.back());
available_textures_.back() = nullptr;
available_textures_.pop_back();
return texture.Pass();
}
void TextureCache::PutTexture(scoped_ptr<mojo::GLTexture> texture) {
if (texture->size() != size_)
return;
available_textures_.push_back(texture.release());
}
} // namespace sky