Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/fallback/FallbackScreenConfiguration.h
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 file,
3
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#ifndef mozilla_fallback_FallbackScreenConfiguration_h
6
#define mozilla_fallback_FallbackScreenConfiguration_h
7
8
#include "Hal.h"
9
#include "nsIScreenManager.h"
10
#include "nsServiceManagerUtils.h"
11
12
namespace mozilla {
13
namespace fallback {
14
15
inline void
16
GetCurrentScreenConfiguration(hal::ScreenConfiguration* aScreenConfiguration)
17
0
{
18
0
  nsresult rv;
19
0
  nsCOMPtr<nsIScreenManager> screenMgr =
20
0
    do_GetService("@mozilla.org/gfx/screenmanager;1", &rv);
21
0
  if (NS_FAILED(rv)) {
22
0
    NS_ERROR("Can't find nsIScreenManager!");
23
0
    return;
24
0
  }
25
0
26
0
  int32_t colorDepth, pixelDepth, x, y, w, h;
27
0
  ScreenOrientation orientation;
28
0
  nsCOMPtr<nsIScreen> screen;
29
0
30
0
  screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
31
0
  screen->GetRect(&x, &y, &w, &h);
32
0
  screen->GetColorDepth(&colorDepth);
33
0
  screen->GetPixelDepth(&pixelDepth);
34
0
  orientation = w >= h
35
0
                ? hal::eScreenOrientation_LandscapePrimary
36
0
                : hal::eScreenOrientation_PortraitPrimary;
37
0
38
0
  *aScreenConfiguration = hal::ScreenConfiguration(nsIntRect(x, y, w, h),
39
0
               orientation, 0,
40
0
               colorDepth, pixelDepth);
41
0
}
42
43
}
44
}
45
46
#endif // mozilla_fallback_FallbackScreenConfiguration_h