| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/test_in_process_context_provider.h" | 5 #include "cc/test/test_in_process_context_provider.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 TestInProcessContextProvider::TestInProcessContextProvider( | 61 TestInProcessContextProvider::TestInProcessContextProvider( |
| 62 TestInProcessContextProvider* shared_context) | 62 TestInProcessContextProvider* shared_context) |
| 63 : context_(CreateTestInProcessContext( | 63 : context_(CreateTestInProcessContext( |
| 64 &gpu_memory_buffer_manager_, | 64 &gpu_memory_buffer_manager_, |
| 65 &image_factory_, | 65 &image_factory_, |
| 66 (shared_context ? shared_context->context_.get() : nullptr))) {} | 66 (shared_context ? shared_context->context_.get() : nullptr))) {} |
| 67 | 67 |
| 68 TestInProcessContextProvider::~TestInProcessContextProvider() { | 68 TestInProcessContextProvider::~TestInProcessContextProvider() { |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool TestInProcessContextProvider::BindToCurrentThread() { return true; } | 71 bool TestInProcessContextProvider::BindToCurrentThread() { |
| 72 return true; |
| 73 } |
| 72 | 74 |
| 73 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { | 75 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { |
| 74 return context_->GetImplementation(); | 76 return context_->GetImplementation(); |
| 75 } | 77 } |
| 76 | 78 |
| 77 gpu::ContextSupport* TestInProcessContextProvider::ContextSupport() { | 79 gpu::ContextSupport* TestInProcessContextProvider::ContextSupport() { |
| 78 return context_->GetImplementation(); | 80 return context_->GetImplementation(); |
| 79 } | 81 } |
| 80 | 82 |
| 81 class GrContext* TestInProcessContextProvider::GrContext() { | 83 class GrContext* TestInProcessContextProvider::GrContext() { |
| 82 if (gr_context_) | 84 if (gr_context_) |
| 83 return gr_context_->get(); | 85 return gr_context_->get(); |
| 84 | 86 |
| 85 gr_context_.reset(new skia_bindings::GrContextForGLES2Interface(ContextGL())); | 87 gr_context_.reset(new skia_bindings::GrContextForGLES2Interface(ContextGL())); |
| 86 return gr_context_->get(); | 88 return gr_context_->get(); |
| 87 } | 89 } |
| 88 | 90 |
| 89 void TestInProcessContextProvider::InvalidateGrContext(uint32_t state) { | 91 void TestInProcessContextProvider::InvalidateGrContext(uint32_t state) { |
| 90 if (gr_context_) | 92 if (gr_context_) |
| 91 gr_context_->ResetContext(state); | 93 gr_context_->ResetContext(state); |
| 92 } | 94 } |
| 93 | 95 |
| 94 void TestInProcessContextProvider::SetupLock() { | 96 void TestInProcessContextProvider::SetupLock() { |
| 95 } | 97 } |
| 96 | 98 |
| 97 base::Lock* TestInProcessContextProvider::GetLock() { | 99 base::Lock* TestInProcessContextProvider::GetLock() { |
| 98 return &context_lock_; | 100 return &context_lock_; |
| 99 } | 101 } |
| 100 | 102 |
| 101 ContextProvider::Capabilities | 103 gpu::Capabilities TestInProcessContextProvider::ContextCapabilities() { |
| 102 TestInProcessContextProvider::ContextCapabilities() { | 104 gpu::Capabilities capabilities; |
| 103 ContextProvider::Capabilities capabilities; | 105 capabilities.image = true; |
| 104 capabilities.gpu.image = true; | 106 capabilities.texture_rectangle = true; |
| 105 capabilities.gpu.texture_rectangle = true; | 107 capabilities.sync_query = true; |
| 106 capabilities.gpu.sync_query = true; | |
| 107 | |
| 108 switch (PlatformColor::Format()) { | 108 switch (PlatformColor::Format()) { |
| 109 case PlatformColor::SOURCE_FORMAT_RGBA8: | 109 case PlatformColor::SOURCE_FORMAT_RGBA8: |
| 110 capabilities.gpu.texture_format_bgra8888 = false; | 110 capabilities.texture_format_bgra8888 = false; |
| 111 break; | 111 break; |
| 112 case PlatformColor::SOURCE_FORMAT_BGRA8: | 112 case PlatformColor::SOURCE_FORMAT_BGRA8: |
| 113 capabilities.gpu.texture_format_bgra8888 = true; | 113 capabilities.texture_format_bgra8888 = true; |
| 114 break; | 114 break; |
| 115 } | 115 } |
| 116 | |
| 117 return capabilities; | 116 return capabilities; |
| 118 } | 117 } |
| 119 | 118 |
| 120 void TestInProcessContextProvider::DeleteCachedResources() { | 119 void TestInProcessContextProvider::DeleteCachedResources() { |
| 121 if (gr_context_) | 120 if (gr_context_) |
| 122 gr_context_->FreeGpuResources(); | 121 gr_context_->FreeGpuResources(); |
| 123 } | 122 } |
| 124 | 123 |
| 125 void TestInProcessContextProvider::SetLostContextCallback( | 124 void TestInProcessContextProvider::SetLostContextCallback( |
| 126 const LostContextCallback& lost_context_callback) {} | 125 const LostContextCallback& lost_context_callback) {} |
| 127 | 126 |
| 128 } // namespace cc | 127 } // namespace cc |
| OLD | NEW |