| 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_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 18 matching lines...) Expand all Loading... |
| 29 #include "cc/resources/transferable_resource.h" | 29 #include "cc/resources/transferable_resource.h" |
| 30 #include "third_party/khronos/GLES2/gl2.h" | 30 #include "third_party/khronos/GLES2/gl2.h" |
| 31 #include "third_party/khronos/GLES2/gl2ext.h" | 31 #include "third_party/khronos/GLES2/gl2ext.h" |
| 32 #include "third_party/skia/include/core/SkBitmap.h" | 32 #include "third_party/skia/include/core/SkBitmap.h" |
| 33 #include "third_party/skia/include/core/SkCanvas.h" | 33 #include "third_party/skia/include/core/SkCanvas.h" |
| 34 #include "ui/gfx/geometry/size.h" | 34 #include "ui/gfx/geometry/size.h" |
| 35 | 35 |
| 36 class GrContext; | 36 class GrContext; |
| 37 | 37 |
| 38 namespace gpu { | 38 namespace gpu { |
| 39 class GpuMemoryBufferManager; |
| 39 namespace gles { | 40 namespace gles { |
| 40 class GLES2Interface; | 41 class GLES2Interface; |
| 41 } | 42 } |
| 42 } | 43 } |
| 43 | 44 |
| 44 namespace gfx { | 45 namespace gfx { |
| 45 class GpuMemoryBuffer; | 46 class GpuMemoryBuffer; |
| 46 class Rect; | 47 class Rect; |
| 47 class Vector2d; | 48 class Vector2d; |
| 48 } | 49 } |
| 49 | 50 |
| 50 namespace cc { | 51 namespace cc { |
| 51 class BlockingTaskRunner; | 52 class BlockingTaskRunner; |
| 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: | 61 private: |
| 62 struct Resource; | 62 struct Resource; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 75 }; | 75 }; |
| 76 enum ResourceType { | 76 enum ResourceType { |
| 77 InvalidType = 0, | 77 InvalidType = 0, |
| 78 GLTexture = 1, | 78 GLTexture = 1, |
| 79 Bitmap, | 79 Bitmap, |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 static scoped_ptr<ResourceProvider> Create( | 82 static scoped_ptr<ResourceProvider> Create( |
| 83 OutputSurface* output_surface, | 83 OutputSurface* output_surface, |
| 84 SharedBitmapManager* shared_bitmap_manager, | 84 SharedBitmapManager* shared_bitmap_manager, |
| 85 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 85 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 86 BlockingTaskRunner* blocking_main_thread_task_runner, | 86 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 87 int highp_threshold_min, | 87 int highp_threshold_min, |
| 88 bool use_rgba_4444_texture_format, | 88 bool use_rgba_4444_texture_format, |
| 89 size_t id_allocation_chunk_size); | 89 size_t id_allocation_chunk_size); |
| 90 virtual ~ResourceProvider(); | 90 virtual ~ResourceProvider(); |
| 91 | 91 |
| 92 void InitializeSoftware(); | 92 void InitializeSoftware(); |
| 93 void InitializeGL(); | 93 void InitializeGL(); |
| 94 | 94 |
| 95 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 95 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 public: | 312 public: |
| 313 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, | 313 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, |
| 314 ResourceProvider::ResourceId resource_id); | 314 ResourceProvider::ResourceId resource_id); |
| 315 ~ScopedWriteLockGpuMemoryBuffer(); | 315 ~ScopedWriteLockGpuMemoryBuffer(); |
| 316 | 316 |
| 317 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer(); | 317 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer(); |
| 318 | 318 |
| 319 private: | 319 private: |
| 320 ResourceProvider* resource_provider_; | 320 ResourceProvider* resource_provider_; |
| 321 ResourceProvider::Resource* resource_; | 321 ResourceProvider::Resource* resource_; |
| 322 GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 322 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
| 323 gfx::GpuMemoryBuffer* gpu_memory_buffer_; | 323 gfx::GpuMemoryBuffer* gpu_memory_buffer_; |
| 324 gfx::Size size_; | 324 gfx::Size size_; |
| 325 ResourceFormat format_; | 325 ResourceFormat format_; |
| 326 | 326 |
| 327 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); | 327 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); |
| 328 }; | 328 }; |
| 329 | 329 |
| 330 class CC_EXPORT ScopedWriteLockGr { | 330 class CC_EXPORT ScopedWriteLockGr { |
| 331 public: | 331 public: |
| 332 ScopedWriteLockGr(ResourceProvider* resource_provider, | 332 ScopedWriteLockGr(ResourceProvider* resource_provider, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 }; | 481 }; |
| 482 typedef base::hash_map<int, Child> ChildMap; | 482 typedef base::hash_map<int, Child> ChildMap; |
| 483 | 483 |
| 484 bool ReadLockFenceHasPassed(const Resource* resource) { | 484 bool ReadLockFenceHasPassed(const Resource* resource) { |
| 485 return !resource->read_lock_fence.get() || | 485 return !resource->read_lock_fence.get() || |
| 486 resource->read_lock_fence->HasPassed(); | 486 resource->read_lock_fence->HasPassed(); |
| 487 } | 487 } |
| 488 | 488 |
| 489 ResourceProvider(OutputSurface* output_surface, | 489 ResourceProvider(OutputSurface* output_surface, |
| 490 SharedBitmapManager* shared_bitmap_manager, | 490 SharedBitmapManager* shared_bitmap_manager, |
| 491 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 491 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 492 BlockingTaskRunner* blocking_main_thread_task_runner, | 492 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 493 int highp_threshold_min, | 493 int highp_threshold_min, |
| 494 bool use_rgba_4444_texture_format, | 494 bool use_rgba_4444_texture_format, |
| 495 size_t id_allocation_chunk_size); | 495 size_t id_allocation_chunk_size); |
| 496 | 496 |
| 497 void CleanUpGLIfNeeded(); | 497 void CleanUpGLIfNeeded(); |
| 498 | 498 |
| 499 Resource* GetResource(ResourceId id); | 499 Resource* GetResource(ResourceId id); |
| 500 const Resource* LockForRead(ResourceId id); | 500 const Resource* LockForRead(ResourceId id); |
| 501 void UnlockForRead(ResourceId id); | 501 void UnlockForRead(ResourceId id); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 525 // specified filter for both minification and magnification. Returns the | 525 // specified filter for both minification and magnification. Returns the |
| 526 // texture target used. The resource must be locked for reading. | 526 // texture target used. The resource must be locked for reading. |
| 527 GLenum BindForSampling(ResourceId resource_id, GLenum unit, GLenum filter); | 527 GLenum BindForSampling(ResourceId resource_id, GLenum unit, GLenum filter); |
| 528 | 528 |
| 529 // Returns NULL if the output_surface_ does not have a ContextProvider. | 529 // Returns NULL if the output_surface_ does not have a ContextProvider. |
| 530 gpu::gles2::GLES2Interface* ContextGL() const; | 530 gpu::gles2::GLES2Interface* ContextGL() const; |
| 531 class GrContext* GrContext() const; | 531 class GrContext* GrContext() const; |
| 532 | 532 |
| 533 OutputSurface* output_surface_; | 533 OutputSurface* output_surface_; |
| 534 SharedBitmapManager* shared_bitmap_manager_; | 534 SharedBitmapManager* shared_bitmap_manager_; |
| 535 GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 535 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
| 536 BlockingTaskRunner* blocking_main_thread_task_runner_; | 536 BlockingTaskRunner* blocking_main_thread_task_runner_; |
| 537 bool lost_output_surface_; | 537 bool lost_output_surface_; |
| 538 int highp_threshold_min_; | 538 int highp_threshold_min_; |
| 539 ResourceId next_id_; | 539 ResourceId next_id_; |
| 540 ResourceMap resources_; | 540 ResourceMap resources_; |
| 541 int next_child_; | 541 int next_child_; |
| 542 ChildMap children_; | 542 ChildMap children_; |
| 543 | 543 |
| 544 ResourceType default_resource_type_; | 544 ResourceType default_resource_type_; |
| 545 bool use_texture_storage_ext_; | 545 bool use_texture_storage_ext_; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 return format_gl_data_format[format]; | 609 return format_gl_data_format[format]; |
| 610 } | 610 } |
| 611 | 611 |
| 612 inline GLenum GLInternalFormat(ResourceFormat format) { | 612 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 613 return GLDataFormat(format); | 613 return GLDataFormat(format); |
| 614 } | 614 } |
| 615 | 615 |
| 616 } // namespace cc | 616 } // namespace cc |
| 617 | 617 |
| 618 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 618 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |