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

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

Issue 2697353003: cc: Make ScopedResource constructor public, use MakeUnique to construct (Closed)
Patch Set: construct: . Created 3 years, 10 months 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/raster/raster_buffer_provider_unittest.cc ('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
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_RESOURCES_SCOPED_RESOURCE_H_ 5 #ifndef CC_RESOURCES_SCOPED_RESOURCE_H_
6 #define CC_RESOURCES_SCOPED_RESOURCE_H_ 6 #define CC_RESOURCES_SCOPED_RESOURCE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "cc/base/cc_export.h" 13 #include "cc/base/cc_export.h"
14 #include "cc/resources/resource.h" 14 #include "cc/resources/resource.h"
15 15
16 #if DCHECK_IS_ON() 16 #if DCHECK_IS_ON()
17 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.h"
18 #endif 18 #endif
19 19
20 namespace cc { 20 namespace cc {
21 21
22 class CC_EXPORT ScopedResource : public Resource { 22 class CC_EXPORT ScopedResource : public Resource {
23 public: 23 public:
24 static std::unique_ptr<ScopedResource> Create( 24 explicit ScopedResource(ResourceProvider* provider);
25 ResourceProvider* resource_provider) {
26 return base::WrapUnique(new ScopedResource(resource_provider));
27 }
28 virtual ~ScopedResource(); 25 virtual ~ScopedResource();
29 26
30 void Allocate(const gfx::Size& size, 27 void Allocate(const gfx::Size& size,
31 ResourceProvider::TextureHint hint, 28 ResourceProvider::TextureHint hint,
32 ResourceFormat format, 29 ResourceFormat format,
33 const gfx::ColorSpace& color_space); 30 const gfx::ColorSpace& color_space);
34 void AllocateWithGpuMemoryBuffer(const gfx::Size& size, 31 void AllocateWithGpuMemoryBuffer(const gfx::Size& size,
35 ResourceFormat format, 32 ResourceFormat format,
36 gfx::BufferUsage usage, 33 gfx::BufferUsage usage,
37 const gfx::ColorSpace& color_space); 34 const gfx::ColorSpace& color_space);
38 void Free(); 35 void Free();
39 36
40 protected:
41 explicit ScopedResource(ResourceProvider* provider);
42
43 private: 37 private:
44 ResourceProvider* resource_provider_; 38 ResourceProvider* resource_provider_;
45 39
46 #if DCHECK_IS_ON() 40 #if DCHECK_IS_ON()
47 base::PlatformThreadId allocate_thread_id_; 41 base::PlatformThreadId allocate_thread_id_;
48 #endif 42 #endif
49 43
50 DISALLOW_COPY_AND_ASSIGN(ScopedResource); 44 DISALLOW_COPY_AND_ASSIGN(ScopedResource);
51 }; 45 };
52 46
53 } // namespace cc 47 } // namespace cc
54 48
55 #endif // CC_RESOURCES_SCOPED_RESOURCE_H_ 49 #endif // CC_RESOURCES_SCOPED_RESOURCE_H_
OLDNEW
« no previous file with comments | « cc/raster/raster_buffer_provider_unittest.cc ('k') | cc/resources/scoped_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698