summaryrefslogtreecommitdiff
path: root/chromium/skia/ext/legacy_display_globals.cc
blob: fa4e39227dd29eb6b1f150076ca722aebf5af2e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "skia/ext/legacy_display_globals.h"

namespace skia {

namespace {
SkPixelGeometry g_pixel_geometry = kRGB_H_SkPixelGeometry;
}

// static
void LegacyDisplayGlobals::SetCachedPixelGeometry(
    SkPixelGeometry pixel_geometry) {
  g_pixel_geometry = pixel_geometry;
}

// static
SkPixelGeometry LegacyDisplayGlobals::GetCachedPixelGeometry() {
  return g_pixel_geometry;
}

// static
SkSurfaceProps LegacyDisplayGlobals::GetSkSurfaceProps() {
  return GetSkSurfaceProps(0);
}

// static
SkSurfaceProps LegacyDisplayGlobals::GetSkSurfaceProps(uint32_t flags) {
  return SkSurfaceProps{flags, g_pixel_geometry};
}

SkSurfaceProps LegacyDisplayGlobals::ComputeSurfaceProps(
    bool can_use_lcd_text) {
  uint32_t flags = 0;
  if (can_use_lcd_text) {
    return LegacyDisplayGlobals::GetSkSurfaceProps(flags);
  }
  // Use unknown pixel geometry to disable LCD text.
  return SkSurfaceProps{flags, kUnknown_SkPixelGeometry};
}

}  // namespace skia