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

Side by Side Diff: cc/resources/resource_provider.h

Issue 645943002: cc: Move GpuMemoryBuffer allocation to worker threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chromium-image-refactor
Patch Set: address review feedback Created 6 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
« no previous file with comments | « cc/resources/one_copy_raster_worker_pool.cc ('k') | cc/resources/resource_provider.cc » ('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 CC_RESOURCES_RESOURCE_PROVIDER_H_ 5 #ifndef CC_RESOURCES_RESOURCE_PROVIDER_H_
6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_ 6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 class BlockingTaskRunner; 51 class BlockingTaskRunner;
52 class GpuMemoryBufferManager; 52 class GpuMemoryBufferManager;
53 class IdAllocator; 53 class IdAllocator;
54 class SharedBitmap; 54 class SharedBitmap;
55 class SharedBitmapManager; 55 class SharedBitmapManager;
56 class TextureUploader; 56 class TextureUploader;
57 57
58 // This class is not thread-safe and can only be called from the thread it was 58 // This class is not thread-safe and can only be called from the thread it was
59 // created on (in practice, the impl thread). 59 // created on (in practice, the impl thread).
60 class CC_EXPORT ResourceProvider { 60 class CC_EXPORT ResourceProvider {
61 private:
62 struct Resource;
63
61 public: 64 public:
62 typedef unsigned ResourceId; 65 typedef unsigned ResourceId;
63 typedef std::vector<ResourceId> ResourceIdArray; 66 typedef std::vector<ResourceId> ResourceIdArray;
64 typedef std::set<ResourceId> ResourceIdSet; 67 typedef std::set<ResourceId> ResourceIdSet;
65 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; 68 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap;
66 enum TextureHint { 69 enum TextureHint {
67 TextureHintDefault = 0x0, 70 TextureHintDefault = 0x0,
68 TextureHintImmutable = 0x1, 71 TextureHintImmutable = 0x1,
69 TextureHintFramebuffer = 0x2, 72 TextureHintFramebuffer = 0x2,
70 TextureHintImmutableFramebuffer = 73 TextureHintImmutableFramebuffer =
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 class CC_EXPORT ScopedWriteLockGL { 254 class CC_EXPORT ScopedWriteLockGL {
252 public: 255 public:
253 ScopedWriteLockGL(ResourceProvider* resource_provider, 256 ScopedWriteLockGL(ResourceProvider* resource_provider,
254 ResourceProvider::ResourceId resource_id); 257 ResourceProvider::ResourceId resource_id);
255 ~ScopedWriteLockGL(); 258 ~ScopedWriteLockGL();
256 259
257 unsigned texture_id() const { return texture_id_; } 260 unsigned texture_id() const { return texture_id_; }
258 261
259 private: 262 private:
260 ResourceProvider* resource_provider_; 263 ResourceProvider* resource_provider_;
261 ResourceProvider::ResourceId resource_id_; 264 ResourceProvider::Resource* resource_;
262 unsigned texture_id_; 265 unsigned texture_id_;
263 266
264 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL); 267 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL);
265 }; 268 };
266 269
267 class CC_EXPORT ScopedReadLockSoftware { 270 class CC_EXPORT ScopedReadLockSoftware {
268 public: 271 public:
269 ScopedReadLockSoftware(ResourceProvider* resource_provider, 272 ScopedReadLockSoftware(ResourceProvider* resource_provider,
270 ResourceProvider::ResourceId resource_id); 273 ResourceProvider::ResourceId resource_id);
271 ~ScopedReadLockSoftware(); 274 ~ScopedReadLockSoftware();
(...skipping 19 matching lines...) Expand all
291 public: 294 public:
292 ScopedWriteLockSoftware(ResourceProvider* resource_provider, 295 ScopedWriteLockSoftware(ResourceProvider* resource_provider,
293 ResourceProvider::ResourceId resource_id); 296 ResourceProvider::ResourceId resource_id);
294 ~ScopedWriteLockSoftware(); 297 ~ScopedWriteLockSoftware();
295 298
296 SkCanvas* sk_canvas() { return sk_canvas_.get(); } 299 SkCanvas* sk_canvas() { return sk_canvas_.get(); }
297 bool valid() const { return !!sk_bitmap_.getPixels(); } 300 bool valid() const { return !!sk_bitmap_.getPixels(); }
298 301
299 private: 302 private:
300 ResourceProvider* resource_provider_; 303 ResourceProvider* resource_provider_;
301 ResourceProvider::ResourceId resource_id_; 304 ResourceProvider::Resource* resource_;
302 SkBitmap sk_bitmap_; 305 SkBitmap sk_bitmap_;
303 scoped_ptr<SkCanvas> sk_canvas_; 306 scoped_ptr<SkCanvas> sk_canvas_;
304 307
305 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware); 308 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware);
306 }; 309 };
307 310
308 class CC_EXPORT ScopedWriteLockGpuMemoryBuffer { 311 class CC_EXPORT ScopedWriteLockGpuMemoryBuffer {
309 public: 312 public:
310 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, 313 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider,
311 ResourceProvider::ResourceId resource_id); 314 ResourceProvider::ResourceId resource_id);
312 ~ScopedWriteLockGpuMemoryBuffer(); 315 ~ScopedWriteLockGpuMemoryBuffer();
313 316
314 gfx::GpuMemoryBuffer* gpu_memory_buffer() { return gpu_memory_buffer_; } 317 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer();
315 318
316 private: 319 private:
317 ResourceProvider* resource_provider_; 320 ResourceProvider* resource_provider_;
318 ResourceProvider::ResourceId resource_id_; 321 ResourceProvider::Resource* resource_;
322 GpuMemoryBufferManager* gpu_memory_buffer_manager_;
319 gfx::GpuMemoryBuffer* gpu_memory_buffer_; 323 gfx::GpuMemoryBuffer* gpu_memory_buffer_;
324 gfx::Size size_;
325 ResourceFormat format_;
320 326
321 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); 327 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer);
322 }; 328 };
323 329
324 class CC_EXPORT ScopedWriteLockGr { 330 class CC_EXPORT ScopedWriteLockGr {
325 public: 331 public:
326 ScopedWriteLockGr(ResourceProvider* resource_provider, 332 ScopedWriteLockGr(ResourceProvider* resource_provider,
327 ResourceProvider::ResourceId resource_id); 333 ResourceProvider::ResourceId resource_id);
328 ~ScopedWriteLockGr(); 334 ~ScopedWriteLockGr();
329 335
330 SkSurface* GetSkSurface(bool use_distance_field_text); 336 SkSurface* GetSkSurface(bool use_distance_field_text);
331 337
332 private: 338 private:
333 ResourceProvider* resource_provider_; 339 ResourceProvider* resource_provider_;
334 ResourceProvider::ResourceId resource_id_; 340 ResourceProvider::Resource* resource_;
335 341
336 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGr); 342 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGr);
337 }; 343 };
338 344
339 class Fence : public base::RefCounted<Fence> { 345 class Fence : public base::RefCounted<Fence> {
340 public: 346 public:
341 Fence() {} 347 Fence() {}
342 348
343 virtual void Set() = 0; 349 virtual void Set() = 0;
344 virtual bool HasPassed() = 0; 350 virtual bool HasPassed() = 0;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 BlockingTaskRunner* blocking_main_thread_task_runner, 492 BlockingTaskRunner* blocking_main_thread_task_runner,
487 int highp_threshold_min, 493 int highp_threshold_min,
488 bool use_rgba_4444_texture_format, 494 bool use_rgba_4444_texture_format,
489 size_t id_allocation_chunk_size); 495 size_t id_allocation_chunk_size);
490 496
491 void CleanUpGLIfNeeded(); 497 void CleanUpGLIfNeeded();
492 498
493 Resource* GetResource(ResourceId id); 499 Resource* GetResource(ResourceId id);
494 const Resource* LockForRead(ResourceId id); 500 const Resource* LockForRead(ResourceId id);
495 void UnlockForRead(ResourceId id); 501 void UnlockForRead(ResourceId id);
496 const Resource* LockForWrite(ResourceId id); 502 Resource* LockForWrite(ResourceId id);
497 void UnlockForWrite(ResourceId id); 503 void UnlockForWrite(Resource* resource);
498 const Resource* LockForWriteToGpuMemoryBuffer(ResourceId id);
499 void UnlockForWriteToGpuMemoryBuffer(ResourceId id);
500 void LockForWriteToSkSurface(ResourceId id);
501 void UnlockForWriteToSkSurface(ResourceId id);
502 504
503 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, 505 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap,
504 const Resource* resource); 506 const Resource* resource);
505 507
506 void TransferResource(gpu::gles2::GLES2Interface* gl, 508 void TransferResource(gpu::gles2::GLES2Interface* gl,
507 ResourceId id, 509 ResourceId id,
508 TransferableResource* resource); 510 TransferableResource* resource);
509 enum DeleteStyle { 511 enum DeleteStyle {
510 Normal, 512 Normal,
511 ForShutdown, 513 ForShutdown,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 return format_gl_data_format[format]; 609 return format_gl_data_format[format];
608 } 610 }
609 611
610 inline GLenum GLInternalFormat(ResourceFormat format) { 612 inline GLenum GLInternalFormat(ResourceFormat format) {
611 return GLDataFormat(format); 613 return GLDataFormat(format);
612 } 614 }
613 615
614 } // namespace cc 616 } // namespace cc
615 617
616 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 618 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW
« no previous file with comments | « cc/resources/one_copy_raster_worker_pool.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698