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/resources/platform_color.h" | 12 #include "cc/resources/platform_color.h" |
13 #include "gpu/GLES2/gl2extchromium.h" | 13 #include "gpu/GLES2/gl2extchromium.h" |
14 #include "gpu/command_buffer/client/gl_in_process_context.h" | 14 #include "gpu/command_buffer/client/gl_in_process_context.h" |
15 #include "gpu/command_buffer/client/gles2_implementation.h" | 15 #include "gpu/command_buffer/client/gles2_implementation.h" |
16 #include "gpu/command_buffer/client/gles2_lib.h" | 16 #include "gpu/command_buffer/client/gles2_lib.h" |
17 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 17 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
18 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" | 18 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" |
19 #include "third_party/khronos/GLES2/gl2.h" | 19 #include "third_party/khronos/GLES2/gl2.h" |
20 #include "third_party/khronos/GLES2/gl2ext.h" | 20 #include "third_party/khronos/GLES2/gl2ext.h" |
21 #include "third_party/skia/include/gpu/GrContext.h" | 21 #include "third_party/skia/include/gpu/GrContext.h" |
22 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 22 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
23 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
24 | 24 |
25 namespace cc { | 25 namespace cc { |
26 | 26 |
27 // static | 27 // static |
28 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext( | 28 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext( |
(...skipping 30 matching lines...) Expand all Loading... |
59 } | 59 } |
60 | 60 |
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 if (gr_context_) | |
70 gr_context_->releaseResourcesAndAbandonContext(); | |
71 } | 69 } |
72 | 70 |
73 bool TestInProcessContextProvider::BindToCurrentThread() { return true; } | 71 bool TestInProcessContextProvider::BindToCurrentThread() { return true; } |
74 | 72 |
75 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { | 73 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { |
76 return context_->GetImplementation(); | 74 return context_->GetImplementation(); |
77 } | 75 } |
78 | 76 |
79 gpu::ContextSupport* TestInProcessContextProvider::ContextSupport() { | 77 gpu::ContextSupport* TestInProcessContextProvider::ContextSupport() { |
80 return context_->GetImplementation(); | 78 return context_->GetImplementation(); |
81 } | 79 } |
82 | 80 |
83 class GrContext* TestInProcessContextProvider::GrContext() { | 81 class GrContext* TestInProcessContextProvider::GrContext() { |
84 if (gr_context_) | 82 if (gr_context_) |
85 return gr_context_.get(); | 83 return gr_context_->get(); |
86 | 84 |
87 sk_sp<GrGLInterface> interface( | 85 gr_context_.reset(new skia_bindings::GrContextForGLES2Interface(ContextGL())); |
88 skia_bindings::CreateGLES2InterfaceBindings(ContextGL())); | 86 return gr_context_->get(); |
89 | |
90 gr_context_ = skia::AdoptRef(GrContext::Create( | |
91 // GrContext takes ownership of |interface|. | |
92 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); | |
93 return gr_context_.get(); | |
94 } | 87 } |
95 | 88 |
96 void TestInProcessContextProvider::InvalidateGrContext(uint32_t state) { | 89 void TestInProcessContextProvider::InvalidateGrContext(uint32_t state) { |
97 if (gr_context_) | 90 if (gr_context_) |
98 gr_context_->resetContext(state); | 91 gr_context_->ResetContext(state); |
99 } | 92 } |
100 | 93 |
101 void TestInProcessContextProvider::SetupLock() { | 94 void TestInProcessContextProvider::SetupLock() { |
102 } | 95 } |
103 | 96 |
104 base::Lock* TestInProcessContextProvider::GetLock() { | 97 base::Lock* TestInProcessContextProvider::GetLock() { |
105 return &context_lock_; | 98 return &context_lock_; |
106 } | 99 } |
107 | 100 |
108 ContextProvider::Capabilities | 101 ContextProvider::Capabilities |
(...skipping 10 matching lines...) Expand all Loading... |
119 case PlatformColor::SOURCE_FORMAT_BGRA8: | 112 case PlatformColor::SOURCE_FORMAT_BGRA8: |
120 capabilities.gpu.texture_format_bgra8888 = true; | 113 capabilities.gpu.texture_format_bgra8888 = true; |
121 break; | 114 break; |
122 } | 115 } |
123 | 116 |
124 return capabilities; | 117 return capabilities; |
125 } | 118 } |
126 | 119 |
127 void TestInProcessContextProvider::DeleteCachedResources() { | 120 void TestInProcessContextProvider::DeleteCachedResources() { |
128 if (gr_context_) | 121 if (gr_context_) |
129 gr_context_->freeGpuResources(); | 122 gr_context_->FreeGpuResources(); |
130 } | 123 } |
131 | 124 |
132 void TestInProcessContextProvider::SetLostContextCallback( | 125 void TestInProcessContextProvider::SetLostContextCallback( |
133 const LostContextCallback& lost_context_callback) {} | 126 const LostContextCallback& lost_context_callback) {} |
134 | 127 |
135 } // namespace cc | 128 } // namespace cc |
OLD | NEW |