Chromium Code Reviews| 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_RESOURCE_PROVIDER_H_ | 5 #ifndef CC_RESOURCE_PROVIDER_H_ |
| 6 #define CC_RESOURCE_PROVIDER_H_ | 6 #define CC_RESOURCE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 // NOTE: if the syncPoint filed in TransferableResourceList is set, this | 125 // NOTE: if the syncPoint filed in TransferableResourceList is set, this |
| 126 // will wait on it. | 126 // will wait on it. |
| 127 void receiveFromChild(int child, const TransferableResourceList&); | 127 void receiveFromChild(int child, const TransferableResourceList&); |
| 128 | 128 |
| 129 // Receives resources from the parent, moving them from mailboxes. Resource IDs | 129 // Receives resources from the parent, moving them from mailboxes. Resource IDs |
| 130 // passed are in the child namespace. | 130 // passed are in the child namespace. |
| 131 // NOTE: if the syncPoint filed in TransferableResourceList is set, this | 131 // NOTE: if the syncPoint filed in TransferableResourceList is set, this |
| 132 // will wait on it. | 132 // will wait on it. |
| 133 void receiveFromParent(const TransferableResourceList&); | 133 void receiveFromParent(const TransferableResourceList&); |
| 134 | 134 |
| 135 // Bind the given GL resource to a texture target for sampling using the | |
| 136 // specified minification and magnification filters. The resource must be | |
| 137 // locked for reading. | |
| 138 void bindForSampling(ResourceProvider::ResourceId, GLenum target, GLenum min Filter = GL_LINEAR, GLenum magFilter = GL_LINEAR); | |
|
jamesr
2012/11/26 06:54:26
chrome style forbids default parameter values. can
Sami
2012/11/30 17:49:27
Ah, I wasn't exactly sure what style guide we're f
| |
| 139 | |
| 135 // The following lock classes are part of the ResourceProvider API and are | 140 // The following lock classes are part of the ResourceProvider API and are |
| 136 // needed to read and write the resource contents. The user must ensure | 141 // needed to read and write the resource contents. The user must ensure |
| 137 // that they only use GL locks on GL resources, etc, and this is enforced | 142 // that they only use GL locks on GL resources, etc, and this is enforced |
| 138 // by assertions. | 143 // by assertions. |
| 139 class CC_EXPORT ScopedReadLockGL { | 144 class CC_EXPORT ScopedReadLockGL { |
| 140 public: | 145 public: |
| 141 ScopedReadLockGL(ResourceProvider*, ResourceProvider::ResourceId); | 146 ScopedReadLockGL(ResourceProvider*, ResourceProvider::ResourceId); |
| 142 ~ScopedReadLockGL(); | 147 ~ScopedReadLockGL(); |
| 143 | 148 |
| 144 unsigned textureId() const { return m_textureId; } | 149 unsigned textureId() const { return m_textureId; } |
| 145 | 150 |
| 146 private: | 151 private: |
| 147 ResourceProvider* m_resourceProvider; | 152 ResourceProvider* m_resourceProvider; |
| 148 ResourceProvider::ResourceId m_resourceId; | 153 ResourceProvider::ResourceId m_resourceId; |
| 149 unsigned m_textureId; | 154 unsigned m_textureId; |
| 150 | 155 |
| 151 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGL); | 156 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGL); |
| 152 }; | 157 }; |
| 153 | 158 |
| 159 class CC_EXPORT ScopedSamplerGL : public ScopedReadLockGL { | |
| 160 public: | |
| 161 ScopedSamplerGL(ResourceProvider*, ResourceProvider::ResourceId, GLenum target, GLenum minFilter = GL_LINEAR, GLenum magFilter = GL_LINEAR); | |
| 162 | |
| 163 private: | |
| 164 DISALLOW_COPY_AND_ASSIGN(ScopedSamplerGL); | |
| 165 }; | |
| 166 | |
| 154 class CC_EXPORT ScopedWriteLockGL { | 167 class CC_EXPORT ScopedWriteLockGL { |
| 155 public: | 168 public: |
| 156 ScopedWriteLockGL(ResourceProvider*, ResourceProvider::ResourceId); | 169 ScopedWriteLockGL(ResourceProvider*, ResourceProvider::ResourceId); |
| 157 ~ScopedWriteLockGL(); | 170 ~ScopedWriteLockGL(); |
| 158 | 171 |
| 159 unsigned textureId() const { return m_textureId; } | 172 unsigned textureId() const { return m_textureId; } |
| 160 | 173 |
| 161 private: | 174 private: |
| 162 ResourceProvider* m_resourceProvider; | 175 ResourceProvider* m_resourceProvider; |
| 163 ResourceProvider::ResourceId m_resourceId; | 176 ResourceProvider::ResourceId m_resourceId; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 193 ResourceProvider::ResourceId m_resourceId; | 206 ResourceProvider::ResourceId m_resourceId; |
| 194 SkBitmap m_skBitmap; | 207 SkBitmap m_skBitmap; |
| 195 scoped_ptr<SkCanvas> m_skCanvas; | 208 scoped_ptr<SkCanvas> m_skCanvas; |
| 196 | 209 |
| 197 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware); | 210 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware); |
| 198 }; | 211 }; |
| 199 | 212 |
| 200 private: | 213 private: |
| 201 struct Resource { | 214 struct Resource { |
| 202 Resource(); | 215 Resource(); |
| 203 Resource(unsigned textureId, int pool, const gfx::Size& size, GLenum for mat); | 216 Resource(unsigned textureId, int pool, const gfx::Size& size, GLenum for mat, GLenum minFilter, GLenum magFilter); |
| 204 Resource(uint8_t* pixels, int pool, const gfx::Size& size, GLenum format ); | 217 Resource(uint8_t* pixels, int pool, const gfx::Size& size, GLenum format , GLenum minFilter, GLenum magFilter); |
| 205 | 218 |
| 206 unsigned glId; | 219 unsigned glId; |
| 207 Mailbox mailbox; | 220 Mailbox mailbox; |
| 208 uint8_t* pixels; | 221 uint8_t* pixels; |
| 209 int pool; | 222 int pool; |
| 210 int lockForReadCount; | 223 int lockForReadCount; |
| 211 bool lockedForWrite; | 224 bool lockedForWrite; |
| 212 bool external; | 225 bool external; |
| 213 bool exported; | 226 bool exported; |
| 214 bool markedForDeletion; | 227 bool markedForDeletion; |
| 215 gfx::Size size; | 228 gfx::Size size; |
| 216 GLenum format; | 229 GLenum format; |
| 230 // TODO: Use a separate sampler object for filter state. | |
|
jamesr
2012/11/26 06:54:26
not sure what this means.
in chromium style, TODO
Sami
2012/11/30 17:49:27
In more recent OpenGL versions the sampling state
| |
| 231 GLenum minFilter; | |
| 232 GLenum magFilter; | |
|
jamesr
2012/11/26 06:54:26
do we really need to support separate minification
Sami
2012/11/30 17:49:27
For now we only need matching filters so I'll go w
| |
| 217 ResourceType type; | 233 ResourceType type; |
| 218 }; | 234 }; |
| 219 typedef base::hash_map<ResourceId, Resource> ResourceMap; | 235 typedef base::hash_map<ResourceId, Resource> ResourceMap; |
| 220 struct Child { | 236 struct Child { |
| 221 Child(); | 237 Child(); |
| 222 ~Child(); | 238 ~Child(); |
| 223 | 239 |
| 224 int pool; | 240 int pool; |
| 225 ResourceIdMap childToParentMap; | 241 ResourceIdMap childToParentMap; |
| 226 ResourceIdMap parentToChildMap; | 242 ResourceIdMap parentToChildMap; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 254 int m_maxTextureSize; | 270 int m_maxTextureSize; |
| 255 | 271 |
| 256 base::ThreadChecker m_threadChecker; | 272 base::ThreadChecker m_threadChecker; |
| 257 | 273 |
| 258 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 274 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 259 }; | 275 }; |
| 260 | 276 |
| 261 } | 277 } |
| 262 | 278 |
| 263 #endif // CC_RESOURCE_PROVIDER_H_ | 279 #endif // CC_RESOURCE_PROVIDER_H_ |
| OLD | NEW |