GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / cc / resources / scoped_ui_resource.cc
blobe69b4bc936800eb1a53cc1e5e5fee1e58477c55b
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.
5 #include "cc/resources/scoped_ui_resource.h"
7 #include "base/basictypes.h"
8 #include "base/bind.h"
9 #include "cc/trees/layer_tree_host.h"
11 namespace cc {
13 scoped_ptr<ScopedUIResource> ScopedUIResource::Create(
14 LayerTreeHost* host,
15 const UIResourceBitmap& bitmap) {
16 return make_scoped_ptr(new ScopedUIResource(host, bitmap));
19 ScopedUIResource::ScopedUIResource(LayerTreeHost* host,
20 const UIResourceBitmap& bitmap)
21 : bitmap_(bitmap), host_(host) {
22 DCHECK(host_);
23 id_ = host_->CreateUIResource(this);
26 // User must make sure that host is still valid before this object goes out of
27 // scope.
28 ScopedUIResource::~ScopedUIResource() {
29 if (id_) {
30 DCHECK(host_);
31 host_->DeleteUIResource(id_);
35 UIResourceBitmap ScopedUIResource::GetBitmap(UIResourceId uid,
36 bool resource_lost) {
37 return bitmap_;
40 } // namespace cc