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