Skip to content

Commit

Permalink
[CGD2D] Add support for Transparency Layers. (#1496)
Browse files Browse the repository at this point in the history
This changeset introduces support for transparency layers. Transparency layers serve as render targets that are composed down to the backing surface in one fell swoop.

To make way for this, CGContext was mildly refactored:
* Existing private (denoted by `__CGContextX`) methods were moved into `__CGContext` the class as `__CGContext::X`.
* Graphics state manipulation was promoted to `__CGContext`.
* Some methods were promoted to drawing state methods (clipping, draw decision)
* `__CGContextLayer`, a class that tracks a stack of drawing states and their destination buffers, was introduced.
* CGContext's render target setup was moved into its constructor.
* `globalAlpha` was reintroduced, as sometimes per-primitive alpha is just not enough. *Such as: layers are composed down all at once using the alpha set at the time the context was created.*

Deficiencies:
* Clipped layers are implemented in terms of a baseline clipping state applied to the layer. All primitives are drawn through a Direct2D **PushLayer** and **PopLayer** pair.
* Alpha-composited layers are implemented in terms of the same.
* There is some dodgy math witnessed on the reference platform that grows shadowed layers by some combination of shadow offset and width; an attempt was made to mimic this.
* Minor layering violations that pass a `__CGContext` to a `CGContextXxx()` public function by way of **this**.

Fixes #1427, #584.
  • Loading branch information
DHowett committed Dec 6, 2016
1 parent 82f0cc3 commit 3176d73
Show file tree
Hide file tree
Showing 7 changed files with 601 additions and 166 deletions.
Loading

0 comments on commit 3176d73

Please sign in to comment.