blob: ff54056721466f4168b5ba22de9bbc728d7c362e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "CCScopedTexture.h"
namespace cc {
CCScopedTexture::CCScopedTexture(CCResourceProvider* resourceProvider)
: m_resourceProvider(resourceProvider)
{
DCHECK(m_resourceProvider);
}
CCScopedTexture::~CCScopedTexture()
{
free();
}
bool CCScopedTexture::allocate(int pool, const IntSize& size, GC3Denum format, CCResourceProvider::TextureUsageHint hint)
{
DCHECK(!id());
DCHECK(!size.isEmpty());
setDimensions(size, format);
setId(m_resourceProvider->createResource(pool, size, format, hint));
#ifndef NDEBUG
m_allocateThreadIdentifier = base::PlatformThread::CurrentId();
#endif
return id();
}
void CCScopedTexture::free()
{
if (id()) {
#ifndef NDEBUG
DCHECK(m_allocateThreadIdentifier == base::PlatformThread::CurrentId());
#endif
m_resourceProvider->deleteResource(id());
}
setId(0);
}
void CCScopedTexture::leak()
{
setId(0);
}
}
|