| 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 13 matching lines...) Expand all Loading... |
| 24 #include "cc/resources/return_callback.h" | 24 #include "cc/resources/return_callback.h" |
| 25 #include "cc/resources/single_release_callback.h" | 25 #include "cc/resources/single_release_callback.h" |
| 26 #include "cc/resources/texture_mailbox.h" | 26 #include "cc/resources/texture_mailbox.h" |
| 27 #include "cc/resources/transferable_resource.h" | 27 #include "cc/resources/transferable_resource.h" |
| 28 #include "third_party/khronos/GLES2/gl2.h" | 28 #include "third_party/khronos/GLES2/gl2.h" |
| 29 #include "third_party/khronos/GLES2/gl2ext.h" | 29 #include "third_party/khronos/GLES2/gl2ext.h" |
| 30 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
| 31 #include "third_party/skia/include/core/SkCanvas.h" | 31 #include "third_party/skia/include/core/SkCanvas.h" |
| 32 #include "ui/gfx/size.h" | 32 #include "ui/gfx/size.h" |
| 33 | 33 |
| 34 namespace blink { class WebGraphicsContext3D; } | 34 namespace gpu { |
| 35 namespace gles { |
| 36 class GLES2Interface; |
| 37 } |
| 38 } |
| 35 | 39 |
| 36 namespace gfx { | 40 namespace gfx { |
| 37 class Rect; | 41 class Rect; |
| 38 class Vector2d; | 42 class Vector2d; |
| 39 } | 43 } |
| 40 | 44 |
| 41 namespace cc { | 45 namespace cc { |
| 42 class IdAllocator; | 46 class IdAllocator; |
| 43 class SharedBitmap; | 47 class SharedBitmap; |
| 44 class SharedBitmapManager; | 48 class SharedBitmapManager; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 current_read_lock_fence_ = fence; | 352 current_read_lock_fence_ = fence; |
| 349 } | 353 } |
| 350 Fence* GetReadLockFence() { return current_read_lock_fence_.get(); } | 354 Fence* GetReadLockFence() { return current_read_lock_fence_.get(); } |
| 351 | 355 |
| 352 // Enable read lock fences for a specific resource. | 356 // Enable read lock fences for a specific resource. |
| 353 void EnableReadLockFences(ResourceProvider::ResourceId id, bool enable); | 357 void EnableReadLockFences(ResourceProvider::ResourceId id, bool enable); |
| 354 | 358 |
| 355 // Indicates if we can currently lock this resource for write. | 359 // Indicates if we can currently lock this resource for write. |
| 356 bool CanLockForWrite(ResourceId id); | 360 bool CanLockForWrite(ResourceId id); |
| 357 | 361 |
| 358 static GLint GetActiveTextureUnit(blink::WebGraphicsContext3D* context); | 362 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); |
| 359 | 363 |
| 360 private: | 364 private: |
| 361 struct Resource { | 365 struct Resource { |
| 362 Resource(); | 366 Resource(); |
| 363 ~Resource(); | 367 ~Resource(); |
| 364 Resource(unsigned texture_id, | 368 Resource(unsigned texture_id, |
| 365 gfx::Size size, | 369 gfx::Size size, |
| 366 GLenum target, | 370 GLenum target, |
| 367 GLenum filter, | 371 GLenum filter, |
| 368 GLenum texture_pool, | 372 GLenum texture_pool, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 void CleanUpGLIfNeeded(); | 448 void CleanUpGLIfNeeded(); |
| 445 | 449 |
| 446 Resource* GetResource(ResourceId id); | 450 Resource* GetResource(ResourceId id); |
| 447 const Resource* LockForRead(ResourceId id); | 451 const Resource* LockForRead(ResourceId id); |
| 448 void UnlockForRead(ResourceId id); | 452 void UnlockForRead(ResourceId id); |
| 449 const Resource* LockForWrite(ResourceId id); | 453 const Resource* LockForWrite(ResourceId id); |
| 450 void UnlockForWrite(ResourceId id); | 454 void UnlockForWrite(ResourceId id); |
| 451 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, | 455 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, |
| 452 const Resource* resource); | 456 const Resource* resource); |
| 453 | 457 |
| 454 void TransferResource(blink::WebGraphicsContext3D* context, | 458 void TransferResource(gpu::gles2::GLES2Interface* gl, |
| 455 ResourceId id, | 459 ResourceId id, |
| 456 TransferableResource* resource); | 460 TransferableResource* resource); |
| 457 enum DeleteStyle { | 461 enum DeleteStyle { |
| 458 Normal, | 462 Normal, |
| 459 ForShutdown, | 463 ForShutdown, |
| 460 }; | 464 }; |
| 461 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); | 465 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); |
| 462 void DeleteAndReturnUnusedResourcesToChild(ChildMap::iterator child_it, | 466 void DeleteAndReturnUnusedResourcesToChild(ChildMap::iterator child_it, |
| 463 DeleteStyle style, | 467 DeleteStyle style, |
| 464 const ResourceIdArray& unused); | 468 const ResourceIdArray& unused); |
| 465 void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); | 469 void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); |
| 466 void LazyCreate(Resource* resource); | 470 void LazyCreate(Resource* resource); |
| 467 void LazyAllocate(Resource* resource); | 471 void LazyAllocate(Resource* resource); |
| 468 | 472 |
| 469 // Binds the given GL resource to a texture target for sampling using the | 473 // Binds the given GL resource to a texture target for sampling using the |
| 470 // specified filter for both minification and magnification. Returns the | 474 // specified filter for both minification and magnification. Returns the |
| 471 // texture target used. The resource must be locked for reading. | 475 // texture target used. The resource must be locked for reading. |
| 472 GLenum BindForSampling(ResourceProvider::ResourceId resource_id, | 476 GLenum BindForSampling(ResourceProvider::ResourceId resource_id, |
| 473 GLenum unit, | 477 GLenum unit, |
| 474 GLenum filter); | 478 GLenum filter); |
| 475 | 479 |
| 476 // Returns NULL if the output_surface_ does not have a ContextProvider. | 480 // Returns NULL if the output_surface_ does not have a ContextProvider. |
| 477 blink::WebGraphicsContext3D* Context3d() const; | 481 gpu::gles2::GLES2Interface* ContextGL() const; |
| 478 | 482 |
| 479 OutputSurface* output_surface_; | 483 OutputSurface* output_surface_; |
| 480 SharedBitmapManager* shared_bitmap_manager_; | 484 SharedBitmapManager* shared_bitmap_manager_; |
| 481 bool lost_output_surface_; | 485 bool lost_output_surface_; |
| 482 int highp_threshold_min_; | 486 int highp_threshold_min_; |
| 483 ResourceId next_id_; | 487 ResourceId next_id_; |
| 484 ResourceMap resources_; | 488 ResourceMap resources_; |
| 485 int next_child_; | 489 int next_child_; |
| 486 ChildMap children_; | 490 ChildMap children_; |
| 487 | 491 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 return format_gl_data_format[format]; | 551 return format_gl_data_format[format]; |
| 548 } | 552 } |
| 549 | 553 |
| 550 inline GLenum GLInternalFormat(ResourceFormat format) { | 554 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 551 return GLDataFormat(format); | 555 return GLDataFormat(format); |
| 552 } | 556 } |
| 553 | 557 |
| 554 } // namespace cc | 558 } // namespace cc |
| 555 | 559 |
| 556 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 560 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |