| 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 | |
| 6 #ifndef CCResourceProvider_h | 5 #ifndef CCResourceProvider_h |
| 7 #define CCResourceProvider_h | 6 #define CCResourceProvider_h |
| 8 | 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "CCGraphicsContext.h" | 9 #include "CCGraphicsContext.h" |
| 10 #include "GraphicsContext3D.h" | 10 #include "GraphicsContext3D.h" |
| 11 #include "IntSize.h" | 11 #include "IntSize.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
| 14 #include "TextureCopier.h" | 14 #include "TextureCopier.h" |
| 15 #include <wtf/Deque.h> | 15 #include <wtf/Deque.h> |
| 16 #include <wtf/HashMap.h> | 16 #include <wtf/HashMap.h> |
| 17 #include <wtf/OwnPtr.h> | 17 #include <wtf/OwnPtr.h> |
| 18 #include <wtf/PassOwnPtr.h> | 18 #include <wtf/PassOwnPtr.h> |
| 19 #include <wtf/PassRefPtr.h> | 19 #include <wtf/PassRefPtr.h> |
| 20 #include <wtf/RefPtr.h> | 20 #include <wtf/RefPtr.h> |
| 21 #include <wtf/Vector.h> | 21 #include <wtf/Vector.h> |
| 22 | 22 |
| 23 namespace WebKit { | 23 namespace WebKit { |
| 24 class WebGraphicsContext3D; | 24 class WebGraphicsContext3D; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace cc { | 27 namespace cc { |
| 28 | 28 |
| 29 class IntRect; | 29 class IntRect; |
| 30 class LayerTextureSubImage; | 30 class LayerTextureSubImage; |
| 31 class TextureCopier; | 31 class TextureCopier; |
| 32 class TextureUploader; | 32 class TextureUploader; |
| 33 | 33 |
| 34 // Thread-safety notes: this class is not thread-safe and can only be called | 34 // Thread-safety notes: this class is not thread-safe and can only be called |
| 35 // from the thread it was created on (in practice, the compositor thread). | 35 // from the thread it was created on (in practice, the compositor thread). |
| 36 class CCResourceProvider { | 36 class CCResourceProvider { |
| 37 WTF_MAKE_NONCOPYABLE(CCResourceProvider); | |
| 38 public: | 37 public: |
| 39 typedef unsigned ResourceId; | 38 typedef unsigned ResourceId; |
| 40 typedef Vector<ResourceId> ResourceIdArray; | 39 typedef Vector<ResourceId> ResourceIdArray; |
| 41 typedef HashMap<ResourceId, ResourceId> ResourceIdMap; | 40 typedef HashMap<ResourceId, ResourceId> ResourceIdMap; |
| 42 enum TextureUsageHint { TextureUsageAny, TextureUsageFramebuffer }; | 41 enum TextureUsageHint { TextureUsageAny, TextureUsageFramebuffer }; |
| 43 enum ResourceType { | 42 enum ResourceType { |
| 44 GLTexture = 1, | 43 GLTexture = 1, |
| 45 Bitmap, | 44 Bitmap, |
| 46 }; | 45 }; |
| 47 struct Mailbox { | 46 struct Mailbox { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 static void debugNotifyContextLost(); | 151 static void debugNotifyContextLost(); |
| 153 static void debugIncrementCommitCount(); | 152 static void debugIncrementCommitCount(); |
| 154 static void debugNotifyPtmClearAllMemoryCount(); | 153 static void debugNotifyPtmClearAllMemoryCount(); |
| 155 static void debugNotifyPtmReduceMemoryOnImplThread(); | 154 static void debugNotifyPtmReduceMemoryOnImplThread(); |
| 156 | 155 |
| 157 // The following lock classes are part of the CCResourceProvider API and are | 156 // The following lock classes are part of the CCResourceProvider API and are |
| 158 // needed to read and write the resource contents. The user must ensure | 157 // needed to read and write the resource contents. The user must ensure |
| 159 // that they only use GL locks on GL resources, etc, and this is enforced | 158 // that they only use GL locks on GL resources, etc, and this is enforced |
| 160 // by assertions. | 159 // by assertions. |
| 161 class ScopedReadLockGL { | 160 class ScopedReadLockGL { |
| 162 WTF_MAKE_NONCOPYABLE(ScopedReadLockGL); | |
| 163 public: | 161 public: |
| 164 ScopedReadLockGL(CCResourceProvider*, CCResourceProvider::ResourceId); | 162 ScopedReadLockGL(CCResourceProvider*, CCResourceProvider::ResourceId); |
| 165 ~ScopedReadLockGL(); | 163 ~ScopedReadLockGL(); |
| 166 | 164 |
| 167 unsigned textureId() const { return m_textureId; } | 165 unsigned textureId() const { return m_textureId; } |
| 168 | 166 |
| 169 private: | 167 private: |
| 170 CCResourceProvider* m_resourceProvider; | 168 CCResourceProvider* m_resourceProvider; |
| 171 CCResourceProvider::ResourceId m_resourceId; | 169 CCResourceProvider::ResourceId m_resourceId; |
| 172 unsigned m_textureId; | 170 unsigned m_textureId; |
| 171 |
| 172 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGL); |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 class ScopedWriteLockGL { | 175 class ScopedWriteLockGL { |
| 176 WTF_MAKE_NONCOPYABLE(ScopedWriteLockGL); | |
| 177 public: | 176 public: |
| 178 ScopedWriteLockGL(CCResourceProvider*, CCResourceProvider::ResourceId); | 177 ScopedWriteLockGL(CCResourceProvider*, CCResourceProvider::ResourceId); |
| 179 ~ScopedWriteLockGL(); | 178 ~ScopedWriteLockGL(); |
| 180 | 179 |
| 181 unsigned textureId() const { return m_textureId; } | 180 unsigned textureId() const { return m_textureId; } |
| 182 | 181 |
| 183 private: | 182 private: |
| 184 CCResourceProvider* m_resourceProvider; | 183 CCResourceProvider* m_resourceProvider; |
| 185 CCResourceProvider::ResourceId m_resourceId; | 184 CCResourceProvider::ResourceId m_resourceId; |
| 186 unsigned m_textureId; | 185 unsigned m_textureId; |
| 186 |
| 187 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL); |
| 187 }; | 188 }; |
| 188 | 189 |
| 189 class ScopedReadLockSoftware { | 190 class ScopedReadLockSoftware { |
| 190 WTF_MAKE_NONCOPYABLE(ScopedReadLockSoftware); | |
| 191 public: | 191 public: |
| 192 ScopedReadLockSoftware(CCResourceProvider*, CCResourceProvider::Resource
Id); | 192 ScopedReadLockSoftware(CCResourceProvider*, CCResourceProvider::Resource
Id); |
| 193 ~ScopedReadLockSoftware(); | 193 ~ScopedReadLockSoftware(); |
| 194 | 194 |
| 195 const SkBitmap* skBitmap() const { return &m_skBitmap; } | 195 const SkBitmap* skBitmap() const { return &m_skBitmap; } |
| 196 | 196 |
| 197 private: | 197 private: |
| 198 CCResourceProvider* m_resourceProvider; | 198 CCResourceProvider* m_resourceProvider; |
| 199 CCResourceProvider::ResourceId m_resourceId; | 199 CCResourceProvider::ResourceId m_resourceId; |
| 200 SkBitmap m_skBitmap; | 200 SkBitmap m_skBitmap; |
| 201 |
| 202 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockSoftware); |
| 201 }; | 203 }; |
| 202 | 204 |
| 203 class ScopedWriteLockSoftware { | 205 class ScopedWriteLockSoftware { |
| 204 WTF_MAKE_NONCOPYABLE(ScopedWriteLockSoftware); | |
| 205 public: | 206 public: |
| 206 ScopedWriteLockSoftware(CCResourceProvider*, CCResourceProvider::Resourc
eId); | 207 ScopedWriteLockSoftware(CCResourceProvider*, CCResourceProvider::Resourc
eId); |
| 207 ~ScopedWriteLockSoftware(); | 208 ~ScopedWriteLockSoftware(); |
| 208 | 209 |
| 209 SkCanvas* skCanvas() { return m_skCanvas.get(); } | 210 SkCanvas* skCanvas() { return m_skCanvas.get(); } |
| 210 | 211 |
| 211 private: | 212 private: |
| 212 CCResourceProvider* m_resourceProvider; | 213 CCResourceProvider* m_resourceProvider; |
| 213 CCResourceProvider::ResourceId m_resourceId; | 214 CCResourceProvider::ResourceId m_resourceId; |
| 214 SkBitmap m_skBitmap; | 215 SkBitmap m_skBitmap; |
| 215 OwnPtr<SkCanvas> m_skCanvas; | 216 OwnPtr<SkCanvas> m_skCanvas; |
| 217 |
| 218 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware); |
| 216 }; | 219 }; |
| 217 | 220 |
| 218 private: | 221 private: |
| 219 struct Resource { | 222 struct Resource { |
| 220 Resource(); | 223 Resource(); |
| 221 Resource(unsigned textureId, int pool, const IntSize& size, GC3Denum for
mat); | 224 Resource(unsigned textureId, int pool, const IntSize& size, GC3Denum for
mat); |
| 222 Resource(uint8_t* pixels, int pool, const IntSize& size, GC3Denum format
); | 225 Resource(uint8_t* pixels, int pool, const IntSize& size, GC3Denum format
); |
| 223 | 226 |
| 224 unsigned glId; | 227 unsigned glId; |
| 225 uint8_t* pixels; | 228 uint8_t* pixels; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // Do not use these! | 279 // Do not use these! |
| 277 static int64 m_commitCount; | 280 static int64 m_commitCount; |
| 278 static int64 m_commitCountAtLastEviction; | 281 static int64 m_commitCountAtLastEviction; |
| 279 static int64 m_commitCountAtLastContextLost; | 282 static int64 m_commitCountAtLastContextLost; |
| 280 static int64 m_evictionCount; | 283 static int64 m_evictionCount; |
| 281 static int64 m_contextLostCount; | 284 static int64 m_contextLostCount; |
| 282 static int64 m_commitCountAtLastPtmClearAllMemoryCount; | 285 static int64 m_commitCountAtLastPtmClearAllMemoryCount; |
| 283 static int64 m_commitCountAtLastPtmReduceMemoryOnImplThread; | 286 static int64 m_commitCountAtLastPtmReduceMemoryOnImplThread; |
| 284 static int64 m_resourceProviderCreatedCount; | 287 static int64 m_resourceProviderCreatedCount; |
| 285 static int64 m_resourceProviderDestroyedCount; | 288 static int64 m_resourceProviderDestroyedCount; |
| 289 |
| 290 DISALLOW_COPY_AND_ASSIGN(CCResourceProvider); |
| 286 }; | 291 }; |
| 287 | 292 |
| 288 } | 293 } |
| 289 | 294 |
| 290 #endif | 295 #endif |
| OLD | NEW |