/src/mozilla-central/gfx/webrender_bindings/RendererOGL.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef MOZILLA_LAYERS_RENDEREROGL_H |
8 | | #define MOZILLA_LAYERS_RENDEREROGL_H |
9 | | |
10 | | #include "mozilla/layers/CompositorTypes.h" |
11 | | #include "mozilla/webrender/RenderThread.h" |
12 | | #include "mozilla/webrender/WebRenderTypes.h" |
13 | | #include "mozilla/webrender/webrender_ffi.h" |
14 | | |
15 | | namespace mozilla { |
16 | | |
17 | | namespace gfx { |
18 | | class DrawTarget; |
19 | | } |
20 | | |
21 | | namespace gl { |
22 | | class GLContext; |
23 | | } |
24 | | |
25 | | namespace layers { |
26 | | class CompositorBridgeParent; |
27 | | class SyncObjectHost; |
28 | | } |
29 | | |
30 | | namespace widget { |
31 | | class CompositorWidget; |
32 | | } |
33 | | |
34 | | namespace wr { |
35 | | |
36 | | class RenderCompositor; |
37 | | class RenderTextureHost; |
38 | | |
39 | | /// Owns the WebRender renderer and GL context. |
40 | | /// |
41 | | /// There is one renderer per window, all owned by the render thread. |
42 | | /// This class is a similar abstraction to CompositorOGL except that it is used |
43 | | /// on the render thread instead of the compositor thread. |
44 | | class RendererOGL |
45 | | { |
46 | | friend wr::WrExternalImage LockExternalImage(void* aObj, |
47 | | wr::WrExternalImageId aId, |
48 | | uint8_t aChannelIndex, |
49 | | wr::ImageRendering); |
50 | | friend void UnlockExternalImage(void* aObj, wr::WrExternalImageId aId, uint8_t aChannelIndex); |
51 | | |
52 | | public: |
53 | | wr::WrExternalImageHandler GetExternalImageHandler(); |
54 | | |
55 | | /// This can be called on the render thread only. |
56 | | void Update(); |
57 | | |
58 | | /// This can be called on the render thread only. |
59 | | bool UpdateAndRender(bool aReadback); |
60 | | |
61 | | /// This can be called on the render thread only. |
62 | | bool RenderToTarget(gfx::DrawTarget& aTarget); |
63 | | |
64 | | /// This can be called on the render thread only. |
65 | | void SetProfilerEnabled(bool aEnabled); |
66 | | |
67 | | /// This can be called on the render thread only. |
68 | | void SetFrameStartTime(const TimeStamp& aTime); |
69 | | |
70 | | /// This can be called on the render thread only. |
71 | | ~RendererOGL(); |
72 | | |
73 | | /// This can be called on the render thread only. |
74 | | RendererOGL(RefPtr<RenderThread>&& aThread, |
75 | | UniquePtr<RenderCompositor> aCompositor, |
76 | | wr::WindowId aWindowId, |
77 | | wr::Renderer* aRenderer, |
78 | | layers::CompositorBridgeParent* aBridge); |
79 | | |
80 | | /// This can be called on the render thread only. |
81 | | void Pause(); |
82 | | |
83 | | /// This can be called on the render thread only. |
84 | | bool Resume(); |
85 | | |
86 | | layers::SyncObjectHost* GetSyncObject() const; |
87 | | |
88 | 0 | layers::CompositorBridgeParent* GetCompositorBridge() { return mBridge; } |
89 | | |
90 | | wr::WrPipelineInfo FlushPipelineInfo(); |
91 | | |
92 | | RenderTextureHost* GetRenderTexture(wr::WrExternalImageId aExternalImageId); |
93 | | |
94 | 0 | wr::Renderer* GetRenderer() { return mRenderer; } |
95 | | |
96 | | gl::GLContext* gl() const; |
97 | | |
98 | | protected: |
99 | | void NotifyWebRenderError(WebRenderError aError); |
100 | | |
101 | | RefPtr<RenderThread> mThread; |
102 | | UniquePtr<RenderCompositor> mCompositor; |
103 | | wr::Renderer* mRenderer; |
104 | | layers::CompositorBridgeParent* mBridge; |
105 | | wr::WindowId mWindowId; |
106 | | TimeStamp mFrameStartTime; |
107 | | wr::DebugFlags mDebugFlags; |
108 | | }; |
109 | | |
110 | | } // namespace wr |
111 | | } // namespace mozilla |
112 | | |
113 | | #endif |