87 Commits

Author SHA1 Message Date
Adlai Holler
5c15869087 Disable Text Node Fast Path (#2581)
* Disable text node fast path

* Actually commit the test change
2016-11-09 10:25:02 +09:00
Garrett Moon
076d22e9f1 Do not reuse NSStringDrawingContexts (#2537) 2016-11-02 14:37:51 -07:00
Adlai Holler
f09b92641c Invalidate TextNode Renderer Instead of Changing constrainedSize (#2516)
* Instead of changing its constrained size, just invalidate renderer. It's virtually the same.

* Check constrained size before invalidating renderer
2016-10-31 14:14:21 -07:00
Adlai Holler
3eb7a307fa Share a singleton shadower for all cases when shadow isn't drawn, fix issues (#2511) 2016-10-30 15:34:29 -07:00
Adlai Holler
c0125010c1 Workaround iOS 7 text drawing bug (#2492) 2016-10-27 11:48:49 -07:00
Adlai Holler
0d439a43b6 [ASTextNode] Add Fast-Paths For Text Measurement and Drawing (#2392)
* Add test case for TextKit truncation style

* Add fast path for text node measurement with default truncation

* Use fast path more often

* Reverse options order

* Simplify implementation – no functional change

* Share "isScaled" variable

* Intersect with constrained rect

* Add a failing test case for fast-path truncation

* Add some more truncation tests, using slow path as reference image

* Update the tests

* In ASTextKitRenderer, intersect bounds with constrained rect

* Add test case for TextKit truncation style

* Add fast path for text node measurement with default truncation

* Use fast path more often

* Reverse options order

* Simplify implementation – no functional change

* Share "isScaled" variable

* Intersect with constrained rect

* Add a failing test case for fast-path truncation

* Add some more truncation tests, using slow path as reference image

* Update the tests

* In ASTextKitRenderer, intersect bounds with constrained rect

* Use maximumNumberOfLines property in text kit fast path

Add reference images

Disable fast-path for max-one-line case

* Remove unneeded snapshot files
2016-10-24 17:05:59 -07:00
appleguy
0a5c1f43a8 [ASRunLoopQueue - Performance] Add ASDeallocQueue for efficient object teardown. (#2399)
* [ASRunLoopQueue - Performance] Add ASDeallocQueue for efficient object teardown.

This measurably reduces block overhead and context switching.  In the layout benchmark,
it increases ops/s while actually reducing CPU utilization.  This suggests that we are
now at a lock-bounded local maximum, at least for tri-core devices.

* [ASDeallocQueue] Update convenience helper method and adopt in ASImageNode etc.

* [ASDeallocQueue] Reimplement the queue using a timer-based runloop.

* [Debugging] Re-enable ASDisplayNode Event Log.

* [ASDeallocQueue] Final refinements, comments, code minimization.

* [ASDeallocQueue] Fix for lock release needed in early return (refactoring typo from last commit)
2016-10-17 12:24:11 -07:00
Adlai Holler
cb838664aa [ASTextNode] Go Back to Having Renderer as Ivar (#2376)
* Revert "Disable ASTextKitRenderer cache (#2315)"

This reverts commit 4aa7c9631d3a03b1542fac168f1a74531755392a.

* Revert "[ASTextNode] Add NSCache based cache for ASTextKitRenderer (#2199)"
2016-10-13 11:37:56 -07:00
ricky
872aad220f [ASTextKitFontSizeAdjuster] Use the constrainedSize’s height to adjust font scaling (#2309)
* refactor shrinking logic

# Conflicts:
#	AsyncDisplayKit/TextKit/ASTextKitFontSizeAdjuster.mm

* fix ASTraitCollection sample

* updated comments.

* fix build errors

* adlai’s comments
2016-10-04 13:01:50 -04:00
Michael Schneider
8897614f0e [Layout] Layout API based on content area (#2110)
* Initial commit for adding a size constraint to ASLayoutable's

* Some more commits

* Fix sample projects in extra/

* Remove preferredFrameSize test of ASEditableTextNode

* Remove preferredFrameSize from examples_extra

* Add deprecation warning to -[ASDisplayNode preferredFrameSize]

* Add deprecation warning to -[ASDisplayNode measureWithSizeRange:]

* Commit

* Commit

* Remove ASRelativeSizeRange

* Make ASRelativeSize private

* Adjust examples

* Improve setting of -[ASLayoutable size] with points or fractions

* Add ASWrapperLayoutSpec

* Improve creation of ASRelativeDimension

* Add `preferredFrameSize` back and add deprecated logging

* Add `layoutSpecBlock` setter and getter and add locking for it

* Add better documentation and fix macros to create ASRelativeDimension

* Create new ASSizeRangeMake with just a CGSize as parameter

* Update Kitten and Social App Layout example

* Add layoutThatFits: and deprecate measure:

* Rename ASRelativeDimension to ASDimension

* Fix examples for ASDimension renaming

* Remove fancy height and width setter

* Fix ASDimension helper

* Rename -[ASLayout layoutableObject] to -[ASLayout layoutable]

* Update layout related methods and more clearer documentation around how to use it

* Deprecate old ASLayout class constructors

* Don't unnecessary recalculate layout if constrained or parent size did not change

* Use shared pointer for ASDisplayNodeLayout

* Fix rebase conflicts

* Add documentation and move implementation in mm file of ASDisplayNodeLayout

* Fix test errors

* Rename ASSize to ASLayoutableSize

* Address comments

* Rename setSizeFromCGSize to setSizeWithCGSize

* Improve inline functions in ASDimension

* Fix rebase conflicts
2016-09-07 08:44:48 -07:00
Michael Schneider
2388f67474 [ASTextNode] Add NSCache based cache for ASTextKitRenderer (#2199)
* Add cache implementation

* Remove old ASEqualityHashHelpers

* Some more ASEquality and ASEqualityHashHelper cleanup

* Add cache for text renderer in ASTextNode

* Move from C++ LRU renderer cache to NSCache based renderer cache
2016-09-06 15:23:21 -07:00
Adlai Holler
90c59e0de7 Remove completely unused layoutManagerDelegate things (#2189) 2016-09-04 12:01:42 -07:00
Adlai Holler
9c3b688a87 Remove textStorageCreationBlock API (#2142)
* Remove textStorageCreationBlock API

* Remove layoutManagerCreationBlock also
2016-08-26 11:42:20 -07:00
Adlai Holler
04ecd4180e [ASTextKitRenderer] Shift TextKit Teardown onto the Deallocation Queue (#2136)
* [ASTextKitRenderer] Shift TextKit teardown onto the deallocation queue

* Import it!
2016-08-25 17:29:31 -07:00
Hannah Trosi
971d43ad4d [Build settings] add missing newlines at end of file 2016-08-18 15:01:41 -07:00
Hannah Troisi
893e601e81 Convert to type-generic math (#2050)
* [Optimization] Convert to type-generic math

* add std:: prefix in obj-c++ files

* more cleanup

* revert test changes

* convert min and max back to fmin/fmax
2016-08-09 15:31:37 -07:00
Michael Schneider
aba05a747c [ASThread] Add SharedLocker and SharedUnlocker that uses a shared pointer for the mutex (#2047)
* Add SharedLocker and SharedUnlocker that uses a shared pointer for the mutex

* Move ASTextKitContext to use Shared Locker
2016-08-09 15:20:31 -07:00
Adlai Holler
5ff5a27717 [ASTextKitComponents] Remove unused, somewhat dangerous functions (#2007)
[ASTextKitComponents] Remove Unused Scale Conversion Functions
2016-07-28 20:43:27 -07:00
Yue-Wang-Google
7426c1dd66 Fixed implicit cast for 64-bit devices in ASTextKitComponents.h (#1994) 2016-07-28 17:03:02 -07:00
Michael Schneider
6e573fba0d Reset _calculatedSize if a new constrained size is set on the ASTextKitRenderer (#1942) 2016-07-16 16:23:47 -07:00
Hannah Troisi
4baf9bdbfe [Infer] Fix Infer errors/warnings (#1938)
* [Infer] Fix 11 Infer errors/warnings

* fix build error
2016-07-16 15:29:24 -07:00
Michael Schneider
bbc957bce5 Throw away all subcomponents of the text kit renderer if constraints are changing
Throw away the all subcomponents to create them with the new constrained size new as well as let the truncater do it's job again for the new constrained size. This is necessary as after a truncation did happen the context would use the truncated string and not the original string to truncate based on the new constrained size
2016-07-14 15:11:10 -07:00
Scott Goodson
bf9c142765 Revert "[ASTextNode] Fix text node truncation (#1863)"
This reverts commit 6238e5edbde55fb82982ce4a19a0cbca7fe7eb9d.

We will re-apply this change, but there are some early signs of performance impacts that need to be investigated.
2016-07-09 23:54:43 -07:00
Scott Goodson
d83f319fe3 Revert "Use textStorageCreationBlock for resetting the text storage (#1874)"
This reverts commit d646d3c753193382f8ad029172d975c782ad8544.
2016-07-09 23:54:28 -07:00
appleguy
3b2af7eb6d [Build] Remove Unused Imports across all of AsyncDisplayKit. This uses a feature of AppCode. (#1875)
Details on the tool are here: https://www.jetbrains.com/help/idea/2016.1/optimizing-imports.html
2016-07-09 17:20:59 -07:00
Michael Schneider
d646d3c753 Use textStorageCreationBlock for resetting the text storage (#1874) 2016-07-09 16:43:18 -07:00
Michael Schneider
6238e5edbd [ASTextNode] Fix text node truncation (#1863)
* Before truncate a text storage in ASTextKitContext reset the text storage to original value

* Fix ASTextNode tests

We should pass in the constrained size in both cases and the sizes should be the same. We adjust the calculated size in ASTextNode to be a bit narrower in the second case if we truncate again with the calculated size as constrained size it will truncate more and the resulting size will shrink.
2016-07-09 15:40:31 -07:00
Michael Schneider
f25e0f0d01 Fix Xcode 8 errors 2016-07-08 10:51:07 -07:00
Michael Schneider
22fa715682 Move lock from ASDN::Mutex to std::mutex in ASTextKitContext 2016-06-20 13:42:17 -07:00
Hannah Troisi
c857e809f4 Clean up header comments (for consistent Facebook licensing info) (#1741)
[Licensing] Clean up header comments (for consistent Facebook licensing info)
2016-06-11 23:31:39 -07:00
Michael Schneider
a914e3c428 Change visibleSizeRange to return a range with 0 location and length 2016-06-04 15:40:07 -07:00
Michael Schneider
19bb6519ed Fix crash truncating a string of a node with a zero size
The crash happens in the placeholderImage of ASTextNode. The node is not visible in the time it try to get the `placeholderImage` and so the `visibleRange` has count 0 and a crash happens while accessing the first object of an empty array.
2016-06-03 09:53:59 -07:00
rcancro
ffde31a1b2 Fixed a crash in ASTextNode that I made
fixes a crash introduced by https://github.com/facebook/AsyncDisplayKit/pull/1637
2016-05-10 15:25:34 -07:00
rcancro
22e026a5e1 fix truncater method to only return the truncater. 2016-05-09 16:36:27 -07:00
rcancro
082ababda6 Fix to text shrinking
Summary: Previously the first thing we did when calculating the size of text was to truncate it. This could lead to ASFontSizeAdjuster being sent a truncated string which, obviously, never needed to shrink. If we change the order then we first shrink, then truncate if still necessary.

Reviewers: scottg, levi, garrett

Differential Revision: https://phabricator.pinadmin.com/D89780
2016-05-09 15:59:08 -07:00
appleguy
fcdc7966cc Merge pull request #1536 from garrettmoon/upstream-renderer-lock
[ASTextNode] Add locking around NSTextContainer's constrainedSize
2016-04-15 20:57:32 -07:00
Garrett Moon
dd998b086f I think this needs a lock.
Summary: Looks like this isn't being locked when it should be.

Reviewers: ricky, levi, scottg, schneider

Reviewed By: scottg, schneider

Subscribers: jenkins

Differential Revision: https://phabricator.pinadmin.com/D84952
2016-04-15 10:41:31 -07:00
Michael Schneider
c0927f8028 Create helper function to get text range rects without locking
Add helper function that should be called within performBlockWithLockedTextKitComponents: in
 an already locked state to prevent a deadlock
2016-04-15 09:57:24 -07:00
Michael Schneider
a9d0542d8f If trailing rect was set early return 2016-04-15 07:10:22 -07:00
Michael Schneider
91b6995987 Fix deadlock calling trailingRect on a ASTextNode 2016-04-15 07:10:22 -07:00
appleguy
ea935456b8 Merge pull request #1437 from ejensen/editable-text-node-layout-manager
[ASEditableTextNode] Allow TextKit component customization
2016-03-31 20:46:19 -07:00
Scott Goodson
daf41ebb43 [ASTextNode] Fix edge case where text truncator may not run (manually hosted nodes that are lacking the expected call to -measure).
This fixes the scenario described in https://github.com/facebook/AsyncDisplayKit/issues/1295
2016-03-26 18:19:02 -07:00
Eric Jensen
387abbff5d Rename ASTextKitHelpers to ASTextKitComponents and make the header public 2016-03-26 15:31:53 -07:00
Eric Jensen
0758475409 Remove unnecessary imports 2016-03-25 22:33:02 -07:00
Eric Jensen
f8f3585764 Add a ASTextKitComponents initializer that allows customization of its NSTextStorage and NSLayoutManager 2016-03-25 22:12:19 -07:00
Eric Jensen
057ec55941 Correct documentation comments 2016-03-24 20:08:03 -07:00
Scott Goodson
8308a4ce49 [AsyncDisplayKit] Adopt #pragma once, remove last remaining dispatch_sync (UIScreen scale). 2016-03-19 19:56:41 -07:00
Eric Jensen
14a389c5e0 Replace ASTextKitAttributes' objectsEqual with the shared ASObjectIsEqual 2016-03-17 10:36:35 -07:00
appleguy
d9ef0922d8 Merge pull request #1354 from ejensen/cleanup
[Refactoring] Objective-C 2.0 / Modern syntax for arrays, dictionaries, numbers; logic simplification
2016-03-17 01:06:33 -07:00
Eric Jensen
33fda7ab49 - Use modern Objective-C syntax.
-  Simplify comparisons.
-  Remove dead stores.
2016-03-15 22:34:29 -07:00