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" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "cc/output/context_cache_controller.h" |
12 #include "cc/resources/platform_color.h" | 13 #include "cc/resources/platform_color.h" |
13 #include "gpu/GLES2/gl2extchromium.h" | 14 #include "gpu/GLES2/gl2extchromium.h" |
14 #include "gpu/command_buffer/client/gl_in_process_context.h" | 15 #include "gpu/command_buffer/client/gl_in_process_context.h" |
15 #include "gpu/command_buffer/client/gles2_implementation.h" | 16 #include "gpu/command_buffer/client/gles2_implementation.h" |
16 #include "gpu/command_buffer/client/gles2_lib.h" | 17 #include "gpu/command_buffer/client/gles2_lib.h" |
17 #include "gpu/command_buffer/client/shared_memory_limits.h" | 18 #include "gpu/command_buffer/client/shared_memory_limits.h" |
18 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 19 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
19 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" | 20 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" |
20 #include "third_party/khronos/GLES2/gl2.h" | 21 #include "third_party/khronos/GLES2/gl2.h" |
21 #include "third_party/khronos/GLES2/gl2ext.h" | 22 #include "third_party/khronos/GLES2/gl2ext.h" |
(...skipping 30 matching lines...) Expand all Loading... |
52 | 53 |
53 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() { | 54 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() { |
54 return CreateTestInProcessContext(nullptr, nullptr, nullptr); | 55 return CreateTestInProcessContext(nullptr, nullptr, nullptr); |
55 } | 56 } |
56 | 57 |
57 TestInProcessContextProvider::TestInProcessContextProvider( | 58 TestInProcessContextProvider::TestInProcessContextProvider( |
58 TestInProcessContextProvider* shared_context) | 59 TestInProcessContextProvider* shared_context) |
59 : context_(CreateTestInProcessContext( | 60 : context_(CreateTestInProcessContext( |
60 &gpu_memory_buffer_manager_, | 61 &gpu_memory_buffer_manager_, |
61 &image_factory_, | 62 &image_factory_, |
62 (shared_context ? shared_context->context_.get() : nullptr))) {} | 63 (shared_context ? shared_context->context_.get() : nullptr))), |
| 64 cache_controller_( |
| 65 new ContextCacheController(context_->GetImplementation())) {} |
63 | 66 |
64 TestInProcessContextProvider::~TestInProcessContextProvider() { | 67 TestInProcessContextProvider::~TestInProcessContextProvider() { |
65 } | 68 } |
66 | 69 |
67 bool TestInProcessContextProvider::BindToCurrentThread() { | 70 bool TestInProcessContextProvider::BindToCurrentThread() { |
68 return true; | 71 return true; |
69 } | 72 } |
70 | 73 |
71 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { | 74 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { |
72 return context_->GetImplementation(); | 75 return context_->GetImplementation(); |
73 } | 76 } |
74 | 77 |
75 gpu::ContextSupport* TestInProcessContextProvider::ContextSupport() { | 78 gpu::ContextSupport* TestInProcessContextProvider::ContextSupport() { |
76 return context_->GetImplementation(); | 79 return context_->GetImplementation(); |
77 } | 80 } |
78 | 81 |
79 class GrContext* TestInProcessContextProvider::GrContext() { | 82 class GrContext* TestInProcessContextProvider::GrContext() { |
80 if (gr_context_) | 83 if (gr_context_) |
81 return gr_context_->get(); | 84 return gr_context_->get(); |
82 | 85 |
83 gr_context_.reset(new skia_bindings::GrContextForGLES2Interface(ContextGL())); | 86 gr_context_.reset(new skia_bindings::GrContextForGLES2Interface(ContextGL())); |
| 87 cache_controller_->SetGrContext(gr_context_->get()); |
84 return gr_context_->get(); | 88 return gr_context_->get(); |
85 } | 89 } |
86 | 90 |
| 91 ContextCacheController* TestInProcessContextProvider::CacheController() { |
| 92 return cache_controller_.get(); |
| 93 } |
| 94 |
87 void TestInProcessContextProvider::InvalidateGrContext(uint32_t state) { | 95 void TestInProcessContextProvider::InvalidateGrContext(uint32_t state) { |
88 if (gr_context_) | 96 if (gr_context_) |
89 gr_context_->ResetContext(state); | 97 gr_context_->ResetContext(state); |
90 } | 98 } |
91 | 99 |
92 base::Lock* TestInProcessContextProvider::GetLock() { | 100 base::Lock* TestInProcessContextProvider::GetLock() { |
93 return &context_lock_; | 101 return &context_lock_; |
94 } | 102 } |
95 | 103 |
96 gpu::Capabilities TestInProcessContextProvider::ContextCapabilities() { | 104 gpu::Capabilities TestInProcessContextProvider::ContextCapabilities() { |
97 gpu::Capabilities capabilities; | 105 gpu::Capabilities capabilities; |
98 capabilities.image = true; | 106 capabilities.image = true; |
99 capabilities.texture_rectangle = true; | 107 capabilities.texture_rectangle = true; |
100 capabilities.sync_query = true; | 108 capabilities.sync_query = true; |
101 switch (PlatformColor::Format()) { | 109 switch (PlatformColor::Format()) { |
102 case PlatformColor::SOURCE_FORMAT_RGBA8: | 110 case PlatformColor::SOURCE_FORMAT_RGBA8: |
103 capabilities.texture_format_bgra8888 = false; | 111 capabilities.texture_format_bgra8888 = false; |
104 break; | 112 break; |
105 case PlatformColor::SOURCE_FORMAT_BGRA8: | 113 case PlatformColor::SOURCE_FORMAT_BGRA8: |
106 capabilities.texture_format_bgra8888 = true; | 114 capabilities.texture_format_bgra8888 = true; |
107 break; | 115 break; |
108 } | 116 } |
109 return capabilities; | 117 return capabilities; |
110 } | 118 } |
111 | 119 |
112 void TestInProcessContextProvider::DeleteCachedResources() { | |
113 if (gr_context_) | |
114 gr_context_->FreeGpuResources(); | |
115 } | |
116 | |
117 void TestInProcessContextProvider::SetLostContextCallback( | 120 void TestInProcessContextProvider::SetLostContextCallback( |
118 const LostContextCallback& lost_context_callback) {} | 121 const LostContextCallback& lost_context_callback) {} |
119 | 122 |
120 } // namespace cc | 123 } // namespace cc |
OLD | NEW |