| 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 ResourceProvider::Format 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, |
| 36 gfx::Size(), |
| 37 ResourceProvider::RGBA_8888)); |
| 34 } | 38 } |
| 35 ~PrioritizedResource(); | 39 ~PrioritizedResource(); |
| 36 | 40 |
| 37 // Texture properties. Changing these causes the backing texture to be lost. | 41 // Texture properties. Changing these causes the backing texture to be lost. |
| 38 // Setting these to the same value is a no-op. | 42 // Setting these to the same value is a no-op. |
| 39 void SetTextureManager(PrioritizedResourceManager* manager); | 43 void SetTextureManager(PrioritizedResourceManager* manager); |
| 40 PrioritizedResourceManager* resource_manager() { return manager_; } | 44 PrioritizedResourceManager* resource_manager() { return manager_; } |
| 41 void SetDimensions(gfx::Size size, GLenum format); | 45 void SetDimensions(gfx::Size size, ResourceProvider::Format format); |
| 42 GLenum format() const { return format_; } | 46 ResourceProvider::Format format() const { return format_; } |
| 43 gfx::Size size() const { return size_; } | 47 gfx::Size size() const { return size_; } |
| 44 size_t bytes() const { return bytes_; } | 48 size_t bytes() const { return bytes_; } |
| 45 bool contents_swizzled() const { return contents_swizzled_; } | 49 bool contents_swizzled() const { return contents_swizzled_; } |
| 46 | 50 |
| 47 // Set priority for the requested texture. | 51 // Set priority for the requested texture. |
| 48 void set_request_priority(int priority) { priority_ = priority; } | 52 void set_request_priority(int priority) { priority_ = priority; } |
| 49 int request_priority() const { return priority_; } | 53 int request_priority() const { return priority_; } |
| 50 | 54 |
| 51 // After PrioritizedResource::PrioritizeTextures() is called, this returns | 55 // After PrioritizedResource::PrioritizeTextures() is called, this returns |
| 52 // if the the request succeeded and this texture can be acquired for use. | 56 // 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 | 103 |
| 100 private: | 104 private: |
| 101 friend class PrioritizedResourceManager; | 105 friend class PrioritizedResourceManager; |
| 102 friend class PrioritizedResourceTest; | 106 friend class PrioritizedResourceTest; |
| 103 | 107 |
| 104 class Backing : public Resource { | 108 class Backing : public Resource { |
| 105 public: | 109 public: |
| 106 Backing(unsigned id, | 110 Backing(unsigned id, |
| 107 ResourceProvider* resource_provider, | 111 ResourceProvider* resource_provider, |
| 108 gfx::Size size, | 112 gfx::Size size, |
| 109 GLenum format); | 113 ResourceProvider::Format format); |
| 110 ~Backing(); | 114 ~Backing(); |
| 111 void UpdatePriority(); | 115 void UpdatePriority(); |
| 112 void UpdateInDrawingImplTree(); | 116 void UpdateInDrawingImplTree(); |
| 113 | 117 |
| 114 PrioritizedResource* owner() { return owner_; } | 118 PrioritizedResource* owner() { return owner_; } |
| 115 bool CanBeRecycled() const; | 119 bool CanBeRecycled() const; |
| 116 int request_priority_at_last_priority_update() const { | 120 int request_priority_at_last_priority_update() const { |
| 117 return priority_at_last_priority_update_; | 121 return priority_at_last_priority_update_; |
| 118 } | 122 } |
| 119 bool was_above_priority_cutoff_at_last_priority_update() const { | 123 bool was_above_priority_cutoff_at_last_priority_update() const { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 139 bool resource_has_been_deleted_; | 143 bool resource_has_been_deleted_; |
| 140 | 144 |
| 141 #ifndef NDEBUG | 145 #ifndef NDEBUG |
| 142 ResourceProvider* resource_provider_; | 146 ResourceProvider* resource_provider_; |
| 143 #endif | 147 #endif |
| 144 DISALLOW_COPY_AND_ASSIGN(Backing); | 148 DISALLOW_COPY_AND_ASSIGN(Backing); |
| 145 }; | 149 }; |
| 146 | 150 |
| 147 PrioritizedResource(PrioritizedResourceManager* resource_manager, | 151 PrioritizedResource(PrioritizedResourceManager* resource_manager, |
| 148 gfx::Size size, | 152 gfx::Size size, |
| 149 GLenum format); | 153 ResourceProvider::Format format); |
| 150 | 154 |
| 151 bool is_above_priority_cutoff() { return is_above_priority_cutoff_; } | 155 bool is_above_priority_cutoff() { return is_above_priority_cutoff_; } |
| 152 void set_above_priority_cutoff(bool is_above_priority_cutoff) { | 156 void set_above_priority_cutoff(bool is_above_priority_cutoff) { |
| 153 is_above_priority_cutoff_ = is_above_priority_cutoff; | 157 is_above_priority_cutoff_ = is_above_priority_cutoff; |
| 154 } | 158 } |
| 155 void set_manager_internal(PrioritizedResourceManager* manager) { | 159 void set_manager_internal(PrioritizedResourceManager* manager) { |
| 156 manager_ = manager; | 160 manager_ = manager; |
| 157 } | 161 } |
| 158 | 162 |
| 159 Backing* backing() const { return backing_; } | 163 Backing* backing() const { return backing_; } |
| 160 void Link(Backing* backing); | 164 void Link(Backing* backing); |
| 161 void Unlink(); | 165 void Unlink(); |
| 162 | 166 |
| 163 gfx::Size size_; | 167 gfx::Size size_; |
| 164 GLenum format_; | 168 ResourceProvider::Format format_; |
| 165 size_t bytes_; | 169 size_t bytes_; |
| 166 bool contents_swizzled_; | 170 bool contents_swizzled_; |
| 167 | 171 |
| 168 int priority_; | 172 int priority_; |
| 169 bool is_above_priority_cutoff_; | 173 bool is_above_priority_cutoff_; |
| 170 bool is_self_managed_; | 174 bool is_self_managed_; |
| 171 | 175 |
| 172 Backing* backing_; | 176 Backing* backing_; |
| 173 PrioritizedResourceManager* manager_; | 177 PrioritizedResourceManager* manager_; |
| 174 | 178 |
| 175 DISALLOW_COPY_AND_ASSIGN(PrioritizedResource); | 179 DISALLOW_COPY_AND_ASSIGN(PrioritizedResource); |
| 176 }; | 180 }; |
| 177 | 181 |
| 178 } // namespace cc | 182 } // namespace cc |
| 179 | 183 |
| 180 #endif // CC_RESOURCES_PRIORITIZED_RESOURCE_H_ | 184 #endif // CC_RESOURCES_PRIORITIZED_RESOURCE_H_ |
| OLD | NEW |