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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 case BGRA_8888: | 86 case BGRA_8888: |
87 storage_format = GL_BGRA8_EXT; | 87 storage_format = GL_BGRA8_EXT; |
88 break; | 88 break; |
89 case RGBA_4444: | 89 case RGBA_4444: |
90 case ALPHA_8: | 90 case ALPHA_8: |
91 case LUMINANCE_8: | 91 case LUMINANCE_8: |
92 case RGB_565: | 92 case RGB_565: |
93 case ETC1: | 93 case ETC1: |
94 case RED_8: | 94 case RED_8: |
95 case LUMINANCE_F16: | 95 case LUMINANCE_F16: |
| 96 case RG_88: |
96 NOTREACHED(); | 97 NOTREACHED(); |
97 break; | 98 break; |
98 } | 99 } |
99 | 100 |
100 return storage_format; | 101 return storage_format; |
101 } | 102 } |
102 | 103 |
103 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) { | 104 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) { |
104 switch (format) { | 105 switch (format) { |
105 case RGBA_8888: | 106 case RGBA_8888: |
106 return true; | 107 return true; |
107 case BGRA_8888: | 108 case BGRA_8888: |
108 return use_bgra; | 109 return use_bgra; |
109 case RGBA_4444: | 110 case RGBA_4444: |
110 case ALPHA_8: | 111 case ALPHA_8: |
111 case LUMINANCE_8: | 112 case LUMINANCE_8: |
112 case RGB_565: | 113 case RGB_565: |
113 case ETC1: | 114 case ETC1: |
114 case RED_8: | 115 case RED_8: |
115 case LUMINANCE_F16: | 116 case LUMINANCE_F16: |
| 117 case RG_88: |
116 return false; | 118 return false; |
117 } | 119 } |
118 return false; | 120 return false; |
119 } | 121 } |
120 | 122 |
121 GrPixelConfig ToGrPixelConfig(ResourceFormat format) { | 123 GrPixelConfig ToGrPixelConfig(ResourceFormat format) { |
122 switch (format) { | 124 switch (format) { |
123 case RGBA_8888: | 125 case RGBA_8888: |
124 return kRGBA_8888_GrPixelConfig; | 126 return kRGBA_8888_GrPixelConfig; |
125 case BGRA_8888: | 127 case BGRA_8888: |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 use_compressed_texture_etc1_ = caps.texture_format_etc1; | 453 use_compressed_texture_etc1_ = caps.texture_format_etc1; |
452 | 454 |
453 if (caps.disable_one_component_textures) { | 455 if (caps.disable_one_component_textures) { |
454 yuv_resource_format_ = yuv_highbit_resource_format_ = RGBA_8888; | 456 yuv_resource_format_ = yuv_highbit_resource_format_ = RGBA_8888; |
455 } else { | 457 } else { |
456 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8; | 458 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8; |
457 yuv_highbit_resource_format_ = | 459 yuv_highbit_resource_format_ = |
458 caps.texture_half_float_linear ? LUMINANCE_F16 : yuv_resource_format_; | 460 caps.texture_half_float_linear ? LUMINANCE_F16 : yuv_resource_format_; |
459 } | 461 } |
460 | 462 |
| 463 y16_resource_format_ = |
| 464 (!caps.disable_one_component_textures && caps.texture_rg) ? RG_88 |
| 465 : RGBA_8888; |
461 use_sync_query_ = caps.sync_query; | 466 use_sync_query_ = caps.sync_query; |
462 | 467 |
463 GLES2Interface* gl = ContextGL(); | 468 GLES2Interface* gl = ContextGL(); |
464 | 469 |
465 max_texture_size_ = 0; // Context expects cleared value. | 470 max_texture_size_ = 0; // Context expects cleared value. |
466 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); | 471 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); |
467 best_texture_format_ = | 472 best_texture_format_ = |
468 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_); | 473 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_); |
469 | 474 |
470 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat( | 475 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 case RGBA_4444: | 521 case RGBA_4444: |
517 case RGBA_8888: | 522 case RGBA_8888: |
518 case RGB_565: | 523 case RGB_565: |
519 case LUMINANCE_8: | 524 case LUMINANCE_8: |
520 return true; | 525 return true; |
521 case BGRA_8888: | 526 case BGRA_8888: |
522 return caps.texture_format_bgra8888; | 527 return caps.texture_format_bgra8888; |
523 case ETC1: | 528 case ETC1: |
524 return caps.texture_format_etc1; | 529 return caps.texture_format_etc1; |
525 case RED_8: | 530 case RED_8: |
| 531 case RG_88: |
526 return caps.texture_rg; | 532 return caps.texture_rg; |
527 case LUMINANCE_F16: | 533 case LUMINANCE_F16: |
528 return caps.texture_half_float_linear; | 534 return caps.texture_half_float_linear; |
529 } | 535 } |
530 | 536 |
531 NOTREACHED(); | 537 NOTREACHED(); |
532 return false; | 538 return false; |
533 } | 539 } |
534 | 540 |
535 bool ResourceProvider::InUseByConsumer(ResourceId id) { | 541 bool ResourceProvider::InUseByConsumer(ResourceId id) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 | 585 |
580 case RESOURCE_TYPE_BITMAP: | 586 case RESOURCE_TYPE_BITMAP: |
581 DCHECK_EQ(RGBA_8888, format); | 587 DCHECK_EQ(RGBA_8888, format); |
582 return CreateBitmap(size, color_space); | 588 return CreateBitmap(size, color_space); |
583 } | 589 } |
584 | 590 |
585 LOG(FATAL) << "Invalid default resource type."; | 591 LOG(FATAL) << "Invalid default resource type."; |
586 return 0; | 592 return 0; |
587 } | 593 } |
588 | 594 |
| 595 ResourceFormat ResourceProvider::Y16ResourceFormat() const { |
| 596 return y16_resource_format_; |
| 597 } |
| 598 |
589 ResourceId ResourceProvider::CreateGpuMemoryBufferResource( | 599 ResourceId ResourceProvider::CreateGpuMemoryBufferResource( |
590 const gfx::Size& size, | 600 const gfx::Size& size, |
591 TextureHint hint, | 601 TextureHint hint, |
592 ResourceFormat format, | 602 ResourceFormat format, |
593 gfx::BufferUsage usage, | 603 gfx::BufferUsage usage, |
594 const gfx::ColorSpace& color_space) { | 604 const gfx::ColorSpace& color_space) { |
595 DCHECK(!size.IsEmpty()); | 605 DCHECK(!size.IsEmpty()); |
596 switch (default_resource_type_) { | 606 switch (default_resource_type_) { |
597 case RESOURCE_TYPE_GPU_MEMORY_BUFFER: | 607 case RESOURCE_TYPE_GPU_MEMORY_BUFFER: |
598 case RESOURCE_TYPE_GL_TEXTURE: { | 608 case RESOURCE_TYPE_GL_TEXTURE: { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 resource->read_lock_fences_enabled = true; | 1071 resource->read_lock_fences_enabled = true; |
1062 } | 1072 } |
1063 | 1073 |
1064 ResourceProvider::ScopedReadLockGL::ScopedReadLockGL( | 1074 ResourceProvider::ScopedReadLockGL::ScopedReadLockGL( |
1065 ResourceProvider* resource_provider, | 1075 ResourceProvider* resource_provider, |
1066 ResourceId resource_id) | 1076 ResourceId resource_id) |
1067 : resource_provider_(resource_provider), resource_id_(resource_id) { | 1077 : resource_provider_(resource_provider), resource_id_(resource_id) { |
1068 const Resource* resource = resource_provider->LockForRead(resource_id); | 1078 const Resource* resource = resource_provider->LockForRead(resource_id); |
1069 texture_id_ = resource->gl_id; | 1079 texture_id_ = resource->gl_id; |
1070 target_ = resource->target; | 1080 target_ = resource->target; |
| 1081 format_ = resource->format; |
1071 size_ = resource->size; | 1082 size_ = resource->size; |
1072 color_space_ = resource->color_space; | 1083 color_space_ = resource->color_space; |
1073 } | 1084 } |
1074 | 1085 |
1075 ResourceProvider::ScopedReadLockGL::~ScopedReadLockGL() { | 1086 ResourceProvider::ScopedReadLockGL::~ScopedReadLockGL() { |
1076 resource_provider_->UnlockForRead(resource_id_); | 1087 resource_provider_->UnlockForRead(resource_id_); |
1077 } | 1088 } |
1078 | 1089 |
1079 ResourceProvider::ScopedSamplerGL::ScopedSamplerGL( | 1090 ResourceProvider::ScopedSamplerGL::ScopedSamplerGL( |
1080 ResourceProvider* resource_provider, | 1091 ResourceProvider* resource_provider, |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 | 2070 |
2060 const int kImportance = 2; | 2071 const int kImportance = 2; |
2061 pmd->CreateSharedGlobalAllocatorDump(guid); | 2072 pmd->CreateSharedGlobalAllocatorDump(guid); |
2062 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2073 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
2063 } | 2074 } |
2064 | 2075 |
2065 return true; | 2076 return true; |
2066 } | 2077 } |
2067 | 2078 |
2068 } // namespace cc | 2079 } // namespace cc |
OLD | NEW |