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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 InvalidType = 0, | 68 InvalidType = 0, |
69 GLTexture = 1, | 69 GLTexture = 1, |
70 Bitmap, | 70 Bitmap, |
71 }; | 71 }; |
72 | 72 |
73 static scoped_ptr<ResourceProvider> Create( | 73 static scoped_ptr<ResourceProvider> Create( |
74 OutputSurface* output_surface, | 74 OutputSurface* output_surface, |
75 SharedBitmapManager* shared_bitmap_manager, | 75 SharedBitmapManager* shared_bitmap_manager, |
76 int highp_threshold_min, | 76 int highp_threshold_min, |
77 bool use_rgba_4444_texture_format, | 77 bool use_rgba_4444_texture_format, |
78 size_t id_allocation_chunk_size); | 78 size_t id_allocation_chunk_size, |
| 79 bool use_distance_field_text); |
79 virtual ~ResourceProvider(); | 80 virtual ~ResourceProvider(); |
80 | 81 |
81 void InitializeSoftware(); | 82 void InitializeSoftware(); |
82 void InitializeGL(); | 83 void InitializeGL(); |
83 | 84 |
84 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 85 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
85 | 86 |
86 int max_texture_size() const { return max_texture_size_; } | 87 int max_texture_size() const { return max_texture_size_; } |
87 ResourceFormat memory_efficient_texture_format() const { | 88 ResourceFormat memory_efficient_texture_format() const { |
88 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; | 89 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 private: | 471 private: |
471 const Resource* resource_; | 472 const Resource* resource_; |
472 ResourceProvider* resource_provider_; | 473 ResourceProvider* resource_provider_; |
473 SkCanvas* locked_canvas_; | 474 SkCanvas* locked_canvas_; |
474 int canvas_save_count_; | 475 int canvas_save_count_; |
475 }; | 476 }; |
476 | 477 |
477 class DirectRasterBuffer : public RasterBuffer { | 478 class DirectRasterBuffer : public RasterBuffer { |
478 public: | 479 public: |
479 DirectRasterBuffer(const Resource* resource, | 480 DirectRasterBuffer(const Resource* resource, |
480 ResourceProvider* resource_provider); | 481 ResourceProvider* resource_provider, |
| 482 bool use_distance_field_text); |
481 virtual ~DirectRasterBuffer(); | 483 virtual ~DirectRasterBuffer(); |
482 | 484 |
483 protected: | 485 protected: |
484 virtual SkCanvas* DoLockForWrite() OVERRIDE; | 486 virtual SkCanvas* DoLockForWrite() OVERRIDE; |
485 virtual bool DoUnlockForWrite() OVERRIDE; | 487 virtual bool DoUnlockForWrite() OVERRIDE; |
486 skia::RefPtr<SkSurface> CreateSurface(); | 488 skia::RefPtr<SkSurface> CreateSurface(); |
487 | 489 |
488 private: | 490 private: |
489 skia::RefPtr<SkSurface> surface_; | 491 skia::RefPtr<SkSurface> surface_; |
490 uint32_t surface_generation_id_; | 492 uint32_t surface_generation_id_; |
| 493 const bool use_distance_field_text_; |
491 | 494 |
492 DISALLOW_COPY_AND_ASSIGN(DirectRasterBuffer); | 495 DISALLOW_COPY_AND_ASSIGN(DirectRasterBuffer); |
493 }; | 496 }; |
494 | 497 |
495 class BitmapRasterBuffer : public RasterBuffer { | 498 class BitmapRasterBuffer : public RasterBuffer { |
496 public: | 499 public: |
497 virtual ~BitmapRasterBuffer(); | 500 virtual ~BitmapRasterBuffer(); |
498 | 501 |
499 protected: | 502 protected: |
500 BitmapRasterBuffer(const Resource* resource, | 503 BitmapRasterBuffer(const Resource* resource, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 | 562 |
560 bool ReadLockFenceHasPassed(const Resource* resource) { | 563 bool ReadLockFenceHasPassed(const Resource* resource) { |
561 return !resource->read_lock_fence.get() || | 564 return !resource->read_lock_fence.get() || |
562 resource->read_lock_fence->HasPassed(); | 565 resource->read_lock_fence->HasPassed(); |
563 } | 566 } |
564 | 567 |
565 ResourceProvider(OutputSurface* output_surface, | 568 ResourceProvider(OutputSurface* output_surface, |
566 SharedBitmapManager* shared_bitmap_manager, | 569 SharedBitmapManager* shared_bitmap_manager, |
567 int highp_threshold_min, | 570 int highp_threshold_min, |
568 bool use_rgba_4444_texture_format, | 571 bool use_rgba_4444_texture_format, |
569 size_t id_allocation_chunk_size); | 572 size_t id_allocation_chunk_size, |
| 573 bool use_distance_field_text); |
570 | 574 |
571 void CleanUpGLIfNeeded(); | 575 void CleanUpGLIfNeeded(); |
572 | 576 |
573 Resource* GetResource(ResourceId id); | 577 Resource* GetResource(ResourceId id); |
574 const Resource* LockForRead(ResourceId id); | 578 const Resource* LockForRead(ResourceId id); |
575 void UnlockForRead(ResourceId id); | 579 void UnlockForRead(ResourceId id); |
576 const Resource* LockForWrite(ResourceId id); | 580 const Resource* LockForWrite(ResourceId id); |
577 void UnlockForWrite(ResourceId id); | 581 void UnlockForWrite(ResourceId id); |
578 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, | 582 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, |
579 const Resource* resource); | 583 const Resource* resource); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 | 649 |
646 scoped_refptr<Fence> current_read_lock_fence_; | 650 scoped_refptr<Fence> current_read_lock_fence_; |
647 bool use_rgba_4444_texture_format_; | 651 bool use_rgba_4444_texture_format_; |
648 | 652 |
649 const size_t id_allocation_chunk_size_; | 653 const size_t id_allocation_chunk_size_; |
650 scoped_ptr<IdAllocator> texture_id_allocator_; | 654 scoped_ptr<IdAllocator> texture_id_allocator_; |
651 scoped_ptr<IdAllocator> buffer_id_allocator_; | 655 scoped_ptr<IdAllocator> buffer_id_allocator_; |
652 | 656 |
653 bool use_sync_query_; | 657 bool use_sync_query_; |
654 | 658 |
| 659 bool use_distance_field_text_; |
| 660 |
655 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 661 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
656 }; | 662 }; |
657 | 663 |
658 | 664 |
659 // TODO(epenner): Move these format conversions to resource_format.h | 665 // TODO(epenner): Move these format conversions to resource_format.h |
660 // once that builds on mac (npapi.h currently #includes OpenGL.h). | 666 // once that builds on mac (npapi.h currently #includes OpenGL.h). |
661 inline unsigned BitsPerPixel(ResourceFormat format) { | 667 inline unsigned BitsPerPixel(ResourceFormat format) { |
662 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 668 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
663 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { | 669 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { |
664 32, // RGBA_8888 | 670 32, // RGBA_8888 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 return format_gl_data_format[format]; | 703 return format_gl_data_format[format]; |
698 } | 704 } |
699 | 705 |
700 inline GLenum GLInternalFormat(ResourceFormat format) { | 706 inline GLenum GLInternalFormat(ResourceFormat format) { |
701 return GLDataFormat(format); | 707 return GLDataFormat(format); |
702 } | 708 } |
703 | 709 |
704 } // namespace cc | 710 } // namespace cc |
705 | 711 |
706 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 712 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |