Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Side by Side Diff: cc/resources/scoped_resource.cc

Issue 1533773002: Delete CC. (Closed) Base URL: git@github.com:domokit/mojo.git@cl-2e
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/scoped_resource.h ('k') | cc/resources/scoped_resource_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "cc/resources/scoped_resource.h"
6
7 namespace cc {
8
9 ScopedResource::ScopedResource(ResourceProvider* resource_provider)
10 : resource_provider_(resource_provider) {
11 DCHECK(resource_provider_);
12 }
13
14 ScopedResource::~ScopedResource() {
15 Free();
16 }
17
18 void ScopedResource::Allocate(const gfx::Size& size,
19 ResourceProvider::TextureHint hint,
20 ResourceFormat format) {
21 DCHECK(!id());
22 DCHECK(!size.IsEmpty());
23
24 set_dimensions(size, format);
25 set_id(resource_provider_->CreateResource(
26 size, GL_CLAMP_TO_EDGE, hint, format));
27
28 #if DCHECK_IS_ON()
29 allocate_thread_id_ = base::PlatformThread::CurrentId();
30 #endif
31 }
32
33 void ScopedResource::AllocateManaged(const gfx::Size& size,
34 GLenum target,
35 ResourceFormat format) {
36 DCHECK(!id());
37 DCHECK(!size.IsEmpty());
38
39 set_dimensions(size, format);
40 set_id(resource_provider_->CreateManagedResource(
41 size, target, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
42 format));
43
44 #if DCHECK_IS_ON()
45 allocate_thread_id_ = base::PlatformThread::CurrentId();
46 #endif
47 }
48
49 void ScopedResource::Free() {
50 if (id()) {
51 #if DCHECK_IS_ON()
52 DCHECK(allocate_thread_id_ == base::PlatformThread::CurrentId());
53 #endif
54 resource_provider_->DeleteResource(id());
55 }
56 set_id(0);
57 }
58
59 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/scoped_resource.h ('k') | cc/resources/scoped_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698