| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 namespace WebCore { | 38 namespace WebCore { |
| 39 | 39 |
| 40 class ManagedTexture; | 40 class ManagedTexture; |
| 41 typedef int TextureToken; | 41 typedef int TextureToken; |
| 42 | 42 |
| 43 class TextureAllocator { | 43 class TextureAllocator { |
| 44 public: | 44 public: |
| 45 virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0; | 45 virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0; |
| 46 virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0; | 46 virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0; |
| 47 virtual void deleteAllTextures() = 0; |
| 47 | 48 |
| 48 protected: | 49 protected: |
| 49 virtual ~TextureAllocator() { } | 50 virtual ~TextureAllocator() { } |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 class TextureManager { | 53 class TextureManager { |
| 53 WTF_MAKE_NONCOPYABLE(TextureManager); | 54 WTF_MAKE_NONCOPYABLE(TextureManager); |
| 54 public: | 55 public: |
| 55 static PassOwnPtr<TextureManager> create(size_t maxMemoryLimitBytes, size_t
preferredMemoryLimitBytes, int maxTextureSize) | 56 static PassOwnPtr<TextureManager> create(size_t maxMemoryLimitBytes, size_t
preferredMemoryLimitBytes, int maxTextureSize) |
| 56 { | 57 { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 bool requestTexture(TextureToken, IntSize, GC3Denum textureFormat); | 82 bool requestTexture(TextureToken, IntSize, GC3Denum textureFormat); |
| 82 | 83 |
| 83 void protectTexture(TextureToken); | 84 void protectTexture(TextureToken); |
| 84 void unprotectTexture(TextureToken); | 85 void unprotectTexture(TextureToken); |
| 85 void unprotectAllTextures(); | 86 void unprotectAllTextures(); |
| 86 bool isProtected(TextureToken); | 87 bool isProtected(TextureToken); |
| 87 | 88 |
| 88 unsigned allocateTexture(TextureAllocator*, TextureToken); | 89 unsigned allocateTexture(TextureAllocator*, TextureToken); |
| 89 void deleteEvictedTextures(TextureAllocator*); | 90 void deleteEvictedTextures(TextureAllocator*); |
| 90 | 91 |
| 92 void evictAndRemoveAllDeletedTextures(); |
| 91 void evictAndDeleteAllTextures(TextureAllocator*); | 93 void evictAndDeleteAllTextures(TextureAllocator*); |
| 92 | 94 |
| 93 void reduceMemoryToLimit(size_t); | 95 void reduceMemoryToLimit(size_t); |
| 94 size_t currentMemoryUseBytes() const { return m_memoryUseBytes; } | 96 size_t currentMemoryUseBytes() const { return m_memoryUseBytes; } |
| 95 | 97 |
| 96 private: | 98 private: |
| 97 TextureManager(size_t maxMemoryLimitBytes, size_t preferredMemoryLimitBytes,
int maxTextureSize); | 99 TextureManager(size_t maxMemoryLimitBytes, size_t preferredMemoryLimitBytes,
int maxTextureSize); |
| 98 | 100 |
| 99 struct TextureInfo { | 101 struct TextureInfo { |
| 100 IntSize size; | 102 IntSize size; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 130 TextureAllocator* allocator; | 132 TextureAllocator* allocator; |
| 131 #endif | 133 #endif |
| 132 }; | 134 }; |
| 133 | 135 |
| 134 Vector<EvictionEntry> m_evictedTextures; | 136 Vector<EvictionEntry> m_evictedTextures; |
| 135 }; | 137 }; |
| 136 | 138 |
| 137 } | 139 } |
| 138 | 140 |
| 139 #endif | 141 #endif |
| OLD | NEW |