| OLD | NEW |
| 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> |
| 9 |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/ptr_util.h" |
| 11 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
| 12 #include "cc/resources/resource.h" | 14 #include "cc/resources/resource.h" |
| 13 | 15 |
| 14 #if DCHECK_IS_ON() | 16 #if DCHECK_IS_ON() |
| 15 #include "base/threading/platform_thread.h" | 17 #include "base/threading/platform_thread.h" |
| 16 #endif | 18 #endif |
| 17 | 19 |
| 18 namespace cc { | 20 namespace cc { |
| 19 | 21 |
| 20 class CC_EXPORT ScopedResource : public Resource { | 22 class CC_EXPORT ScopedResource : public Resource { |
| 21 public: | 23 public: |
| 22 static scoped_ptr<ScopedResource> Create( | 24 static std::unique_ptr<ScopedResource> Create( |
| 23 ResourceProvider* resource_provider) { | 25 ResourceProvider* resource_provider) { |
| 24 return make_scoped_ptr(new ScopedResource(resource_provider)); | 26 return base::WrapUnique(new ScopedResource(resource_provider)); |
| 25 } | 27 } |
| 26 virtual ~ScopedResource(); | 28 virtual ~ScopedResource(); |
| 27 | 29 |
| 28 void Allocate(const gfx::Size& size, | 30 void Allocate(const gfx::Size& size, |
| 29 ResourceProvider::TextureHint hint, | 31 ResourceProvider::TextureHint hint, |
| 30 ResourceFormat format); | 32 ResourceFormat format); |
| 31 void AllocateWithGpuMemoryBuffer(const gfx::Size& size, | 33 void AllocateWithGpuMemoryBuffer(const gfx::Size& size, |
| 32 ResourceFormat format); | 34 ResourceFormat format); |
| 33 void Free(); | 35 void Free(); |
| 34 | 36 |
| 35 protected: | 37 protected: |
| 36 explicit ScopedResource(ResourceProvider* provider); | 38 explicit ScopedResource(ResourceProvider* provider); |
| 37 | 39 |
| 38 private: | 40 private: |
| 39 ResourceProvider* resource_provider_; | 41 ResourceProvider* resource_provider_; |
| 40 | 42 |
| 41 #if DCHECK_IS_ON() | 43 #if DCHECK_IS_ON() |
| 42 base::PlatformThreadId allocate_thread_id_; | 44 base::PlatformThreadId allocate_thread_id_; |
| 43 #endif | 45 #endif |
| 44 | 46 |
| 45 DISALLOW_COPY_AND_ASSIGN(ScopedResource); | 47 DISALLOW_COPY_AND_ASSIGN(ScopedResource); |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 } // namespace cc | 50 } // namespace cc |
| 49 | 51 |
| 50 #endif // CC_RESOURCES_SCOPED_RESOURCE_H_ | 52 #endif // CC_RESOURCES_SCOPED_RESOURCE_H_ |
| OLD | NEW |