1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_COMPOSITOR_MAILBOX_OUTPUT_SURFACE_EFL_H_
6 #define CONTENT_BROWSER_COMPOSITOR_MAILBOX_OUTPUT_SURFACE_EFL_H_
8 #include "base/cancelable_callback.h"
9 #include "components/viz/common/resources/resource_format.h"
10 #include "components/viz/service/display/output_surface.h"
11 #include "gpu/ipc/client/command_buffer_proxy_impl.h"
12 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h"
13 #include "ui/compositor/compositor.h"
14 #include "ui/gfx/swap_result.h"
18 class MailboxOutputSurfaceEfl : public viz::OutputSurface {
20 MailboxOutputSurfaceEfl(
21 const scoped_refptr<ui::ContextProviderCommandBuffer>& context_provider,
22 viz::ResourceFormat format);
23 ~MailboxOutputSurfaceEfl() override;
25 // viz::OutputSurface implementation.
26 void BindToClient(viz::OutputSurfaceClient* client) override;
27 void EnsureBackbuffer() override;
28 void DiscardBackbuffer() override;
29 void BindFramebuffer() override;
30 void SetDrawRectangle(const gfx::Rect& rect) override;
31 void Reshape(const gfx::Size& size,
33 const gfx::ColorSpace& color_space,
35 bool use_stencil) override;
36 void SwapBuffers(viz::OutputSurfaceFrame frame) override;
37 bool HasExternalStencilTest() const override;
38 void ApplyExternalStencil() override;
39 uint32_t GetFramebufferCopyTextureFormat() override;
40 viz::OverlayCandidateValidator* GetOverlayCandidateValidator() const override;
41 bool IsDisplayedAsOverlayPlane() const override;
42 unsigned GetOverlayTextureId() const override;
43 gfx::BufferFormat GetOverlayBufferFormat() const override;
44 bool SurfaceIsSuspendForRecycle() const override;
47 #if !defined(EWK_BRINGUP) // FIXME: m67 bringup
48 // FIXME: EWK_BRINGUP definition should be removed.
49 // cc::GLFrameData was removed in cc/output/gl_frame_data.h
50 void OnSwapAck(std::unique_ptr<cc::GLFrameData> gl_frame_data);
51 void DrawTexture(std::unique_ptr<cc::GLFrameData> gl_frame_data);
52 #endif // !defined(EWK_BRINGUP)
53 gpu::CommandBufferProxyImpl* GetCommandBufferProxy();
54 void OnSwapBuffersCompleted(
55 const std::vector<ui::LatencyInfo>& latency_info,
56 gfx::SwapResult result,
57 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac);
59 struct TransferableFrame {
61 TransferableFrame(uint32_t texture_id,
62 const gpu::Mailbox& mailbox,
63 const gfx::Size size);
67 gpu::SyncToken sync_token;
71 base::CancelableCallback<void(
72 const std::vector<ui::LatencyInfo>&,
74 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac)>
75 swap_buffers_completion_callback_;
77 ui::CompositorClient* compositor_client_;
79 TransferableFrame current_backing_;
80 std::deque<TransferableFrame> pending_textures_;
81 std::queue<TransferableFrame> returned_textures_;
84 bool is_backbuffer_discarded_;
85 bool texture_upload_pending_;
86 viz::ResourceFormat format_;
89 } // namespace content
91 #endif // CONTENT_BROWSER_COMPOSITOR_MAILBOX_OUTPUT_SURFACE_EFL_H_