| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/output/compositor_frame_sink.h" | 5 #include "cc/output/compositor_frame_sink.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 base::trace_event::ProcessMemoryDump* pmd_; | 114 base::trace_event::ProcessMemoryDump* pmd_; |
| 115 uint64_t share_group_tracing_guid_; | 115 uint64_t share_group_tracing_guid_; |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(SkiaGpuTraceMemoryDump); | 117 DISALLOW_COPY_AND_ASSIGN(SkiaGpuTraceMemoryDump); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } // namespace | 120 } // namespace |
| 121 | 121 |
| 122 CompositorFrameSink::CompositorFrameSink( | 122 CompositorFrameSink::CompositorFrameSink( |
| 123 scoped_refptr<ContextProvider> context_provider, | 123 scoped_refptr<ContextProvider> context_provider, |
| 124 scoped_refptr<ContextProvider> worker_context_provider, | 124 scoped_refptr<ContextProvider> worker_context_provider) |
| 125 std::unique_ptr<SoftwareOutputDevice> software_device) | |
| 126 : context_provider_(std::move(context_provider)), | 125 : context_provider_(std::move(context_provider)), |
| 127 worker_context_provider_(std::move(worker_context_provider)), | 126 worker_context_provider_(std::move(worker_context_provider)), |
| 128 software_device_(std::move(software_device)), | |
| 129 weak_ptr_factory_(this) { | 127 weak_ptr_factory_(this) { |
| 130 client_thread_checker_.DetachFromThread(); | 128 client_thread_checker_.DetachFromThread(); |
| 131 } | 129 } |
| 132 | 130 |
| 133 CompositorFrameSink::CompositorFrameSink( | 131 CompositorFrameSink::CompositorFrameSink( |
| 134 scoped_refptr<VulkanContextProvider> vulkan_context_provider) | 132 scoped_refptr<VulkanContextProvider> vulkan_context_provider) |
| 135 : vulkan_context_provider_(vulkan_context_provider), | 133 : vulkan_context_provider_(vulkan_context_provider), |
| 136 weak_ptr_factory_(this) { | 134 weak_ptr_factory_(this) { |
| 137 client_thread_checker_.DetachFromThread(); | 135 client_thread_checker_.DetachFromThread(); |
| 138 } | 136 } |
| 139 | 137 |
| 140 CompositorFrameSink::~CompositorFrameSink() { | 138 CompositorFrameSink::~CompositorFrameSink() { |
| 141 if (client_) | 139 if (client_) |
| 142 DetachFromClientInternal(); | 140 DetachFromClientInternal(); |
| 143 } | 141 } |
| 144 | 142 |
| 145 bool CompositorFrameSink::HasExternalStencilTest() const { | |
| 146 return false; | |
| 147 } | |
| 148 | |
| 149 void CompositorFrameSink::ApplyExternalStencil() {} | |
| 150 | |
| 151 bool CompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) { | 143 bool CompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) { |
| 152 DCHECK(client_thread_checker_.CalledOnValidThread()); | 144 DCHECK(client_thread_checker_.CalledOnValidThread()); |
| 153 DCHECK(client); | 145 DCHECK(client); |
| 154 DCHECK(!client_); | 146 DCHECK(!client_); |
| 155 client_ = client; | 147 client_ = client; |
| 156 bool success = true; | 148 bool success = true; |
| 157 | 149 |
| 158 if (context_provider_.get()) { | 150 if (context_provider_.get()) { |
| 159 success = context_provider_->BindToCurrentThread(); | 151 success = context_provider_->BindToCurrentThread(); |
| 160 if (success) { | 152 if (success) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 177 | 169 |
| 178 if (!success) | 170 if (!success) |
| 179 DetachFromClient(); | 171 DetachFromClient(); |
| 180 return success; | 172 return success; |
| 181 } | 173 } |
| 182 | 174 |
| 183 void CompositorFrameSink::DetachFromClient() { | 175 void CompositorFrameSink::DetachFromClient() { |
| 184 DetachFromClientInternal(); | 176 DetachFromClientInternal(); |
| 185 } | 177 } |
| 186 | 178 |
| 187 void CompositorFrameSink::EnsureBackbuffer() { | |
| 188 if (software_device_) | |
| 189 software_device_->EnsureBackbuffer(); | |
| 190 } | |
| 191 | |
| 192 void CompositorFrameSink::DiscardBackbuffer() { | |
| 193 if (context_provider_.get()) | |
| 194 context_provider_->ContextGL()->DiscardBackbufferCHROMIUM(); | |
| 195 if (software_device_) | |
| 196 software_device_->DiscardBackbuffer(); | |
| 197 } | |
| 198 | |
| 199 void CompositorFrameSink::Reshape(const gfx::Size& size, | |
| 200 float scale_factor, | |
| 201 const gfx::ColorSpace& color_space, | |
| 202 bool has_alpha) { | |
| 203 device_color_space_ = color_space; | |
| 204 if (size == surface_size_ && scale_factor == device_scale_factor_ && | |
| 205 has_alpha == has_alpha_) | |
| 206 return; | |
| 207 | |
| 208 surface_size_ = size; | |
| 209 device_scale_factor_ = scale_factor; | |
| 210 has_alpha_ = has_alpha; | |
| 211 if (context_provider_.get()) { | |
| 212 context_provider_->ContextGL()->ResizeCHROMIUM(size.width(), size.height(), | |
| 213 scale_factor, has_alpha); | |
| 214 } | |
| 215 if (software_device_) | |
| 216 software_device_->Resize(size, scale_factor); | |
| 217 } | |
| 218 | |
| 219 void CompositorFrameSink::BindFramebuffer() { | |
| 220 DCHECK(context_provider_.get()); | |
| 221 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); | |
| 222 } | |
| 223 | |
| 224 void CompositorFrameSink::PostSwapBuffersComplete() { | 179 void CompositorFrameSink::PostSwapBuffersComplete() { |
| 225 base::ThreadTaskRunnerHandle::Get()->PostTask( | 180 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 226 FROM_HERE, base::Bind(&CompositorFrameSink::OnSwapBuffersComplete, | 181 FROM_HERE, base::Bind(&CompositorFrameSink::OnSwapBuffersComplete, |
| 227 weak_ptr_factory_.GetWeakPtr())); | 182 weak_ptr_factory_.GetWeakPtr())); |
| 228 } | 183 } |
| 229 | 184 |
| 230 // We don't post tasks bound to the client directly since they might run | 185 // We don't post tasks bound to the client directly since they might run |
| 231 // after the CompositorFrameSink has been destroyed. | 186 // after the CompositorFrameSink has been destroyed. |
| 232 void CompositorFrameSink::OnSwapBuffersComplete() { | 187 void CompositorFrameSink::OnSwapBuffersComplete() { |
| 233 client_->DidSwapBuffersComplete(); | 188 client_->DidSwapBuffersComplete(); |
| 234 } | 189 } |
| 235 | 190 |
| 236 void CompositorFrameSink::DidReceiveTextureInUseResponses( | |
| 237 const gpu::TextureInUseResponses& responses) { | |
| 238 client_->DidReceiveTextureInUseResponses(responses); | |
| 239 } | |
| 240 | |
| 241 OverlayCandidateValidator* CompositorFrameSink::GetOverlayCandidateValidator() | |
| 242 const { | |
| 243 return nullptr; | |
| 244 } | |
| 245 | |
| 246 bool CompositorFrameSink::IsDisplayedAsOverlayPlane() const { | |
| 247 return false; | |
| 248 } | |
| 249 | |
| 250 unsigned CompositorFrameSink::GetOverlayTextureId() const { | |
| 251 return 0; | |
| 252 } | |
| 253 | |
| 254 bool CompositorFrameSink::SurfaceIsSuspendForRecycle() const { | |
| 255 return false; | |
| 256 } | |
| 257 | |
| 258 bool CompositorFrameSink::OnMemoryDump( | 191 bool CompositorFrameSink::OnMemoryDump( |
| 259 const base::trace_event::MemoryDumpArgs& args, | 192 const base::trace_event::MemoryDumpArgs& args, |
| 260 base::trace_event::ProcessMemoryDump* pmd) { | 193 base::trace_event::ProcessMemoryDump* pmd) { |
| 261 if (auto* context_provider = this->context_provider()) { | 194 if (auto* context_provider = this->context_provider()) { |
| 262 // No need to lock, main context provider is not shared. | 195 // No need to lock, main context provider is not shared. |
| 263 if (auto* gr_context = context_provider->GrContext()) { | 196 if (auto* gr_context = context_provider->GrContext()) { |
| 264 SkiaGpuTraceMemoryDump trace_memory_dump( | 197 SkiaGpuTraceMemoryDump trace_memory_dump( |
| 265 pmd, context_provider->ContextSupport()->ShareGroupTracingGUID()); | 198 pmd, context_provider->ContextSupport()->ShareGroupTracingGUID()); |
| 266 gr_context->dumpMemoryStatistics(&trace_memory_dump); | 199 gr_context->dumpMemoryStatistics(&trace_memory_dump); |
| 267 } | 200 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 296 client_ = nullptr; | 229 client_ = nullptr; |
| 297 weak_ptr_factory_.InvalidateWeakPtrs(); | 230 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 298 } | 231 } |
| 299 | 232 |
| 300 void CompositorFrameSink::DidLoseCompositorFrameSink() { | 233 void CompositorFrameSink::DidLoseCompositorFrameSink() { |
| 301 TRACE_EVENT0("cc", "CompositorFrameSink::DidLoseCompositorFrameSink"); | 234 TRACE_EVENT0("cc", "CompositorFrameSink::DidLoseCompositorFrameSink"); |
| 302 client_->DidLoseCompositorFrameSink(); | 235 client_->DidLoseCompositorFrameSink(); |
| 303 } | 236 } |
| 304 | 237 |
| 305 } // namespace cc | 238 } // namespace cc |
| OLD | NEW |