Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/widget/CompositorWidget.cpp
Line
Count
Source (jump to first uncovered line)
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#include "CompositorWidget.h"
6
#include "GLConsts.h"
7
#include "nsBaseWidget.h"
8
#include "VsyncDispatcher.h"
9
10
namespace mozilla {
11
namespace widget {
12
13
CompositorWidget::CompositorWidget(const layers::CompositorOptions& aOptions)
14
  : mOptions(aOptions)
15
0
{
16
0
}
17
18
CompositorWidget::~CompositorWidget()
19
0
{
20
0
}
21
22
already_AddRefed<gfx::DrawTarget>
23
CompositorWidget::StartRemoteDrawing()
24
0
{
25
0
  return nullptr;
26
0
}
27
28
void
29
CompositorWidget::CleanupRemoteDrawing()
30
0
{
31
0
  mLastBackBuffer = nullptr;
32
0
}
33
34
already_AddRefed<gfx::DrawTarget>
35
CompositorWidget::GetBackBufferDrawTarget(gfx::DrawTarget* aScreenTarget,
36
                                          const LayoutDeviceIntRect& aRect,
37
                                          const LayoutDeviceIntRect& aClearRect)
38
0
{
39
0
  MOZ_ASSERT(aScreenTarget);
40
0
  gfx::SurfaceFormat format =
41
0
    aScreenTarget->GetFormat() == gfx::SurfaceFormat::B8G8R8X8 ? gfx::SurfaceFormat::B8G8R8X8 : gfx::SurfaceFormat::B8G8R8A8;
42
0
  gfx::IntSize size = aRect.ToUnknownRect().Size();
43
0
  gfx::IntSize clientSize(GetClientSize().ToUnknownSize());
44
0
45
0
  RefPtr<gfx::DrawTarget> target;
46
0
  // Re-use back buffer if possible
47
0
  if (mLastBackBuffer &&
48
0
      mLastBackBuffer->GetBackendType() == aScreenTarget->GetBackendType() &&
49
0
      mLastBackBuffer->GetFormat() == format &&
50
0
      size <= mLastBackBuffer->GetSize() &&
51
0
      mLastBackBuffer->GetSize() <= clientSize) {
52
0
    target = mLastBackBuffer;
53
0
    target->SetTransform(gfx::Matrix());
54
0
    if (!aClearRect.IsEmpty()) {
55
0
      gfx::IntRect clearRect = aClearRect.ToUnknownRect() - aRect.ToUnknownRect().TopLeft();
56
0
      target->ClearRect(gfx::Rect(clearRect.X(), clearRect.Y(), clearRect.Width(), clearRect.Height()));
57
0
    }
58
0
  } else {
59
0
    target = aScreenTarget->CreateSimilarDrawTarget(size, format);
60
0
    mLastBackBuffer = target;
61
0
  }
62
0
  return target.forget();
63
0
}
64
65
already_AddRefed<gfx::SourceSurface>
66
CompositorWidget::EndBackBufferDrawing()
67
0
{
68
0
  RefPtr<gfx::SourceSurface> surface = mLastBackBuffer ? mLastBackBuffer->Snapshot() : nullptr;
69
0
  return surface.forget();
70
0
}
71
72
uint32_t
73
CompositorWidget::GetGLFrameBufferFormat()
74
0
{
75
0
  return LOCAL_GL_RGBA;
76
0
}
77
78
RefPtr<VsyncObserver>
79
CompositorWidget::GetVsyncObserver() const
80
0
{
81
0
  // This should only used when the widget is in the GPU process, and should be
82
0
  // implemented by IPDL-enabled CompositorWidgets.
83
0
  // GPU process does not have a CompositorVsyncDispatcher.
84
0
  MOZ_ASSERT_UNREACHABLE("Must be implemented by derived class");
85
0
  return nullptr;
86
0
}
87
88
} // namespace widget
89
} // namespace mozilla