Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(648)

Unified Diff: sky/compositor/texture_cache.cc

Issue 868263002: Sky shouldn't crash on device rotate (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/compositor/texture_cache.h ('k') | sky/viewer/document_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/compositor/texture_cache.cc
diff --git a/sky/compositor/texture_cache.cc b/sky/compositor/texture_cache.cc
new file mode 100644
index 0000000000000000000000000000000000000000..05fa7d58ebc8414e10acbad08f92e065182c83b1
--- /dev/null
+++ b/sky/compositor/texture_cache.cc
@@ -0,0 +1,37 @@
+// 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/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
« no previous file with comments | « sky/compositor/texture_cache.h ('k') | sky/viewer/document_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698