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/resources/scoped_resource.h"
9 ScopedResource::ScopedResource(ResourceProvider
* resource_provider
)
10 : resource_provider_(resource_provider
) {
11 DCHECK(resource_provider_
);
14 ScopedResource::~ScopedResource() {
18 void ScopedResource::Allocate(const gfx::Size
& size
,
19 ResourceProvider::TextureHint hint
,
20 ResourceFormat format
) {
22 DCHECK(!size
.IsEmpty());
24 set_dimensions(size
, format
);
25 set_id(resource_provider_
->CreateResource(
26 size
, GL_CLAMP_TO_EDGE
, hint
, format
));
29 allocate_thread_id_
= base::PlatformThread::CurrentId();
33 void ScopedResource::AllocateManaged(const gfx::Size
& size
,
35 ResourceFormat format
) {
37 DCHECK(!size
.IsEmpty());
39 set_dimensions(size
, format
);
40 set_id(resource_provider_
->CreateManagedResource(
41 size
, target
, GL_CLAMP_TO_EDGE
, ResourceProvider::TEXTURE_HINT_IMMUTABLE
,
45 allocate_thread_id_
= base::PlatformThread::CurrentId();
49 void ScopedResource::Free() {
52 DCHECK(allocate_thread_id_
== base::PlatformThread::CurrentId());
54 resource_provider_
->DeleteResource(id());