| 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_PRIORITIZED_RESOURCE_H_ | 5 #ifndef CC_RESOURCES_PRIORITIZED_RESOURCE_H_ |
| 6 #define CC_RESOURCES_PRIORITIZED_RESOURCE_H_ | 6 #define CC_RESOURCES_PRIORITIZED_RESOURCE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "cc/resources/priority_calculator.h" | 12 #include "cc/resources/priority_calculator.h" |
| 13 #include "cc/resources/resource.h" | 13 #include "cc/resources/resource.h" |
| 14 #include "cc/resources/resource_provider.h" | 14 #include "cc/resources/resource_provider.h" |
| 15 #include "third_party/khronos/GLES2/gl2.h" | |
| 16 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 17 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
| 18 #include "ui/gfx/vector2d.h" | 17 #include "ui/gfx/vector2d.h" |
| 19 | 18 |
| 20 namespace cc { | 19 namespace cc { |
| 21 | 20 |
| 22 class PrioritizedResourceManager; | 21 class PrioritizedResourceManager; |
| 23 class Proxy; | 22 class Proxy; |
| 24 | 23 |
| 25 class CC_EXPORT PrioritizedResource { | 24 class CC_EXPORT PrioritizedResource { |
| 26 public: | 25 public: |
| 27 static scoped_ptr<PrioritizedResource> | 26 static scoped_ptr<PrioritizedResource> Create( |
| 28 Create(PrioritizedResourceManager* manager, gfx::Size size, GLenum format) { | 27 PrioritizedResourceManager* manager, |
| 28 gfx::Size size, |
| 29 ResourceFormat format) { |
| 29 return make_scoped_ptr(new PrioritizedResource(manager, size, format)); | 30 return make_scoped_ptr(new PrioritizedResource(manager, size, format)); |
| 30 } | 31 } |
| 31 static scoped_ptr<PrioritizedResource> Create( | 32 static scoped_ptr<PrioritizedResource> Create( |
| 32 PrioritizedResourceManager* manager) { | 33 PrioritizedResourceManager* manager) { |
| 33 return make_scoped_ptr(new PrioritizedResource(manager, gfx::Size(), 0)); | 34 return make_scoped_ptr( |
| 35 new PrioritizedResource(manager, gfx::Size(), RGBA_8888)); |
| 34 } | 36 } |
| 35 ~PrioritizedResource(); | 37 ~PrioritizedResource(); |
| 36 | 38 |
| 37 // Texture properties. Changing these causes the backing texture to be lost. | 39 // Texture properties. Changing these causes the backing texture to be lost. |
| 38 // Setting these to the same value is a no-op. | 40 // Setting these to the same value is a no-op. |
| 39 void SetTextureManager(PrioritizedResourceManager* manager); | 41 void SetTextureManager(PrioritizedResourceManager* manager); |
| 40 PrioritizedResourceManager* resource_manager() { return manager_; } | 42 PrioritizedResourceManager* resource_manager() { return manager_; } |
| 41 void SetDimensions(gfx::Size size, GLenum format); | 43 void SetDimensions(gfx::Size size, ResourceFormat format); |
| 42 GLenum format() const { return format_; } | 44 ResourceFormat format() const { return format_; } |
| 43 gfx::Size size() const { return size_; } | 45 gfx::Size size() const { return size_; } |
| 44 size_t bytes() const { return bytes_; } | 46 size_t bytes() const { return bytes_; } |
| 45 bool contents_swizzled() const { return contents_swizzled_; } | 47 bool contents_swizzled() const { return contents_swizzled_; } |
| 46 | 48 |
| 47 // Set priority for the requested texture. | 49 // Set priority for the requested texture. |
| 48 void set_request_priority(int priority) { priority_ = priority; } | 50 void set_request_priority(int priority) { priority_ = priority; } |
| 49 int request_priority() const { return priority_; } | 51 int request_priority() const { return priority_; } |
| 50 | 52 |
| 51 // After PrioritizedResource::PrioritizeTextures() is called, this returns | 53 // After PrioritizedResource::PrioritizeTextures() is called, this returns |
| 52 // if the the request succeeded and this texture can be acquired for use. | 54 // if the the request succeeded and this texture can be acquired for use. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 101 |
| 100 private: | 102 private: |
| 101 friend class PrioritizedResourceManager; | 103 friend class PrioritizedResourceManager; |
| 102 friend class PrioritizedResourceTest; | 104 friend class PrioritizedResourceTest; |
| 103 | 105 |
| 104 class Backing : public Resource { | 106 class Backing : public Resource { |
| 105 public: | 107 public: |
| 106 Backing(unsigned id, | 108 Backing(unsigned id, |
| 107 ResourceProvider* resource_provider, | 109 ResourceProvider* resource_provider, |
| 108 gfx::Size size, | 110 gfx::Size size, |
| 109 GLenum format); | 111 ResourceFormat format); |
| 110 ~Backing(); | 112 ~Backing(); |
| 111 void UpdatePriority(); | 113 void UpdatePriority(); |
| 112 void UpdateInDrawingImplTree(); | 114 void UpdateInDrawingImplTree(); |
| 113 | 115 |
| 114 PrioritizedResource* owner() { return owner_; } | 116 PrioritizedResource* owner() { return owner_; } |
| 115 bool CanBeRecycled() const; | 117 bool CanBeRecycled() const; |
| 116 int request_priority_at_last_priority_update() const { | 118 int request_priority_at_last_priority_update() const { |
| 117 return priority_at_last_priority_update_; | 119 return priority_at_last_priority_update_; |
| 118 } | 120 } |
| 119 bool was_above_priority_cutoff_at_last_priority_update() const { | 121 bool was_above_priority_cutoff_at_last_priority_update() const { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 139 bool resource_has_been_deleted_; | 141 bool resource_has_been_deleted_; |
| 140 | 142 |
| 141 #ifndef NDEBUG | 143 #ifndef NDEBUG |
| 142 ResourceProvider* resource_provider_; | 144 ResourceProvider* resource_provider_; |
| 143 #endif | 145 #endif |
| 144 DISALLOW_COPY_AND_ASSIGN(Backing); | 146 DISALLOW_COPY_AND_ASSIGN(Backing); |
| 145 }; | 147 }; |
| 146 | 148 |
| 147 PrioritizedResource(PrioritizedResourceManager* resource_manager, | 149 PrioritizedResource(PrioritizedResourceManager* resource_manager, |
| 148 gfx::Size size, | 150 gfx::Size size, |
| 149 GLenum format); | 151 ResourceFormat format); |
| 150 | 152 |
| 151 bool is_above_priority_cutoff() { return is_above_priority_cutoff_; } | 153 bool is_above_priority_cutoff() { return is_above_priority_cutoff_; } |
| 152 void set_above_priority_cutoff(bool is_above_priority_cutoff) { | 154 void set_above_priority_cutoff(bool is_above_priority_cutoff) { |
| 153 is_above_priority_cutoff_ = is_above_priority_cutoff; | 155 is_above_priority_cutoff_ = is_above_priority_cutoff; |
| 154 } | 156 } |
| 155 void set_manager_internal(PrioritizedResourceManager* manager) { | 157 void set_manager_internal(PrioritizedResourceManager* manager) { |
| 156 manager_ = manager; | 158 manager_ = manager; |
| 157 } | 159 } |
| 158 | 160 |
| 159 Backing* backing() const { return backing_; } | 161 Backing* backing() const { return backing_; } |
| 160 void Link(Backing* backing); | 162 void Link(Backing* backing); |
| 161 void Unlink(); | 163 void Unlink(); |
| 162 | 164 |
| 163 gfx::Size size_; | 165 gfx::Size size_; |
| 164 GLenum format_; | 166 ResourceFormat format_; |
| 165 size_t bytes_; | 167 size_t bytes_; |
| 166 bool contents_swizzled_; | 168 bool contents_swizzled_; |
| 167 | 169 |
| 168 int priority_; | 170 int priority_; |
| 169 bool is_above_priority_cutoff_; | 171 bool is_above_priority_cutoff_; |
| 170 bool is_self_managed_; | 172 bool is_self_managed_; |
| 171 | 173 |
| 172 Backing* backing_; | 174 Backing* backing_; |
| 173 PrioritizedResourceManager* manager_; | 175 PrioritizedResourceManager* manager_; |
| 174 | 176 |
| 175 DISALLOW_COPY_AND_ASSIGN(PrioritizedResource); | 177 DISALLOW_COPY_AND_ASSIGN(PrioritizedResource); |
| 176 }; | 178 }; |
| 177 | 179 |
| 178 } // namespace cc | 180 } // namespace cc |
| 179 | 181 |
| 180 #endif // CC_RESOURCES_PRIORITIZED_RESOURCE_H_ | 182 #endif // CC_RESOURCES_PRIORITIZED_RESOURCE_H_ |
| OLD | NEW |