OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 "cc/resources/scoped_ui_resource.h" |
| 6 |
| 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" |
| 9 #include "cc/trees/layer_tree_host.h" |
| 10 |
| 11 namespace cc { |
| 12 |
| 13 ScopedUIResource::ScopedUIResource(LayerTreeHost* host, |
| 14 scoped_refptr<UIResourceBitmap> bitmap) |
| 15 : bitmap_(bitmap), host_(host) { |
| 16 DCHECK(host_); |
| 17 id_ = host_->CreateUIResource(this); |
| 18 } |
| 19 |
| 20 // User must make sure that host is still valid before this object goes out of |
| 21 // scope. |
| 22 ScopedUIResource::~ScopedUIResource() { |
| 23 if (id_) { |
| 24 DCHECK(host_); |
| 25 host_->DeleteUIResource(id_); |
| 26 } |
| 27 } |
| 28 |
| 29 scoped_refptr<UIResourceBitmap> ScopedUIResource::Create(bool resource_lost) { |
| 30 return bitmap_; |
| 31 } |
| 32 |
| 33 } // namespace cc |
OLD | NEW |