Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/basic/X11TextureSourceBasic.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 "X11TextureSourceBasic.h"
8
#include "gfxXlibSurface.h"
9
#include "gfx2DGlue.h"
10
11
namespace mozilla {
12
namespace layers {
13
14
using namespace mozilla::gfx;
15
16
X11TextureSourceBasic::X11TextureSourceBasic(BasicCompositor* aCompositor, gfxXlibSurface* aSurface)
17
 : mSurface(aSurface)
18
0
{
19
0
}
20
21
IntSize
22
X11TextureSourceBasic::GetSize() const
23
0
{
24
0
  return mSurface->GetSize();
25
0
}
26
27
SurfaceFormat
28
X11TextureSourceBasic::GetFormat() const
29
0
{
30
0
  gfxContentType type = mSurface->GetContentType();
31
0
  return X11TextureSourceBasic::ContentTypeToSurfaceFormat(type);
32
0
}
33
34
SourceSurface*
35
X11TextureSourceBasic::GetSurface(DrawTarget* aTarget)
36
0
{
37
0
  if (!mSourceSurface) {
38
0
    mSourceSurface =
39
0
        Factory::CreateSourceSurfaceForCairoSurface(mSurface->CairoSurface(),
40
0
                                                    GetSize(), GetFormat());
41
0
  }
42
0
  return mSourceSurface;
43
0
}
44
45
SurfaceFormat
46
X11TextureSourceBasic::ContentTypeToSurfaceFormat(gfxContentType aType)
47
{
48
  switch (aType) {
49
    case gfxContentType::COLOR:
50
      return SurfaceFormat::B8G8R8X8;
51
    case gfxContentType::ALPHA:
52
      return SurfaceFormat::A8;
53
    case gfxContentType::COLOR_ALPHA:
54
      return SurfaceFormat::B8G8R8A8;
55
    default:
56
      return SurfaceFormat::UNKNOWN;
57
  }
58
}
59
60
}
61
}