Chromium Code Reviews| Index: content/renderer/android/synchronous_compositor_output_surface.cc |
| diff --git a/content/renderer/android/synchronous_compositor_output_surface.cc b/content/renderer/android/synchronous_compositor_output_surface.cc |
| index 87b543ba7fe1d7df8a40dd1e5e827e9db1586771..f72926789100439fcbf5a591b158c2200e2e4da8 100644 |
| --- a/content/renderer/android/synchronous_compositor_output_surface.cc |
| +++ b/content/renderer/android/synchronous_compositor_output_surface.cc |
| @@ -49,8 +49,6 @@ const uint32_t kCompositorClientId = 1; |
| // Do not limit number of resources, so use an unrealistically high value. |
| const size_t kNumResourcesLimit = 10 * 1000 * 1000; |
| -} // namespace |
| - |
| class SoftwareDevice : public cc::SoftwareOutputDevice { |
| public: |
| SoftwareDevice(SkCanvas** canvas) : canvas_(canvas) {} |
| @@ -70,7 +68,10 @@ class SoftwareDevice : public cc::SoftwareOutputDevice { |
| DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); |
| }; |
| -class SoftwareOutputSurface : public cc::OutputSurface { |
| +} // namespace |
| + |
| +class SynchronousCompositorOutputSurface::SoftwareOutputSurface |
| + : public cc::OutputSurface { |
| public: |
| SoftwareOutputSurface(std::unique_ptr<SoftwareDevice> software_device) |
| : cc::OutputSurface(nullptr, nullptr, std::move(software_device)) {} |
| @@ -78,6 +79,16 @@ class SoftwareOutputSurface : public cc::OutputSurface { |
| // cc::OutputSurface implementation. |
| uint32_t GetFramebufferCopyTextureFormat() override { return 0; } |
| void SwapBuffers(cc::CompositorFrame frame) override {} |
| + void Reshape(const gfx::Size& size, |
| + float scale_factor, |
| + const gfx::ColorSpace& color_space, |
| + bool has_alpha) override { |
| + // Intentional no-op. Surface size controlled by embedder. |
| + } |
| + |
| + void SetSurfaceSize(const gfx::Size surface_size) { |
| + surface_size_ = surface_size; |
| + } |
| }; |
| SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( |
| @@ -98,7 +109,8 @@ SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( |
| frame_swap_message_queue_(frame_swap_message_queue), |
| surface_manager_(new cc::SurfaceManager), |
| surface_id_allocator_(new cc::SurfaceIdAllocator(kCompositorClientId)), |
| - surface_factory_(new cc::SurfaceFactory(surface_manager_.get(), this)) { |
| + surface_factory_(new cc::SurfaceFactory(surface_manager_.get(), this)), |
| + software_output_surface_(nullptr) { |
| DCHECK(registry_); |
| DCHECK(sender_); |
| thread_checker_.DetachFromThread(); |
| @@ -149,6 +161,11 @@ bool SynchronousCompositorOutputSurface::BindToClient( |
| cc::RendererSettings software_renderer_settings; |
| + std::unique_ptr<SoftwareOutputSurface> output_surface( |
| + new SoftwareOutputSurface( |
| + base::MakeUnique<SoftwareDevice>(¤t_sw_canvas_))); |
| + software_output_surface_ = output_surface.get(); |
| + |
| // The shared_bitmap_manager and gpu_memory_buffer_manager here are null as |
| // this Display is only used for resourcesless software draws, where no |
| // resources are included in the frame swapped from the compositor. So there |
| @@ -156,9 +173,7 @@ bool SynchronousCompositorOutputSurface::BindToClient( |
| display_.reset(new cc::Display( |
| nullptr /* shared_bitmap_manager */, |
| nullptr /* gpu_memory_buffer_manager */, software_renderer_settings, |
| - nullptr /* begin_frame_source */, |
| - base::MakeUnique<SoftwareOutputSurface>( |
| - base::MakeUnique<SoftwareDevice>(¤t_sw_canvas_)), |
| + nullptr /* begin_frame_source */, std::move(output_surface), |
| nullptr /* scheduler */, nullptr /* texture_mailbox_deleter */)); |
| display_->Initialize(&display_client_, surface_manager_.get(), |
| surface_id_allocator_->client_id()); |
| @@ -177,6 +192,7 @@ void SynchronousCompositorOutputSurface::DetachFromClient() { |
| surface_id_allocator_->client_id()); |
| surface_manager_->InvalidateSurfaceClientId( |
| surface_id_allocator_->client_id()); |
| + software_output_surface_ = nullptr; |
| display_ = nullptr; |
| surface_factory_ = nullptr; |
| surface_id_allocator_ = nullptr; |
| @@ -322,6 +338,9 @@ void SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { |
| surface_size_ = gfx::Size(canvas->getBaseLayerSize().width(), |
|
danakj
2016/07/27 21:28:36
Ahh. Does it need to be a member on SCOS still too
boliu
2016/07/27 21:43:04
Hmm... in practice, no, because DelegatingRenderer
danakj
2016/07/27 21:49:53
I'm working toward that right now.
boliu
2016/07/27 22:00:51
Ok, not setting SCOS::surface_size_ anywhere, and
|
| canvas->getBaseLayerSize().height()); |
| base::AutoReset<bool> set_in_software_draw(&in_software_draw_, true); |
| + display_->SetExternalViewport(clip); |
| + display_->SetExternalClip(clip); |
| + software_output_surface_->SetSurfaceSize(surface_size_); |
| InvokeComposite(transform, clip, clip); |
| } |