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 #include "cc/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "cc/resources/resource_util.h" | 26 #include "cc/resources/resource_util.h" |
27 #include "components/viz/common/resources/platform_color.h" | 27 #include "components/viz/common/resources/platform_color.h" |
28 #include "components/viz/common/resources/returned_resource.h" | 28 #include "components/viz/common/resources/returned_resource.h" |
29 #include "components/viz/common/resources/shared_bitmap_manager.h" | 29 #include "components/viz/common/resources/shared_bitmap_manager.h" |
30 #include "components/viz/common/resources/transferable_resource.h" | 30 #include "components/viz/common/resources/transferable_resource.h" |
31 #include "gpu/GLES2/gl2extchromium.h" | 31 #include "gpu/GLES2/gl2extchromium.h" |
32 #include "gpu/command_buffer/client/context_support.h" | 32 #include "gpu/command_buffer/client/context_support.h" |
33 #include "gpu/command_buffer/client/gles2_interface.h" | 33 #include "gpu/command_buffer/client/gles2_interface.h" |
34 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 34 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| 35 #include "media/base/media_switches.h" |
35 #include "skia/ext/texture_handle.h" | 36 #include "skia/ext/texture_handle.h" |
36 #include "third_party/khronos/GLES2/gl2.h" | 37 #include "third_party/khronos/GLES2/gl2.h" |
37 #include "third_party/khronos/GLES2/gl2ext.h" | 38 #include "third_party/khronos/GLES2/gl2ext.h" |
38 #include "third_party/skia/include/core/SkCanvas.h" | 39 #include "third_party/skia/include/core/SkCanvas.h" |
39 #include "third_party/skia/include/core/SkSurface.h" | 40 #include "third_party/skia/include/core/SkSurface.h" |
40 #include "third_party/skia/include/gpu/GrBackendSurface.h" | 41 #include "third_party/skia/include/gpu/GrBackendSurface.h" |
41 #include "third_party/skia/include/gpu/GrContext.h" | 42 #include "third_party/skia/include/gpu/GrContext.h" |
42 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" | 43 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
43 #include "ui/gfx/geometry/rect.h" | 44 #include "ui/gfx/geometry/rect.h" |
44 #include "ui/gfx/geometry/vector2d.h" | 45 #include "ui/gfx/geometry/vector2d.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 case viz::RGBA_F16: | 100 case viz::RGBA_F16: |
100 storage_format = GL_RGBA16F_EXT; | 101 storage_format = GL_RGBA16F_EXT; |
101 break; | 102 break; |
102 case viz::RGBA_4444: | 103 case viz::RGBA_4444: |
103 case viz::ALPHA_8: | 104 case viz::ALPHA_8: |
104 case viz::LUMINANCE_8: | 105 case viz::LUMINANCE_8: |
105 case viz::RGB_565: | 106 case viz::RGB_565: |
106 case viz::ETC1: | 107 case viz::ETC1: |
107 case viz::RED_8: | 108 case viz::RED_8: |
108 case viz::LUMINANCE_F16: | 109 case viz::LUMINANCE_F16: |
| 110 case viz::R16_EXT: |
109 NOTREACHED(); | 111 NOTREACHED(); |
110 break; | 112 break; |
111 } | 113 } |
112 | 114 |
113 return storage_format; | 115 return storage_format; |
114 } | 116 } |
115 | 117 |
116 bool IsFormatSupportedForStorage(viz::ResourceFormat format, bool use_bgra) { | 118 bool IsFormatSupportedForStorage(viz::ResourceFormat format, bool use_bgra) { |
117 switch (format) { | 119 switch (format) { |
118 case viz::RGBA_8888: | 120 case viz::RGBA_8888: |
119 case viz::RGBA_F16: | 121 case viz::RGBA_F16: |
120 return true; | 122 return true; |
121 case viz::BGRA_8888: | 123 case viz::BGRA_8888: |
122 return use_bgra; | 124 return use_bgra; |
123 case viz::RGBA_4444: | 125 case viz::RGBA_4444: |
124 case viz::ALPHA_8: | 126 case viz::ALPHA_8: |
125 case viz::LUMINANCE_8: | 127 case viz::LUMINANCE_8: |
126 case viz::RGB_565: | 128 case viz::RGB_565: |
127 case viz::ETC1: | 129 case viz::ETC1: |
128 case viz::RED_8: | 130 case viz::RED_8: |
129 case viz::LUMINANCE_F16: | 131 case viz::LUMINANCE_F16: |
| 132 case viz::R16_EXT: |
130 return false; | 133 return false; |
131 } | 134 } |
132 return false; | 135 return false; |
133 } | 136 } |
134 | 137 |
135 class ScopedSetActiveTexture { | 138 class ScopedSetActiveTexture { |
136 public: | 139 public: |
137 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) | 140 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) |
138 : gl_(gl), unit_(unit) { | 141 : gl_(gl), unit_(unit) { |
139 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); | 142 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 const auto& caps = compositor_context_provider->ContextCapabilities(); | 350 const auto& caps = compositor_context_provider->ContextCapabilities(); |
348 use_texture_storage_ext = caps.texture_storage; | 351 use_texture_storage_ext = caps.texture_storage; |
349 use_texture_format_bgra = caps.texture_format_bgra8888; | 352 use_texture_format_bgra = caps.texture_format_bgra8888; |
350 use_texture_usage_hint = caps.texture_usage; | 353 use_texture_usage_hint = caps.texture_usage; |
351 use_sync_query = caps.sync_query; | 354 use_sync_query = caps.sync_query; |
352 | 355 |
353 if (caps.disable_one_component_textures) { | 356 if (caps.disable_one_component_textures) { |
354 yuv_resource_format = yuv_highbit_resource_format = viz::RGBA_8888; | 357 yuv_resource_format = yuv_highbit_resource_format = viz::RGBA_8888; |
355 } else { | 358 } else { |
356 yuv_resource_format = caps.texture_rg ? viz::RED_8 : viz::LUMINANCE_8; | 359 yuv_resource_format = caps.texture_rg ? viz::RED_8 : viz::LUMINANCE_8; |
357 yuv_highbit_resource_format = caps.texture_half_float_linear | 360 yuv_highbit_resource_format = |
358 ? viz::LUMINANCE_F16 | 361 (base::FeatureList::IsEnabled(media::kUseR16Texture) && |
359 : yuv_resource_format; | 362 caps.texture_norm16) |
| 363 ? viz::R16_EXT |
| 364 : (caps.texture_half_float_linear ? viz::LUMINANCE_F16 |
| 365 : yuv_resource_format); |
360 } | 366 } |
361 | 367 |
362 GLES2Interface* gl = compositor_context_provider->ContextGL(); | 368 GLES2Interface* gl = compositor_context_provider->ContextGL(); |
363 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); | 369 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); |
364 | 370 |
365 best_texture_format = | 371 best_texture_format = |
366 viz::PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra); | 372 viz::PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra); |
367 best_render_buffer_format = viz::PlatformColor::BestSupportedTextureFormat( | 373 best_render_buffer_format = viz::PlatformColor::BestSupportedTextureFormat( |
368 caps.render_buffer_format_bgra8888); | 374 caps.render_buffer_format_bgra8888); |
369 } | 375 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 case viz::RGBA_8888: | 457 case viz::RGBA_8888: |
452 case viz::RGB_565: | 458 case viz::RGB_565: |
453 case viz::LUMINANCE_8: | 459 case viz::LUMINANCE_8: |
454 return true; | 460 return true; |
455 case viz::BGRA_8888: | 461 case viz::BGRA_8888: |
456 return caps.texture_format_bgra8888; | 462 return caps.texture_format_bgra8888; |
457 case viz::ETC1: | 463 case viz::ETC1: |
458 return caps.texture_format_etc1; | 464 return caps.texture_format_etc1; |
459 case viz::RED_8: | 465 case viz::RED_8: |
460 return caps.texture_rg; | 466 return caps.texture_rg; |
| 467 case viz::R16_EXT: |
| 468 return caps.texture_norm16; |
461 case viz::LUMINANCE_F16: | 469 case viz::LUMINANCE_F16: |
462 case viz::RGBA_F16: | 470 case viz::RGBA_F16: |
463 return caps.texture_half_float_linear; | 471 return caps.texture_half_float_linear; |
464 } | 472 } |
465 | 473 |
466 NOTREACHED(); | 474 NOTREACHED(); |
467 return false; | 475 return false; |
468 } | 476 } |
469 | 477 |
470 bool ResourceProvider::IsRenderBufferFormatSupported( | 478 bool ResourceProvider::IsRenderBufferFormatSupported( |
(...skipping 13 matching lines...) Expand all Loading... |
484 // TODO(ccameron): This will always return false on pixel tests, which | 492 // TODO(ccameron): This will always return false on pixel tests, which |
485 // makes it un-test-able until we upgrade Mesa. | 493 // makes it un-test-able until we upgrade Mesa. |
486 // https://crbug.com/687720 | 494 // https://crbug.com/687720 |
487 return caps.texture_half_float_linear && | 495 return caps.texture_half_float_linear && |
488 caps.color_buffer_half_float_rgba; | 496 caps.color_buffer_half_float_rgba; |
489 case viz::LUMINANCE_8: | 497 case viz::LUMINANCE_8: |
490 case viz::ALPHA_8: | 498 case viz::ALPHA_8: |
491 case viz::RED_8: | 499 case viz::RED_8: |
492 case viz::ETC1: | 500 case viz::ETC1: |
493 case viz::LUMINANCE_F16: | 501 case viz::LUMINANCE_F16: |
| 502 case viz::R16_EXT: |
494 // We don't currently render into these formats. If we need to render into | 503 // We don't currently render into these formats. If we need to render into |
495 // these eventually, we should expand this logic. | 504 // these eventually, we should expand this logic. |
496 return false; | 505 return false; |
497 } | 506 } |
498 | 507 |
499 NOTREACHED(); | 508 NOTREACHED(); |
500 return false; | 509 return false; |
501 } | 510 } |
502 | 511 |
503 bool ResourceProvider::InUseByConsumer(viz::ResourceId id) { | 512 bool ResourceProvider::InUseByConsumer(viz::ResourceId id) { |
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 } else { | 1769 } else { |
1761 pmd->CreateSharedGlobalAllocatorDump(guid); | 1770 pmd->CreateSharedGlobalAllocatorDump(guid); |
1762 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1771 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
1763 } | 1772 } |
1764 } | 1773 } |
1765 | 1774 |
1766 return true; | 1775 return true; |
1767 } | 1776 } |
1768 | 1777 |
1769 } // namespace cc | 1778 } // namespace cc |
OLD | NEW |