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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « sky/compositor/texture_cache.h ('k') | sky/viewer/document_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« 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