[M67 Dev][Tizen] Redirect UncheckedMalloc to malloc for Tizen
[platform/framework/web/chromium-efl.git] / tizen_src / chromium_impl / content / browser / compositor / mailbox_output_surface_efl.h
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.
4
5 #ifndef CONTENT_BROWSER_COMPOSITOR_MAILBOX_OUTPUT_SURFACE_EFL_H_
6 #define CONTENT_BROWSER_COMPOSITOR_MAILBOX_OUTPUT_SURFACE_EFL_H_
7
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"
15
16 namespace content {
17
18 class MailboxOutputSurfaceEfl : public viz::OutputSurface {
19  public:
20   MailboxOutputSurfaceEfl(
21       const scoped_refptr<ui::ContextProviderCommandBuffer>& context_provider,
22       viz::ResourceFormat format);
23   ~MailboxOutputSurfaceEfl() override;
24
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,
32                float scale_factor,
33                const gfx::ColorSpace& color_space,
34                bool has_alpha,
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;
45
46  private:
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);
58
59   struct TransferableFrame {
60     TransferableFrame();
61     TransferableFrame(uint32_t texture_id,
62                       const gpu::Mailbox& mailbox,
63                       const gfx::Size size);
64
65     uint32_t texture_id;
66     gpu::Mailbox mailbox;
67     gpu::SyncToken sync_token;
68     gfx::Size size;
69   };
70
71   base::CancelableCallback<void(
72       const std::vector<ui::LatencyInfo>&,
73       gfx::SwapResult,
74       const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac)>
75       swap_buffers_completion_callback_;
76
77   ui::CompositorClient* compositor_client_;
78
79   TransferableFrame current_backing_;
80   std::deque<TransferableFrame> pending_textures_;
81   std::queue<TransferableFrame> returned_textures_;
82
83   uint32_t fbo_;
84   bool is_backbuffer_discarded_;
85   bool texture_upload_pending_;
86   viz::ResourceFormat format_;
87 };
88
89 }  // namespace content
90
91 #endif  // CONTENT_BROWSER_COMPOSITOR_MAILBOX_OUTPUT_SURFACE_EFL_H_