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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 public: | 281 public: |
282 ScopedWriteLockGL(ResourceProvider* resource_provider, | 282 ScopedWriteLockGL(ResourceProvider* resource_provider, |
283 ResourceId resource_id, | 283 ResourceId resource_id, |
284 bool create_mailbox); | 284 bool create_mailbox); |
285 ~ScopedWriteLockGL(); | 285 ~ScopedWriteLockGL(); |
286 | 286 |
287 unsigned texture_id() const { return texture_id_; } | 287 unsigned texture_id() const { return texture_id_; } |
288 GLenum target() const { return target_; } | 288 GLenum target() const { return target_; } |
289 ResourceFormat format() const { return format_; } | 289 ResourceFormat format() const { return format_; } |
290 const gfx::Size& size() const { return size_; } | 290 const gfx::Size& size() const { return size_; } |
291 sk_sp<SkColorSpace> sk_color_space() const { return sk_color_space_; } | 291 // Will return the invalid color space unless |
| 292 // |enable_color_correct_rasterization| is true. |
| 293 const gfx::ColorSpace& color_space_for_raster() const { |
| 294 return color_space_; |
| 295 } |
292 | 296 |
293 const TextureMailbox& mailbox() const { return mailbox_; } | 297 const TextureMailbox& mailbox() const { return mailbox_; } |
294 | 298 |
295 void set_sync_token(const gpu::SyncToken& sync_token) { | 299 void set_sync_token(const gpu::SyncToken& sync_token) { |
296 sync_token_ = sync_token; | 300 sync_token_ = sync_token; |
297 has_sync_token_ = true; | 301 has_sync_token_ = true; |
298 } | 302 } |
299 | 303 |
300 void set_synchronized(bool synchronized) { synchronized_ = synchronized; } | 304 void set_synchronized(bool synchronized) { synchronized_ = synchronized; } |
301 | 305 |
302 private: | 306 private: |
303 ResourceProvider* resource_provider_; | 307 ResourceProvider* resource_provider_; |
304 ResourceId resource_id_; | 308 ResourceId resource_id_; |
305 unsigned texture_id_; | 309 unsigned texture_id_; |
306 GLenum target_; | 310 GLenum target_; |
307 ResourceFormat format_; | 311 ResourceFormat format_; |
308 gfx::Size size_; | 312 gfx::Size size_; |
309 TextureMailbox mailbox_; | 313 TextureMailbox mailbox_; |
310 gpu::SyncToken sync_token_; | 314 gpu::SyncToken sync_token_; |
311 bool has_sync_token_; | 315 bool has_sync_token_; |
312 bool synchronized_; | 316 bool synchronized_; |
313 base::ThreadChecker thread_checker_; | 317 base::ThreadChecker thread_checker_; |
314 sk_sp<SkColorSpace> sk_color_space_; | 318 gfx::ColorSpace color_space_; |
315 | 319 |
316 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL); | 320 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL); |
317 }; | 321 }; |
318 | 322 |
319 class CC_EXPORT ScopedTextureProvider { | 323 class CC_EXPORT ScopedTextureProvider { |
320 public: | 324 public: |
321 ScopedTextureProvider(gpu::gles2::GLES2Interface* gl, | 325 ScopedTextureProvider(gpu::gles2::GLES2Interface* gl, |
322 ScopedWriteLockGL* resource_lock, | 326 ScopedWriteLockGL* resource_lock, |
323 bool use_mailbox); | 327 bool use_mailbox); |
324 ~ScopedTextureProvider(); | 328 ~ScopedTextureProvider(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 }; | 396 }; |
393 | 397 |
394 class CC_EXPORT ScopedWriteLockSoftware { | 398 class CC_EXPORT ScopedWriteLockSoftware { |
395 public: | 399 public: |
396 ScopedWriteLockSoftware(ResourceProvider* resource_provider, | 400 ScopedWriteLockSoftware(ResourceProvider* resource_provider, |
397 ResourceId resource_id); | 401 ResourceId resource_id); |
398 ~ScopedWriteLockSoftware(); | 402 ~ScopedWriteLockSoftware(); |
399 | 403 |
400 SkBitmap& sk_bitmap() { return sk_bitmap_; } | 404 SkBitmap& sk_bitmap() { return sk_bitmap_; } |
401 bool valid() const { return !!sk_bitmap_.getPixels(); } | 405 bool valid() const { return !!sk_bitmap_.getPixels(); } |
402 sk_sp<SkColorSpace> sk_color_space() const { return sk_color_space_; } | 406 // Will return the invalid color space unless |
| 407 // |enable_color_correct_rasterization| is true. |
| 408 const gfx::ColorSpace& color_space_for_raster() const { |
| 409 return color_space_; |
| 410 } |
403 | 411 |
404 private: | 412 private: |
405 ResourceProvider* resource_provider_; | 413 ResourceProvider* resource_provider_; |
406 ResourceId resource_id_; | 414 ResourceId resource_id_; |
407 SkBitmap sk_bitmap_; | 415 SkBitmap sk_bitmap_; |
408 sk_sp<SkColorSpace> sk_color_space_; | 416 gfx::ColorSpace color_space_; |
409 base::ThreadChecker thread_checker_; | 417 base::ThreadChecker thread_checker_; |
410 | 418 |
411 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware); | 419 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware); |
412 }; | 420 }; |
413 | 421 |
414 class CC_EXPORT ScopedWriteLockGpuMemoryBuffer { | 422 class CC_EXPORT ScopedWriteLockGpuMemoryBuffer { |
415 public: | 423 public: |
416 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, | 424 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, |
417 ResourceId resource_id); | 425 ResourceId resource_id); |
418 ~ScopedWriteLockGpuMemoryBuffer(); | 426 ~ScopedWriteLockGpuMemoryBuffer(); |
419 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer(); | 427 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer(); |
420 sk_sp<SkColorSpace> sk_color_space() const { return sk_color_space_; } | 428 // Will return the invalid color space unless |
| 429 // |enable_color_correct_rasterization| is true. |
| 430 const gfx::ColorSpace& color_space_for_raster() const { |
| 431 return color_space_; |
| 432 } |
421 | 433 |
422 private: | 434 private: |
423 ResourceProvider* resource_provider_; | 435 ResourceProvider* resource_provider_; |
424 ResourceId resource_id_; | 436 ResourceId resource_id_; |
425 ResourceFormat format_; | 437 ResourceFormat format_; |
426 gfx::BufferUsage usage_; | 438 gfx::BufferUsage usage_; |
427 gfx::Size size_; | 439 gfx::Size size_; |
428 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; | 440 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; |
429 sk_sp<SkColorSpace> sk_color_space_; | 441 gfx::ColorSpace color_space_; |
430 base::ThreadChecker thread_checker_; | 442 base::ThreadChecker thread_checker_; |
431 | 443 |
432 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); | 444 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); |
433 }; | 445 }; |
434 | 446 |
435 class Fence : public base::RefCounted<Fence> { | 447 class Fence : public base::RefCounted<Fence> { |
436 public: | 448 public: |
437 Fence() {} | 449 Fence() {} |
438 | 450 |
439 virtual void Set() = 0; | 451 virtual void Set() = 0; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 void BindImageForSampling(Resource* resource); | 728 void BindImageForSampling(Resource* resource); |
717 // Binds the given GL resource to a texture target for sampling using the | 729 // Binds the given GL resource to a texture target for sampling using the |
718 // specified filter for both minification and magnification. Returns the | 730 // specified filter for both minification and magnification. Returns the |
719 // texture target used. The resource must be locked for reading. | 731 // texture target used. The resource must be locked for reading. |
720 GLenum BindForSampling(ResourceId resource_id, GLenum unit, GLenum filter); | 732 GLenum BindForSampling(ResourceId resource_id, GLenum unit, GLenum filter); |
721 | 733 |
722 // Returns null if we do not have a ContextProvider. | 734 // Returns null if we do not have a ContextProvider. |
723 gpu::gles2::GLES2Interface* ContextGL() const; | 735 gpu::gles2::GLES2Interface* ContextGL() const; |
724 bool IsGLContextLost() const; | 736 bool IsGLContextLost() const; |
725 | 737 |
726 // Returns null if |settings_.enable_color_correct_rasterization| is false. | 738 // Will return the invalid color space unless |
727 sk_sp<SkColorSpace> GetResourceSkColorSpace(const Resource* resource) const; | 739 // |enable_color_correct_rasterization| is true. |
| 740 gfx::ColorSpace GetResourceColorSpaceForRaster( |
| 741 const Resource* resource) const; |
728 | 742 |
729 // Holds const settings for the ResourceProvider. Never changed after init. | 743 // Holds const settings for the ResourceProvider. Never changed after init. |
730 struct Settings { | 744 struct Settings { |
731 Settings(ContextProvider* compositor_context_provider, | 745 Settings(ContextProvider* compositor_context_provider, |
732 bool delegated_sync_points_required, | 746 bool delegated_sync_points_required, |
733 bool use_gpu_memory_buffer_resources, | 747 bool use_gpu_memory_buffer_resources, |
734 bool enable_color_correct_rasterization); | 748 bool enable_color_correct_rasterization); |
735 | 749 |
736 int max_texture_size = 0; | 750 int max_texture_size = 0; |
737 bool use_texture_storage_ext = false; | 751 bool use_texture_storage_ext = false; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 // Set of resource Ids that would like to be notified about promotion hints. | 784 // Set of resource Ids that would like to be notified about promotion hints. |
771 ResourceIdSet wants_promotion_hints_set_; | 785 ResourceIdSet wants_promotion_hints_set_; |
772 #endif | 786 #endif |
773 | 787 |
774 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 788 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
775 }; | 789 }; |
776 | 790 |
777 } // namespace cc | 791 } // namespace cc |
778 | 792 |
779 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 793 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |