55 Commits

Author SHA1 Message Date
Collin Jackson
779f5743e5 Refactor of text rendering into painting layer 2015-08-14 13:30:56 -07:00
Adam Barth
d291fcaecd Merge pull request #620 from abarth/compositing_update
Add a compositing update phase
2015-08-14 11:09:28 -07:00
Adam Barth
e17aa1b63a Add a compositing update phase
We need to compute whether a RenderObject has a composited descendant so that
we can decide whether to use canvas.saveLayer or to create a new composited
layer while walking down the tree during painting.

The compositing update walks the tree from the root only to places where the
tree's structure has been mutated. In the common case during an animation loop,
we won't need to visit any render object beyond the root.
2015-08-14 10:47:39 -07:00
Adam Barth
e0f14e3719 Add debug painting for layer borders
This patch makes it easier to debug layerization issues.
2015-08-14 10:46:53 -07:00
Adam Barth
86da2f9bf4 Separate the notions of offset and size in compositing
Separating these notions makes them easier to work with because offset is
relative to the parent layer whereas size is intrinsic to the layer itself.
This patch fixes the underpainting bugs when compositing the stocks example.
2015-08-14 09:49:38 -07:00
Adam Barth
53884a37de Generalize _cleanRelayoutSubtreeRootChildren into visitChildren
This generalization will let us implement other alogorithims that need to walk
the RenderObject tree.
2015-08-14 09:37:19 -07:00
Adam Barth
bf260f98e3 Add a compositing step to the lifecycle
Now we have the ability to draw multiple PictureLayers. We still squash all the
pictures together into a single SkPicture for simplicity. In the future, we'll
submit them to C++ separately and composite them on the GPU thread.
2015-08-13 16:31:45 -07:00
Adam Barth
7cba729110 Switch painting over to using PictureLayer
Currently we have a single PictureLayer that everyone draws into. A future
patch will teach the system to use multiple PictureLayers.
2015-08-13 14:24:29 -07:00
Adam Barth
be8454073a Rename createsNewDisplayList to requiresCompositing
This patch prepares for introducing the compositing system by repurposing the
relevant parts of the createsNewDisplayList system. This patch also removes the
no-longer-relevant parts of that system.
2015-08-13 12:43:39 -07:00
Adam Barth
c80603cf0e Add PaintingContext which has-a sky.Canvas instead of is-a sky.Canvas
We'll need this for compositing because we need to switch out the sky.Canvas
when we switch compositing layers.
2015-08-13 10:18:33 -07:00
Adam Barth
12586a6343 RenderBox.hitTest should do the bounds check
Previously we were doing the bounds testing for hit tests in the parent, but
that doesn't work if the child paints at a location other than 0.0, 0.0. Now we
do the bounds check in the child. This also simplifies Scaffold's hit testing.

Fixes #558
2015-08-12 17:46:10 -07:00
Adam Barth
88eba9150f Don't paint twice
In refactoring the way we generate the SkPicture, I accidentially made us
generate the SkPicture twice. This CL causes us to generate it only once.
2015-08-11 14:38:49 -07:00
Adam Barth
ae9f170243 Images in Stocks drawer layout at crazy sizes
Now that we get sky.Image callbacks synchronously, we were actually figuring in
the width and height of images the second time the drawer opened in the Stocks
app. That exposed a bug in our RenderImage layout code whereby it would ignore
the _width and _height properties when the image was non-null.
2015-08-11 09:52:22 -07:00
Adam Barth
2701b469cf Merge pull request #545 from abarth/image_resource
Use ImageResource instead of Future<sky.Image>
2015-08-11 08:35:49 -07:00
Hans Muller
d2d9ae134d The IgnorePointer class enables one to cut a widget subtree off from pointer events. This is useful when a sibling should not shield pointer events from overlapping siblings below it.
Added a ScrollListener listener to Scrollable. The ScrollListener runs each time the Scrollable's scrollOffset changes. This can be used to keep overlay widgets in sync with a Scrollable below them.

Removed the Scrollable ScrollClient API. It was no longer used and was clumsy to use as a ScrollListener.

Added global function findScrollableAncestor() to scrollable.dart.

Added examples/widgets/overlay_geometry.dart. The app's Scaffold is contained by a Stack. The Stack is used to display green overlay "Markers" at the corners of the most recently selected list item and where the corresponding tap occurred. The app uses widget.localToGlobal() to compute the global overlay positions of the markers. The ScrollListener is used to keep the markers' positions up to date.
2015-08-11 08:29:30 -07:00
Adam Barth
9f228349e9 Use ImageResource instead of Future<sky.Image>
Using ImageResource solves two problems:

1) Listeners can be notified synchronously when the sky.Image is already
   available. This change removes flash of 0x0 layout when moving an
   already-cached image around in the render tree.

2) In the future, when we support animated images, we can notify listeners
   multiple times whenever a new image is available.
2015-08-10 20:43:32 -07:00
Adam Barth
e3d9ea67da Simplify SkPicture
This patch simplifies the SkPicture we generate for Skia. Instead of drawing
everything into a nested SkPicture, we now draw everything into the top-level
picture, which requires us to apply the device scale factor in Dart.
2015-08-10 15:12:13 -07:00
Adam Barth
ec0bccfb5d Optimize circular clips slightly
This patch avoids creating weak references on every paint call by caching the
Path object between paints.
2015-08-10 11:18:44 -07:00
Andrew Wilson
440a63a5bb Fix assert's related to image drawing. 2015-08-07 17:00:56 -07:00
Adam Barth
68565eb317 Use localToGlobal and globalToLocal in MimicOverlay
Also, make RenderStack support negative positions with clipping so that we can
expand objects that are partially offscreen.
2015-08-07 14:47:06 -07:00
Hans Muller
585f3f6297 Widget coordinate transforms: localToGlobal(), globalToLocal() 2015-08-07 14:20:57 -07:00
Adam Barth
b5e0b7c99a Unbreak text
Previously, no text was appearing because we weren't actually converting the
Dart objects into DOM.
2015-08-07 10:37:04 -07:00
Adam Barth
fb512aa604 Merge pull request #494 from abarth/integer_scrolling
RenderViewport should use integer device pixels
2015-08-07 09:52:14 -07:00
Adam Barth
4a70cfed5f Rename various text-related classes
- Inline -> Pargraph. This class is actually a box, not an inline. It's really
   a wrapper for RenderParagraph, so Paragraph is the normal name.

 - InlineBase -> RenderInline. The name we used in C++ for the base class of
   all inlines was RenderInline, which removes the ugly "Base" suffix.

 - InlineText -> RenderText. Aligns this name with C++.

 - InlineStyle -> RenderStyled. Matches the foregoing pattern.
2015-08-06 22:26:02 -07:00
Adam Barth
75da2a9f98 RenderViewport should use integer device pixels
When painting a scroll offset, RenderViewport should use integer device pixels
to prevent "shimmering" effects on images.

Fixes #486
2015-08-06 22:09:51 -07:00
Adam Barth
fd68741fb3 Add operator+ and operator- to EdgeDims
... and use them to improve the horizontal_scrolling example.
2015-08-06 09:41:22 -07:00
Adam Barth
870376dab1 Teach ScrollableBlock how to scroll horizontally
Now ScrollableBlock can combine a horizontally scrolling viewport with a
horizontal block.

Also rename ViewportScrollDirection to just ScrollDirection for less verbosity.
2015-08-05 18:10:03 -07:00
Adam Barth
6f2a3e406d Merge pull request #476 from abarth/horizontal_block
Teach Block how to layout horizontally
2015-08-05 17:36:31 -07:00
Adam Barth
f6c9ab8050 Teach Block how to layout horizontally
We'll need this for horizontally scrolling lists.
2015-08-05 17:20:13 -07:00
Adam Barth
2a4209553f Support horizontal scrolling in ScrollableViewport 2015-08-05 16:18:15 -07:00
Adam Barth
325bfcc739 Fix RenderViewport's hit testing
We were subtracting the scrollOffset when we were supposed to add it.
2015-08-04 15:54:51 -07:00
Matt Perry
78e18a5d18 When animating, use the same curve until it completes.
This ensures we don't run into discontinuities when reversing an
animation halfway through. I refactored AnimationValue to have knowledge
of the reverse curves and intervals.
2015-08-04 16:34:46 -04:00
James Robinson
56a4a8ad81 Add RenderToggleable base and use in Switch and Checkbox
This refactors Checkbox to own a RenderObject similar to how Switch was
refactored in https://github.com/domokit/sky_engine/pull/376 and
extracts common functionality for toggleable renderers into a base
class.  Switch and Checkbox's render objects derive from this base
class to add their own custom painting and theming logic.
2015-08-04 10:45:30 -07:00
James Robinson
53163f8b99 Teach event system about disposition and make 'consumed' disposition terminal
This introduces the notion of event disposition and allows event
targets (widgets and render objects) to consume events that should not
be processed further. This is needed by the Switch component in the
Drawer in the stocks example. The Switch is embedded in a DrawerItem.
The Switch handles the gesture tap event to toggle its state and should
handle pointer events to allow swiping and draw its own radial
reaction. The DrawerItem also handles gesture taps to allow toggling
the switch value when tapping anywhere on the drawer and to draw its
own ink splash. When tapping on the switch, both the switch's render
object and the DrawerItem's listener are in the event dispatch path.
The Switch needs to signal in some fashion that it consumed the event
so the DrawerItem does not also try to toggle the switch's state.
2015-08-03 17:31:30 -07:00
Adam Barth
2b0e4784d3 Fix TextAlign.right
We were applying the style to the RenderInline but we actually needed to apply
it to the RenderParagraph. The lineHeight property had the same problem.
2015-07-31 12:57:53 -07:00
Adam Barth
05d6d55171 Merge pull request #373 from abarth/fix_stack
RenderStack should handle top, right, bottom, left all being zero
2015-07-30 11:11:07 -07:00
Adam Barth
b86ad9b053 RenderStack should handle top, right, bottom, left all being zero
Previously, we didn't set the width of the child correctly when top and bottom
(or left and right) were both specified.

Fixes #275
2015-07-30 10:08:07 -07:00
Adam Barth
3c14e41b07 Sporadic crash from invalid touch event
When embedded by the view_manager, sometimes we receive pointerup or
pointercancel events without having received a cooresponding pointerdown event.
The underlying issue is that the view_manager doesn't capture on pointerdown
and instead performs a new hit test for every pointer event. We should fix that
in view_manager, but, in the meantime, this patch makes us not crash in this
scenario.

Fixes #339
2015-07-30 09:41:40 -07:00
Adam Barth
5d15bb5126 Move build() off microtasks
Rather than using a microtask to schedule component build functions, instead
use the scheduler. We now tread building just like layout and painting as a
visual update.
2015-07-28 14:05:21 -07:00
Hixie
144fe36e25 RenderConstrainedBox was ignoring its additional constraints for its intrinsic size logic when it had no child. 2015-07-23 09:06:34 -07:00
Hixie
a50b065197 Fix the crash when going to settings after showing the popup menu.
If your constraints are tight when you get laid out, you don't get a
relayout subtree root.

If you don't have a relayout subtree root, and you get marked dirty,
you go through layoutWithoutResize() rather than layout(), so we don't
get a parentUsesSize.

If you're not dirty and your constraints didn't change, layout() skips
your layout.

So then if your initial layout had parentUsesSize:true, and then you
got marked dirty directly, you would set your size with
parentCanUseSize=false, and then later if your parent tried to lay you
out then read your size, it would crash because your size wasn't set
up to allow you to get your size.

The fix is to actually remember the last setting of parentUsesSize,
even in the case of the constraints being tight and you later being
marked as needing layout directly.
2015-07-22 10:10:58 -07:00
Adam Barth
6b748e653e Fix more analyzer warnings 2015-07-21 13:59:18 -07:00
Adam Barth
53efc748e1 Merge pull request #191 from abarth/image_height_width
Separate width and height parameters for Image widgets
2015-07-21 13:54:56 -07:00
Adam Barth
012b915704 Separate width and height parameters for Image widgets
This change makes it easier to defined only the width or the height of an image
and let the other value be filled in from the image's intrinsic aspect ratio.

Fixes #175
2015-07-21 13:46:10 -07:00
Matt Perry
0fd3302ebe Renamed AnimatedType to AnimatedValue 2015-07-21 12:55:16 -07:00
Adam Barth
7af81f208a Fix typos in RenderImage
This function took innerConstraints as an argument but used constraints internally.
2015-07-20 20:04:03 -07:00
Collin Jackson
e90d0ec807 Merge remote-tracking branch 'upstream/master' into baseline5
Conflicts:
	sky/sdk/lib/rendering/flex.dart
2015-07-20 10:26:06 -07:00
Collin Jackson
8bf1f86a24 abarth feedback 2015-07-20 10:24:52 -07:00
Collin Jackson
4604021dd3 Support for non-alphabetic baselines 2015-07-17 17:06:08 -07:00
Collin Jackson
e3d5c2b25e Draw debug rects when flex overflows 2015-07-17 17:04:59 -07:00