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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 const gfx::Vector2d& dest_offset); | 146 const gfx::Vector2d& dest_offset); |
147 | 147 |
148 // Check upload status. | 148 // Check upload status. |
149 size_t NumBlockingUploads(); | 149 size_t NumBlockingUploads(); |
150 void MarkPendingUploadsAsNonBlocking(); | 150 void MarkPendingUploadsAsNonBlocking(); |
151 size_t EstimatedUploadsPerTick(); | 151 size_t EstimatedUploadsPerTick(); |
152 void FlushUploads(); | 152 void FlushUploads(); |
153 void ReleaseCachedData(); | 153 void ReleaseCachedData(); |
154 base::TimeTicks EstimatedUploadCompletionTime(size_t uploads_per_tick); | 154 base::TimeTicks EstimatedUploadCompletionTime(size_t uploads_per_tick); |
155 | 155 |
156 // Flush all context operations, kicking uploads and ensuring ordering with | |
157 // respect to other contexts. | |
158 void Flush(); | |
159 | |
160 // Finish all context operations, causing any pending callbacks to be | |
161 // scheduled. | |
162 void Finish(); | |
163 | |
164 // Only flush the command buffer if supported. | 156 // Only flush the command buffer if supported. |
165 // Returns true if the shallow flush occurred, false otherwise. | 157 // Returns true if the shallow flush occurred, false otherwise. |
166 bool ShallowFlushIfSupported(); | 158 bool ShallowFlushIfSupported(); |
167 | 159 |
168 // Creates accounting for a child. Returns a child ID. | 160 // Creates accounting for a child. Returns a child ID. |
169 int CreateChild(const ReturnCallback& return_callback); | 161 int CreateChild(const ReturnCallback& return_callback); |
170 | 162 |
171 // Destroys accounting for the child, deleting all accounted resources. | 163 // Destroys accounting for the child, deleting all accounted resources. |
172 void DestroyChild(int child); | 164 void DestroyChild(int child); |
173 | 165 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 | 291 |
300 private: | 292 private: |
301 ResourceProvider* resource_provider_; | 293 ResourceProvider* resource_provider_; |
302 ResourceProvider::ResourceId resource_id_; | 294 ResourceProvider::ResourceId resource_id_; |
303 SkBitmap sk_bitmap_; | 295 SkBitmap sk_bitmap_; |
304 scoped_ptr<SkCanvas> sk_canvas_; | 296 scoped_ptr<SkCanvas> sk_canvas_; |
305 | 297 |
306 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware); | 298 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware); |
307 }; | 299 }; |
308 | 300 |
309 // The following class is needed to modify GL resources using GPU | |
310 // raster. The user must ensure that they only use GPU raster on | |
311 // GL resources while an instance of this class is alive. | |
312 class CC_EXPORT ScopedGpuRaster { | |
313 public: | |
314 ScopedGpuRaster(ResourceProvider* resource_provider); | |
315 ~ScopedGpuRaster(); | |
316 | |
317 private: | |
318 ResourceProvider* resource_provider_; | |
319 | |
320 DISALLOW_COPY_AND_ASSIGN(ScopedGpuRaster); | |
321 }; | |
322 | |
323 class Fence : public base::RefCounted<Fence> { | 301 class Fence : public base::RefCounted<Fence> { |
324 public: | 302 public: |
325 Fence() {} | 303 Fence() {} |
326 virtual bool HasPassed() = 0; | 304 virtual bool HasPassed() = 0; |
327 | 305 |
328 protected: | 306 protected: |
329 friend class base::RefCounted<Fence>; | 307 friend class base::RefCounted<Fence>; |
330 virtual ~Fence() {} | 308 virtual ~Fence() {} |
331 | 309 |
332 private: | 310 private: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 void EnableReadLockFences(ResourceProvider::ResourceId id, bool enable); | 359 void EnableReadLockFences(ResourceProvider::ResourceId id, bool enable); |
382 | 360 |
383 // Indicates if we can currently lock this resource for write. | 361 // Indicates if we can currently lock this resource for write. |
384 bool CanLockForWrite(ResourceId id); | 362 bool CanLockForWrite(ResourceId id); |
385 | 363 |
386 // Copy pixels from source to destination. | 364 // Copy pixels from source to destination. |
387 void CopyResource(ResourceId source_id, ResourceId dest_id); | 365 void CopyResource(ResourceId source_id, ResourceId dest_id); |
388 | 366 |
389 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); | 367 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); |
390 | 368 |
369 // Returns NULL if the output_surface_ does not have a ContextProvider. | |
danakj
2014/07/11 16:49:04
don't need to be public?
sohanjg
2014/07/11 17:12:45
Done.
| |
370 gpu::gles2::GLES2Interface* ContextGL() const; | |
371 class GrContext* GrContext() const; | |
372 | |
391 private: | 373 private: |
392 class GpuRasterBuffer; | 374 class GpuRasterBuffer; |
393 class ImageRasterBuffer; | 375 class ImageRasterBuffer; |
394 class PixelRasterBuffer; | 376 class PixelRasterBuffer; |
395 | 377 |
396 struct Resource { | 378 struct Resource { |
397 enum Origin { Internal, External, Delegated }; | 379 enum Origin { Internal, External, Delegated }; |
398 | 380 |
399 Resource(); | 381 Resource(); |
400 ~Resource(); | 382 ~Resource(); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 void UnmapImage(const Resource* resource); | 612 void UnmapImage(const Resource* resource); |
631 | 613 |
632 void BindImageForSampling(Resource* resource); | 614 void BindImageForSampling(Resource* resource); |
633 // Binds the given GL resource to a texture target for sampling using the | 615 // Binds the given GL resource to a texture target for sampling using the |
634 // specified filter for both minification and magnification. Returns the | 616 // specified filter for both minification and magnification. Returns the |
635 // texture target used. The resource must be locked for reading. | 617 // texture target used. The resource must be locked for reading. |
636 GLenum BindForSampling(ResourceProvider::ResourceId resource_id, | 618 GLenum BindForSampling(ResourceProvider::ResourceId resource_id, |
637 GLenum unit, | 619 GLenum unit, |
638 GLenum filter); | 620 GLenum filter); |
639 | 621 |
640 // Returns NULL if the output_surface_ does not have a ContextProvider. | |
641 gpu::gles2::GLES2Interface* ContextGL() const; | |
642 class GrContext* GrContext() const; | |
643 | |
644 void BeginGpuRaster(); | |
645 void EndGpuRaster(); | |
646 | |
647 OutputSurface* output_surface_; | 622 OutputSurface* output_surface_; |
648 SharedBitmapManager* shared_bitmap_manager_; | 623 SharedBitmapManager* shared_bitmap_manager_; |
649 bool lost_output_surface_; | 624 bool lost_output_surface_; |
650 int highp_threshold_min_; | 625 int highp_threshold_min_; |
651 ResourceId next_id_; | 626 ResourceId next_id_; |
652 ResourceMap resources_; | 627 ResourceMap resources_; |
653 int next_child_; | 628 int next_child_; |
654 ChildMap children_; | 629 ChildMap children_; |
655 | 630 |
656 ResourceType default_resource_type_; | 631 ResourceType default_resource_type_; |
(...skipping 13 matching lines...) Expand all Loading... | |
670 scoped_ptr<IdAllocator> texture_id_allocator_; | 645 scoped_ptr<IdAllocator> texture_id_allocator_; |
671 scoped_ptr<IdAllocator> buffer_id_allocator_; | 646 scoped_ptr<IdAllocator> buffer_id_allocator_; |
672 | 647 |
673 bool use_sync_query_; | 648 bool use_sync_query_; |
674 | 649 |
675 bool use_distance_field_text_; | 650 bool use_distance_field_text_; |
676 | 651 |
677 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 652 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
678 }; | 653 }; |
679 | 654 |
680 | |
681 // TODO(epenner): Move these format conversions to resource_format.h | 655 // TODO(epenner): Move these format conversions to resource_format.h |
682 // once that builds on mac (npapi.h currently #includes OpenGL.h). | 656 // once that builds on mac (npapi.h currently #includes OpenGL.h). |
683 inline unsigned BitsPerPixel(ResourceFormat format) { | 657 inline unsigned BitsPerPixel(ResourceFormat format) { |
684 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 658 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
685 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { | 659 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { |
686 32, // RGBA_8888 | 660 32, // RGBA_8888 |
687 16, // RGBA_4444 | 661 16, // RGBA_4444 |
688 32, // BGRA_8888 | 662 32, // BGRA_8888 |
689 8, // LUMINANCE_8 | 663 8, // LUMINANCE_8 |
690 16, // RGB_565, | 664 16, // RGB_565, |
(...skipping 28 matching lines...) Expand all Loading... | |
719 return format_gl_data_format[format]; | 693 return format_gl_data_format[format]; |
720 } | 694 } |
721 | 695 |
722 inline GLenum GLInternalFormat(ResourceFormat format) { | 696 inline GLenum GLInternalFormat(ResourceFormat format) { |
723 return GLDataFormat(format); | 697 return GLDataFormat(format); |
724 } | 698 } |
725 | 699 |
726 } // namespace cc | 700 } // namespace cc |
727 | 701 |
728 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 702 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |