OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "gpu/command_buffer/service/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_manager.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 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 // Take no action if this isn't an OES_EXTERNAL texture. | 1625 // Take no action if this isn't an OES_EXTERNAL texture. |
1626 if (target_ && target_ != GL_TEXTURE_EXTERNAL_OES) | 1626 if (target_ && target_ != GL_TEXTURE_EXTERNAL_OES) |
1627 return; | 1627 return; |
1628 | 1628 |
1629 if (!service_id) | 1629 if (!service_id) |
1630 new_service_id = owned_service_id_; | 1630 new_service_id = owned_service_id_; |
1631 | 1631 |
1632 if (service_id_ != new_service_id) { | 1632 if (service_id_ != new_service_id) { |
1633 service_id_ = new_service_id; | 1633 service_id_ = new_service_id; |
1634 IncrementManagerServiceIdGeneration(); | 1634 IncrementManagerServiceIdGeneration(); |
1635 if (gfx::GLContext* context = gfx::GLContext::GetCurrent()) { | 1635 if (gl::GLContext* context = gl::GLContext::GetCurrent()) { |
1636 // It would be preferable to pass in the decoder, and ask it to do this | 1636 // It would be preferable to pass in the decoder, and ask it to do this |
1637 // instead. However, there are several cases, such as TextureDefinition, | 1637 // instead. However, there are several cases, such as TextureDefinition, |
1638 // that show up without a clear context owner. So, instead, we use the | 1638 // that show up without a clear context owner. So, instead, we use the |
1639 // current state's state restorer. | 1639 // current state's state restorer. |
1640 if (gfx::GLStateRestorer* restorer = context->GetGLStateRestorer()) | 1640 if (gl::GLStateRestorer* restorer = context->GetGLStateRestorer()) |
1641 restorer->RestoreAllExternalTextureBindingsIfNeeded(); | 1641 restorer->RestoreAllExternalTextureBindingsIfNeeded(); |
1642 } | 1642 } |
1643 } | 1643 } |
1644 } | 1644 } |
1645 | 1645 |
1646 GLenum Texture::GetCompatibilitySwizzleForChannel(GLenum channel) { | 1646 GLenum Texture::GetCompatibilitySwizzleForChannel(GLenum channel) { |
1647 return GetSwizzleForChannel(channel, compatibility_swizzle_); | 1647 return GetSwizzleForChannel(channel, compatibility_swizzle_); |
1648 } | 1648 } |
1649 | 1649 |
1650 void Texture::SetCompatibilitySwizzle(const CompatibilitySwizzle* swizzle) { | 1650 void Texture::SetCompatibilitySwizzle(const CompatibilitySwizzle* swizzle) { |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2836 GetCompatibilitySwizzle(format); | 2836 GetCompatibilitySwizzle(format); |
2837 if (swizzle) | 2837 if (swizzle) |
2838 return swizzle->dest_format; | 2838 return swizzle->dest_format; |
2839 } | 2839 } |
2840 return format; | 2840 return format; |
2841 } | 2841 } |
2842 | 2842 |
2843 GLenum TextureManager::AdjustTexFormat(GLenum format) const { | 2843 GLenum TextureManager::AdjustTexFormat(GLenum format) const { |
2844 // TODO(bajones): GLES 3 allows for internal format and format to differ. | 2844 // TODO(bajones): GLES 3 allows for internal format and format to differ. |
2845 // This logic may need to change as a result. | 2845 // This logic may need to change as a result. |
2846 if (gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) { | 2846 if (gl::GetGLImplementation() == gl::kGLImplementationDesktopGL) { |
2847 if (format == GL_SRGB_EXT) | 2847 if (format == GL_SRGB_EXT) |
2848 return GL_RGB; | 2848 return GL_RGB; |
2849 if (format == GL_SRGB_ALPHA_EXT) | 2849 if (format == GL_SRGB_ALPHA_EXT) |
2850 return GL_RGBA; | 2850 return GL_RGBA; |
2851 } | 2851 } |
2852 if (feature_info_->gl_version_info().is_desktop_core_profile) { | 2852 if (feature_info_->gl_version_info().is_desktop_core_profile) { |
2853 const Texture::CompatibilitySwizzle* swizzle = | 2853 const Texture::CompatibilitySwizzle* swizzle = |
2854 GetCompatibilitySwizzle(format); | 2854 GetCompatibilitySwizzle(format); |
2855 if (swizzle) | 2855 if (swizzle) |
2856 return swizzle->dest_format; | 2856 return swizzle->dest_format; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3018 memory_tracker_->ClientId(), ref->client_id()); | 3018 memory_tracker_->ClientId(), ref->client_id()); |
3019 | 3019 |
3020 base::trace_event::MemoryAllocatorDump* dump = | 3020 base::trace_event::MemoryAllocatorDump* dump = |
3021 pmd->CreateAllocatorDump(dump_name); | 3021 pmd->CreateAllocatorDump(dump_name); |
3022 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 3022 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
3023 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 3023 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
3024 static_cast<uint64_t>(size)); | 3024 static_cast<uint64_t>(size)); |
3025 | 3025 |
3026 // Add the |client_guid| which expresses shared ownership with the client | 3026 // Add the |client_guid| which expresses shared ownership with the client |
3027 // process. | 3027 // process. |
3028 auto client_guid = gfx::GetGLTextureClientGUIDForTracing( | 3028 auto client_guid = gl::GetGLTextureClientGUIDForTracing( |
3029 memory_tracker_->ShareGroupTracingGUID(), ref->client_id()); | 3029 memory_tracker_->ShareGroupTracingGUID(), ref->client_id()); |
3030 pmd->CreateSharedGlobalAllocatorDump(client_guid); | 3030 pmd->CreateSharedGlobalAllocatorDump(client_guid); |
3031 pmd->AddOwnershipEdge(dump->guid(), client_guid); | 3031 pmd->AddOwnershipEdge(dump->guid(), client_guid); |
3032 | 3032 |
3033 // Add a |service_guid| which expresses shared ownership between the various | 3033 // Add a |service_guid| which expresses shared ownership between the various |
3034 // |client_guid|s. | 3034 // |client_guid|s. |
3035 // TODO(ericrk): May need to ensure uniqueness using GLShareGroup and | 3035 // TODO(ericrk): May need to ensure uniqueness using GLShareGroup and |
3036 // potentially cross-share-group sharing via EGLImages. crbug.com/512534 | 3036 // potentially cross-share-group sharing via EGLImages. crbug.com/512534 |
3037 auto service_guid = gfx::GetGLTextureServiceGUIDForTracing( | 3037 auto service_guid = gl::GetGLTextureServiceGUIDForTracing( |
3038 memory_tracker_->ShareGroupTracingGUID(), ref->texture()->service_id()); | 3038 memory_tracker_->ShareGroupTracingGUID(), ref->texture()->service_id()); |
3039 pmd->CreateSharedGlobalAllocatorDump(service_guid); | 3039 pmd->CreateSharedGlobalAllocatorDump(service_guid); |
3040 | 3040 |
3041 int importance = 0; // Default importance. | 3041 int importance = 0; // Default importance. |
3042 // The link to the memory tracking |client_id| is given a higher importance | 3042 // The link to the memory tracking |client_id| is given a higher importance |
3043 // than other refs. | 3043 // than other refs. |
3044 if (ref == ref->texture()->memory_tracking_ref_) | 3044 if (ref == ref->texture()->memory_tracking_ref_) |
3045 importance = 2; | 3045 importance = 2; |
3046 | 3046 |
3047 pmd->AddOwnershipEdge(client_guid, service_guid, importance); | 3047 pmd->AddOwnershipEdge(client_guid, service_guid, importance); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3309 uint32_t TextureManager::GetServiceIdGeneration() const { | 3309 uint32_t TextureManager::GetServiceIdGeneration() const { |
3310 return current_service_id_generation_; | 3310 return current_service_id_generation_; |
3311 } | 3311 } |
3312 | 3312 |
3313 void TextureManager::IncrementServiceIdGeneration() { | 3313 void TextureManager::IncrementServiceIdGeneration() { |
3314 current_service_id_generation_++; | 3314 current_service_id_generation_++; |
3315 } | 3315 } |
3316 | 3316 |
3317 } // namespace gles2 | 3317 } // namespace gles2 |
3318 } // namespace gpu | 3318 } // namespace gpu |
OLD | NEW |