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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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); |
481 virtual ~DirectRasterBuffer(); | 482 virtual ~DirectRasterBuffer(); |
482 | 483 |
484 void SetUseDistanceFieldText(bool use_distance_field_text) { | |
485 use_distance_field_text_ = use_distance_field_text; | |
486 } | |
487 | |
483 protected: | 488 protected: |
484 virtual SkCanvas* DoLockForWrite() OVERRIDE; | 489 virtual SkCanvas* DoLockForWrite() OVERRIDE; |
485 virtual bool DoUnlockForWrite() OVERRIDE; | 490 virtual bool DoUnlockForWrite() OVERRIDE; |
486 skia::RefPtr<SkSurface> CreateSurface(); | 491 skia::RefPtr<SkSurface> CreateSurface(); |
487 | 492 |
488 private: | 493 private: |
489 skia::RefPtr<SkSurface> surface_; | 494 skia::RefPtr<SkSurface> surface_; |
490 uint32_t surface_generation_id_; | 495 uint32_t surface_generation_id_; |
496 bool use_distance_field_text_; | |
reveman
2014/05/05 21:15:18
Can this be "const bool" and set by the ctor inste
jvanverth1
2014/05/06 14:27:22
Done.
| |
491 | 497 |
492 DISALLOW_COPY_AND_ASSIGN(DirectRasterBuffer); | 498 DISALLOW_COPY_AND_ASSIGN(DirectRasterBuffer); |
493 }; | 499 }; |
494 | 500 |
495 class BitmapRasterBuffer : public RasterBuffer { | 501 class BitmapRasterBuffer : public RasterBuffer { |
496 public: | 502 public: |
497 virtual ~BitmapRasterBuffer(); | 503 virtual ~BitmapRasterBuffer(); |
498 | 504 |
499 protected: | 505 protected: |
500 BitmapRasterBuffer(const Resource* resource, | 506 BitmapRasterBuffer(const Resource* resource, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 | 565 |
560 bool ReadLockFenceHasPassed(const Resource* resource) { | 566 bool ReadLockFenceHasPassed(const Resource* resource) { |
561 return !resource->read_lock_fence.get() || | 567 return !resource->read_lock_fence.get() || |
562 resource->read_lock_fence->HasPassed(); | 568 resource->read_lock_fence->HasPassed(); |
563 } | 569 } |
564 | 570 |
565 ResourceProvider(OutputSurface* output_surface, | 571 ResourceProvider(OutputSurface* output_surface, |
566 SharedBitmapManager* shared_bitmap_manager, | 572 SharedBitmapManager* shared_bitmap_manager, |
567 int highp_threshold_min, | 573 int highp_threshold_min, |
568 bool use_rgba_4444_texture_format, | 574 bool use_rgba_4444_texture_format, |
569 size_t id_allocation_chunk_size); | 575 size_t id_allocation_chunk_size, |
576 bool use_distance_field_text); | |
570 | 577 |
571 void CleanUpGLIfNeeded(); | 578 void CleanUpGLIfNeeded(); |
572 | 579 |
573 Resource* GetResource(ResourceId id); | 580 Resource* GetResource(ResourceId id); |
574 const Resource* LockForRead(ResourceId id); | 581 const Resource* LockForRead(ResourceId id); |
575 void UnlockForRead(ResourceId id); | 582 void UnlockForRead(ResourceId id); |
576 const Resource* LockForWrite(ResourceId id); | 583 const Resource* LockForWrite(ResourceId id); |
577 void UnlockForWrite(ResourceId id); | 584 void UnlockForWrite(ResourceId id); |
578 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, | 585 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, |
579 const Resource* resource); | 586 const Resource* resource); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 | 652 |
646 scoped_refptr<Fence> current_read_lock_fence_; | 653 scoped_refptr<Fence> current_read_lock_fence_; |
647 bool use_rgba_4444_texture_format_; | 654 bool use_rgba_4444_texture_format_; |
648 | 655 |
649 const size_t id_allocation_chunk_size_; | 656 const size_t id_allocation_chunk_size_; |
650 scoped_ptr<IdAllocator> texture_id_allocator_; | 657 scoped_ptr<IdAllocator> texture_id_allocator_; |
651 scoped_ptr<IdAllocator> buffer_id_allocator_; | 658 scoped_ptr<IdAllocator> buffer_id_allocator_; |
652 | 659 |
653 bool use_sync_query_; | 660 bool use_sync_query_; |
654 | 661 |
662 bool use_distance_field_text_; | |
663 | |
655 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 664 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
656 }; | 665 }; |
657 | 666 |
658 | 667 |
659 // TODO(epenner): Move these format conversions to resource_format.h | 668 // TODO(epenner): Move these format conversions to resource_format.h |
660 // once that builds on mac (npapi.h currently #includes OpenGL.h). | 669 // once that builds on mac (npapi.h currently #includes OpenGL.h). |
661 inline unsigned BitsPerPixel(ResourceFormat format) { | 670 inline unsigned BitsPerPixel(ResourceFormat format) { |
662 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 671 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
663 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { | 672 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { |
664 32, // RGBA_8888 | 673 32, // RGBA_8888 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
697 return format_gl_data_format[format]; | 706 return format_gl_data_format[format]; |
698 } | 707 } |
699 | 708 |
700 inline GLenum GLInternalFormat(ResourceFormat format) { | 709 inline GLenum GLInternalFormat(ResourceFormat format) { |
701 return GLDataFormat(format); | 710 return GLDataFormat(format); |
702 } | 711 } |
703 | 712 |
704 } // namespace cc | 713 } // namespace cc |
705 | 714 |
706 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 715 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |