forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscoped_resource.h
53 lines (40 loc) · 1.46 KB
/
scoped_resource.h
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.
#ifndef CC_RESOURCES_SCOPED_RESOURCE_H_
#define CC_RESOURCES_SCOPED_RESOURCE_H_
#include <memory>
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "cc/cc_export.h"
#include "cc/resources/resource.h"
#if DCHECK_IS_ON()
#include "base/threading/platform_thread.h"
#endif
namespace cc {
class CC_EXPORT ScopedResource : public Resource {
public:
explicit ScopedResource(ResourceProvider* provider);
virtual ~ScopedResource();
void Allocate(const gfx::Size& size,
ResourceProvider::TextureHint hint,
viz::ResourceFormat format,
const gfx::ColorSpace& color_space);
void AllocateWithGpuMemoryBuffer(const gfx::Size& size,
viz::ResourceFormat format,
gfx::BufferUsage usage,
const gfx::ColorSpace& color_space);
void Free();
ResourceProvider::TextureHint hint() const { return hint_; }
private:
ResourceProvider* resource_provider_;
ResourceProvider::TextureHint hint_ =
ResourceProvider::TextureHint::TEXTURE_HINT_DEFAULT;
#if DCHECK_IS_ON()
base::PlatformThreadId allocate_thread_id_;
#endif
DISALLOW_COPY_AND_ASSIGN(ScopedResource);
};
} // namespace cc
#endif // CC_RESOURCES_SCOPED_RESOURCE_H_