Depend on stored sync session GUID for Android.
[chromium-blink-merge.git] / cc / scoped_resource.cc
blob5295b55614ac7d7a705dc833683a86e9b7aafe33
1 // Copyright 2012 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/scoped_resource.h"
7 namespace cc {
9 ScopedResource::ScopedResource(ResourceProvider* resource_provider)
10 : resource_provider_(resource_provider) {
11 DCHECK(resource_provider_);
14 ScopedResource::~ScopedResource() {
15 Free();
18 bool ScopedResource::Allocate(int pool, const gfx::Size& size, GLenum format,
19 ResourceProvider::TextureUsageHint hint) {
20 DCHECK(!id());
21 DCHECK(!size.IsEmpty());
23 set_dimensions(size, format);
24 set_id(resource_provider_->createResource(pool, size, format, hint));
26 #ifndef NDEBUG
27 allocate_thread_id_ = base::PlatformThread::CurrentId();
28 #endif
30 return id();
33 void ScopedResource::Free() {
34 if (id()) {
35 #ifndef NDEBUG
36 DCHECK(allocate_thread_id_ == base::PlatformThread::CurrentId());
37 #endif
38 resource_provider_->deleteResource(id());
40 set_id(0);
43 void ScopedResource::Leak() {
44 set_id(0);
47 } // namespace cc