Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/webrender_bindings/RenderCompositorOGL.cpp
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
#include "RenderCompositorOGL.h"
8
9
#include "GLContext.h"
10
#include "GLContextProvider.h"
11
#include "mozilla/widget/CompositorWidget.h"
12
13
namespace mozilla {
14
namespace wr {
15
16
/* static */ UniquePtr<RenderCompositor>
17
RenderCompositorOGL::Create(RefPtr<widget::CompositorWidget>&& aWidget)
18
0
{
19
0
  RefPtr<gl::GLContext> gl;
20
0
  gl = gl::GLContextProvider::CreateForCompositorWidget(aWidget, true);
21
0
  if (!gl || !gl->MakeCurrent()) {
22
0
    gfxCriticalNote << "Failed GL context creation for WebRender: " << gfx::hexa(gl.get());
23
0
    return nullptr;
24
0
  }
25
0
  return MakeUnique<RenderCompositorOGL>(std::move(gl), std::move(aWidget));
26
0
}
27
28
RenderCompositorOGL::RenderCompositorOGL(RefPtr<gl::GLContext>&& aGL,
29
                                         RefPtr<widget::CompositorWidget>&& aWidget)
30
  : RenderCompositor(std::move(aWidget))
31
  , mGL(aGL)
32
0
{
33
0
  MOZ_ASSERT(mGL);
34
0
}
35
36
RenderCompositorOGL::~RenderCompositorOGL()
37
0
{
38
0
}
39
40
bool
41
RenderCompositorOGL::BeginFrame()
42
0
{
43
0
  if (!mGL->MakeCurrent()) {
44
0
    gfxCriticalNote << "Failed to make render context current, can't draw.";
45
0
    return false;
46
0
  }
47
0
  return true;
48
0
}
49
50
void
51
RenderCompositorOGL::EndFrame()
52
0
{
53
0
  mGL->SwapBuffers();
54
0
}
55
56
void
57
RenderCompositorOGL::Pause()
58
0
{
59
#ifdef MOZ_WIDGET_ANDROID
60
  if (!mGL || mGL->IsDestroyed()) {
61
    return;
62
  }
63
  // ReleaseSurface internally calls MakeCurrent.
64
  mGL->ReleaseSurface();
65
#endif
66
}
67
68
bool
69
RenderCompositorOGL::Resume()
70
0
{
71
#ifdef MOZ_WIDGET_ANDROID
72
  if (!mGL || mGL->IsDestroyed()) {
73
    return false;
74
  }
75
  // RenewSurface internally calls MakeCurrent.
76
  return mGL->RenewSurface(mWidget);
77
#else
78
  return true;
79
0
#endif
80
0
}
81
82
LayoutDeviceIntSize
83
RenderCompositorOGL::GetBufferSize()
84
0
{
85
0
  return mWidget->GetClientSize();
86
0
}
87
88
89
} // namespace wr
90
} // namespace mozilla