-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ColorMode, StencilMode, DepthMode abstractions
- Loading branch information
Lauren Budorick
authored
Dec 13, 2017
1 parent
cca8ba4
commit 4658095
Showing
18 changed files
with
272 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// @flow | ||
const Color = require('../style-spec/util/color'); | ||
|
||
import type {BlendFuncType, ColorMaskType} from './types'; | ||
|
||
const ZERO = 0x0000; | ||
const ONE = 0x0001; | ||
const ONE_MINUS_SRC_ALPHA = 0x0303; | ||
|
||
class ColorMode { | ||
blendFunction: BlendFuncType; | ||
blendColor: Color; | ||
mask: ColorMaskType; | ||
|
||
constructor(blendFunction: BlendFuncType, blendColor: Color, mask: ColorMaskType) { | ||
this.blendFunction = blendFunction; | ||
this.blendColor = blendColor; | ||
this.mask = mask; | ||
} | ||
|
||
static Replace: BlendFuncType; | ||
|
||
static disabled(): ColorMode { | ||
return new ColorMode(ColorMode.Replace, Color.transparent, [false, false, false, false]); | ||
} | ||
|
||
static unblended(): ColorMode { | ||
return new ColorMode(ColorMode.Replace, Color.transparent, [true, true, true, true]); | ||
} | ||
|
||
static alphaBlended(): ColorMode { | ||
return new ColorMode([ONE, ONE_MINUS_SRC_ALPHA], Color.transparent, [true, true, true, true]); | ||
} | ||
} | ||
|
||
ColorMode.Replace = [ONE, ZERO]; | ||
|
||
module.exports = ColorMode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// @flow | ||
import type { DepthFuncType, DepthMaskType, DepthRangeType } from './types'; | ||
|
||
const ALWAYS = 0x0207; | ||
|
||
class DepthMode { | ||
func: DepthFuncType; | ||
mask: DepthMaskType; | ||
range: DepthRangeType; | ||
|
||
// DepthMask enums | ||
static ReadOnly: boolean; | ||
static ReadWrite: boolean; | ||
|
||
constructor(depthFunc: DepthFuncType, depthMask: DepthMaskType, depthRange: DepthRangeType) { | ||
this.func = depthFunc; | ||
this.mask = depthMask; | ||
this.range = depthRange; | ||
} | ||
|
||
static disabled() { | ||
return new DepthMode(ALWAYS, DepthMode.ReadOnly, [0, 1]); | ||
} | ||
} | ||
|
||
DepthMode.ReadOnly = false; | ||
DepthMode.ReadWrite = true; | ||
|
||
module.exports = DepthMode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// @flow | ||
import type { StencilOpConstant, StencilTest } from './types'; | ||
|
||
const ALWAYS = 0x0207; | ||
const KEEP = 0x1E00; | ||
|
||
class StencilMode { | ||
test: StencilTest; | ||
ref: number; | ||
mask: number; | ||
fail: StencilOpConstant; | ||
depthFail: StencilOpConstant; | ||
pass: StencilOpConstant; | ||
|
||
constructor(test: StencilTest, ref: number, mask: number, fail: StencilOpConstant, | ||
depthFail: StencilOpConstant, pass: StencilOpConstant) { | ||
this.test = test; | ||
this.ref = ref; | ||
this.mask = mask; | ||
this.fail = fail; | ||
this.depthFail = depthFail; | ||
this.pass = pass; | ||
} | ||
|
||
static disabled() { | ||
return new StencilMode({ func: ALWAYS, mask: 0 }, 0, 0, KEEP, KEEP, KEEP); | ||
} | ||
} | ||
|
||
module.exports = StencilMode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.