Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "LayersTypes.h"
7 :
8 : #include "nsStyleStruct.h" // for nsStyleFilter
9 :
10 : namespace mozilla {
11 : namespace layers {
12 :
13 0 : CSSFilter ToCSSFilter(const nsStyleFilter& filter)
14 : {
15 0 : switch (filter.GetType()) {
16 : case NS_STYLE_FILTER_BRIGHTNESS: {
17 : return {
18 : CSSFilterType::BRIGHTNESS,
19 0 : filter.GetFilterParameter().GetFactorOrPercentValue(),
20 0 : };
21 : }
22 : case NS_STYLE_FILTER_CONTRAST: {
23 : return {
24 : CSSFilterType::CONTRAST,
25 0 : filter.GetFilterParameter().GetFactorOrPercentValue(),
26 0 : };
27 : }
28 : case NS_STYLE_FILTER_GRAYSCALE: {
29 : return {
30 : CSSFilterType::GRAYSCALE,
31 0 : filter.GetFilterParameter().GetFactorOrPercentValue(),
32 0 : };
33 : }
34 : case NS_STYLE_FILTER_INVERT: {
35 : return {
36 : CSSFilterType::INVERT,
37 0 : filter.GetFilterParameter().GetFactorOrPercentValue(),
38 0 : };
39 : }
40 : case NS_STYLE_FILTER_SEPIA: {
41 : return {
42 : CSSFilterType::SEPIA,
43 0 : filter.GetFilterParameter().GetFactorOrPercentValue(),
44 0 : };
45 : }
46 : // All other filter types should be prevented by the code which converts
47 : // display items into layers.
48 : default:
49 0 : MOZ_ASSERT_UNREACHABLE("Tried to convert an unsupported filter");
50 : return { CSSFilterType::CONTRAST, 0 };
51 : }
52 : }
53 :
54 : } // namespace layers
55 : } // namespace mozilla
56 :
|