Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: cc/resource_provider.h

Issue 11365025: Make cc a component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/renderer.h ('k') | cc/resource_update.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 CCResourceProvider_h 5 #ifndef CCResourceProvider_h
6 #define CCResourceProvider_h 6 #define CCResourceProvider_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"
11 #include "cc/cc_export.h"
11 #include "cc/graphics_context.h" 12 #include "cc/graphics_context.h"
12 #include "cc/texture_copier.h" 13 #include "cc/texture_copier.h"
13 #include "third_party/khronos/GLES2/gl2.h" 14 #include "third_party/khronos/GLES2/gl2.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "third_party/skia/include/core/SkCanvas.h" 16 #include "third_party/skia/include/core/SkCanvas.h"
16 #include "ui/gfx/size.h" 17 #include "ui/gfx/size.h"
17 #include <deque> 18 #include <deque>
18 #include <vector> 19 #include <vector>
19 20
20 namespace WebKit { 21 namespace WebKit {
21 class WebGraphicsContext3D; 22 class WebGraphicsContext3D;
22 } 23 }
23 24
24 namespace gfx { 25 namespace gfx {
25 class Rect; 26 class Rect;
26 class Vector2d; 27 class Vector2d;
27 } 28 }
28 29
29 namespace cc { 30 namespace cc {
30 31
31 class LayerTextureSubImage;
32 class TextureCopier;
33 class TextureUploader; 32 class TextureUploader;
34 33
35 // 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
36 // 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).
37 class ResourceProvider { 36 class CC_EXPORT ResourceProvider {
38 public: 37 public:
39 typedef unsigned ResourceId; 38 typedef unsigned ResourceId;
40 typedef std::vector<ResourceId> ResourceIdArray; 39 typedef std::vector<ResourceId> ResourceIdArray;
41 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; 40 typedef base::hash_map<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 {
48 GLbyte name[64]; 47 GLbyte name[64];
49 }; 48 };
50 struct TransferableResource { 49 struct TransferableResource {
51 unsigned id; 50 unsigned id;
52 GLenum format; 51 GLenum format;
53 gfx::Size size; 52 gfx::Size size;
54 Mailbox mailbox; 53 Mailbox mailbox;
55 }; 54 };
56 typedef std::vector<TransferableResource> TransferableResourceArray; 55 typedef std::vector<TransferableResource> TransferableResourceArray;
57 struct TransferableResourceList { 56 struct CC_EXPORT TransferableResourceList {
58 TransferableResourceList(); 57 TransferableResourceList();
59 ~TransferableResourceList(); 58 ~TransferableResourceList();
60 59
61 TransferableResourceArray resources; 60 TransferableResourceArray resources;
62 unsigned syncPoint; 61 unsigned syncPoint;
63 }; 62 };
64 63
65 static scoped_ptr<ResourceProvider> create(GraphicsContext*); 64 static scoped_ptr<ResourceProvider> create(GraphicsContext*);
66 65
67 virtual ~ResourceProvider(); 66 virtual ~ResourceProvider();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // will wait on it. 146 // will wait on it.
148 void receiveFromParent(const TransferableResourceList&); 147 void receiveFromParent(const TransferableResourceList&);
149 148
150 // Only for testing 149 // Only for testing
151 size_t mailboxCount() const { return m_mailboxes.size(); } 150 size_t mailboxCount() const { return m_mailboxes.size(); }
152 151
153 // The following lock classes are part of the ResourceProvider API and are 152 // The following lock classes are part of the ResourceProvider API and are
154 // needed to read and write the resource contents. The user must ensure 153 // needed to read and write the resource contents. The user must ensure
155 // that they only use GL locks on GL resources, etc, and this is enforced 154 // that they only use GL locks on GL resources, etc, and this is enforced
156 // by assertions. 155 // by assertions.
157 class ScopedReadLockGL { 156 class CC_EXPORT ScopedReadLockGL {
158 public: 157 public:
159 ScopedReadLockGL(ResourceProvider*, ResourceProvider::ResourceId); 158 ScopedReadLockGL(ResourceProvider*, ResourceProvider::ResourceId);
160 ~ScopedReadLockGL(); 159 ~ScopedReadLockGL();
161 160
162 unsigned textureId() const { return m_textureId; } 161 unsigned textureId() const { return m_textureId; }
163 162
164 private: 163 private:
165 ResourceProvider* m_resourceProvider; 164 ResourceProvider* m_resourceProvider;
166 ResourceProvider::ResourceId m_resourceId; 165 ResourceProvider::ResourceId m_resourceId;
167 unsigned m_textureId; 166 unsigned m_textureId;
168 167
169 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGL); 168 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGL);
170 }; 169 };
171 170
172 class ScopedWriteLockGL { 171 class CC_EXPORT ScopedWriteLockGL {
173 public: 172 public:
174 ScopedWriteLockGL(ResourceProvider*, ResourceProvider::ResourceId); 173 ScopedWriteLockGL(ResourceProvider*, ResourceProvider::ResourceId);
175 ~ScopedWriteLockGL(); 174 ~ScopedWriteLockGL();
176 175
177 unsigned textureId() const { return m_textureId; } 176 unsigned textureId() const { return m_textureId; }
178 177
179 private: 178 private:
180 ResourceProvider* m_resourceProvider; 179 ResourceProvider* m_resourceProvider;
181 ResourceProvider::ResourceId m_resourceId; 180 ResourceProvider::ResourceId m_resourceId;
182 unsigned m_textureId; 181 unsigned m_textureId;
183 182
184 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL); 183 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL);
185 }; 184 };
186 185
187 class ScopedReadLockSoftware { 186 class CC_EXPORT ScopedReadLockSoftware {
188 public: 187 public:
189 ScopedReadLockSoftware(ResourceProvider*, ResourceProvider::ResourceId); 188 ScopedReadLockSoftware(ResourceProvider*, ResourceProvider::ResourceId);
190 ~ScopedReadLockSoftware(); 189 ~ScopedReadLockSoftware();
191 190
192 const SkBitmap* skBitmap() const { return &m_skBitmap; } 191 const SkBitmap* skBitmap() const { return &m_skBitmap; }
193 192
194 private: 193 private:
195 ResourceProvider* m_resourceProvider; 194 ResourceProvider* m_resourceProvider;
196 ResourceProvider::ResourceId m_resourceId; 195 ResourceProvider::ResourceId m_resourceId;
197 SkBitmap m_skBitmap; 196 SkBitmap m_skBitmap;
198 197
199 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockSoftware); 198 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockSoftware);
200 }; 199 };
201 200
202 class ScopedWriteLockSoftware { 201 class CC_EXPORT ScopedWriteLockSoftware {
203 public: 202 public:
204 ScopedWriteLockSoftware(ResourceProvider*, ResourceProvider::ResourceId) ; 203 ScopedWriteLockSoftware(ResourceProvider*, ResourceProvider::ResourceId) ;
205 ~ScopedWriteLockSoftware(); 204 ~ScopedWriteLockSoftware();
206 205
207 SkCanvas* skCanvas() { return m_skCanvas.get(); } 206 SkCanvas* skCanvas() { return m_skCanvas.get(); }
208 207
209 private: 208 private:
210 ResourceProvider* m_resourceProvider; 209 ResourceProvider* m_resourceProvider;
211 ResourceProvider::ResourceId m_resourceId; 210 ResourceProvider::ResourceId m_resourceId;
212 SkBitmap m_skBitmap; 211 SkBitmap m_skBitmap;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 scoped_ptr<TextureUploader> m_textureUploader; 276 scoped_ptr<TextureUploader> m_textureUploader;
278 scoped_ptr<AcceleratedTextureCopier> m_textureCopier; 277 scoped_ptr<AcceleratedTextureCopier> m_textureCopier;
279 int m_maxTextureSize; 278 int m_maxTextureSize;
280 279
281 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); 280 DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
282 }; 281 };
283 282
284 } 283 }
285 284
286 #endif 285 #endif
OLDNEW
« no previous file with comments | « cc/renderer.h ('k') | cc/resource_update.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698