61 Commits
Author SHA1 Message Date
Greg Bolsinga 343bbb1592 Ship ASExperimentalOOMBackgroundDeallocDisable since it decreases OOMs (#1840) 2020-05-26 15:44:31 -07:00
Greg Bolsinga 44c68a3fef Update Texture Xcode project to 11.4 and fix resulting warnings - 4 (#1838)
* Update Texture Xcode project to 11.4 and fix resulting warnings - 4

* Some tests require testing deprecated functionality
2020-05-26 13:55:16 -07:00
vovasty 74fd8f3d33 deprecate ASGraphicsCreateImageWithTraitCollectionAndOptions (#1836) 2020-05-22 20:15:09 -07:00
Luke Zhao cbc5104c15 Fix tint color dead lock #1731 (#1732)
* fix tintColor dead lock

update to use scoped lock

* pull other accessor out of the scoped lock

* fix ASTextNode
2019-11-25 09:49:27 -08:00
vovasty 18fa714c3f deprecate ASGraphicsCreateImageWithOptions (#1704) 2019-10-16 13:20:39 -07:00
Greg Bolsinga 368aa3aadf ASImageNode tintColor improvements. (#1668)
* ASImageNode tintColor improvements.

When ASImageNodes changes tintColor or enters the hierarchy, ensure -setNeedsDisplay is called if the image is templated.

Add unit tests to ensure this behavior works.
2019-09-11 20:18:04 -07:00
Michael Zuccarino 5e7fbf2ff9 Defer image asset regeneration to draw loop (#1663)
There is a potential dealloc race condition that can occur when attempting to perform work with image asset out of the main thread. Moving that work into the image node draw loop if necessary
2019-09-07 03:37:43 -07:00
Greg Bolsinga c24a21a5a9 lock to access the image renderingMode (#1661) 2019-09-06 13:11:10 -07:00
Greg Bolsinga a403160930 Use MutexLocker for safe locking and then access the ivars directly so that another lock access is not required (#1662) 2019-09-06 13:02:16 -07:00
Greg Bolsinga 00c03e8fcb Use standard ivar _ prefix for userInterfaceStyle (#1660) 2019-09-06 12:59:15 -07:00
vovasty 4d6532ccc8 use lock to avoid crash when image might be changed during the trait collection change (#1651) 2019-08-30 12:45:58 -07:00
Rahul Malik 6464153489 Cleanup from recent changes (#1647)
- Fix availability warnings for usage of userInterfaceLevel
- Deprecate `asyncTraitCollectionDidChange` in favor of the new method
- Remove old compiler warning flag added for Xcode 9 building
- Access `textColorFollowsTintColor` with a locked scope
2019-08-28 12:24:03 -07:00
vovasty 1961a5a948 Add support for loading image variants through Asset catalogs (#1630)
Currently ASImageNode would initially load the correct asset from the asset catalog but would not respond to changes in trait collections that would require loading a different asset from the asset catalog. This change allows use to use `-[UIImage imageAsset]` to reference the asset catalog entry for the current image and load the appropriate version based on the current trait collection
2019-08-23 14:42:05 -07:00
Jessie Alvarez ccee5666dd Allow full color tinting on grayscale template images. (#1629)
* Allow full color tinting on grayscale template images.

* Signing a commit with the correct email address.

* Add snapshot test for a grayscale image with ASExperimentalDrawingGlobal enabled.
2019-08-22 12:53:49 -07:00
Hanton Yang 1467319ec3 Minor code improvements (#1622)
* Simplify code logic

* Keep using user-defined type
2019-08-20 22:14:15 -07:00
Rahul Malik b9903a4155 Add support for tinting layer-backed ASDisplayNode (#1617)
* Add support for tinting layer-backed ASImageNode's

* Move tint color support ASDisplayNode

* Address comments, unlock before calling "tintColorDidChange" on
subclasses

* Address comments
2019-08-15 10:03:15 -07:00
Rahul Malik 540f1344ab Add support for tintColor on ASImageNode and ASButtonNode (#1603)
- Add the ability to specify a tintColor for images / buttons that behave similarly to how they would under UIKit.
- Add flag to control if tint color is applied to ASTextNode to match how
UIKit controls if it is .applied to UILabel.
- Update tests for not-tinting automatic render mode for UIImage.
- Add property on ASTextNode2.
- Add tint color support to ASTextNode2.
2019-08-12 09:14:54 -07:00
Greg Bolsinga 7da85c5008 Run Import Optimizer on Texture (#1580)
* Run Import Optimizer on Texture
2019-07-11 19:19:13 -07:00
Greg Bolsinga 4d1176be4d Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2% (#1487)
* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2%

ASImageNode goes from 1384 to 1376. ASNetworkImageNode goes from 1496 to 1464.

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* add comments as requested in garrett's review.

* access ivar directly since already locked as suggested in review.
2019-05-07 11:17:59 -07:00
Greg Bolsinga c571c8d1c4 Shrink ASDisplayNode from 1072 to 968 bytes, reduction of 10.74% (#1484)
* Shrink ASDisplayNode from 1088 to 976 bytes, reduction of 11.48%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* Forgot to bit-field-ify placeholderEnable; new small size is 968, old size is 1072 (measured consistentlyl on iPhoneSE simulator). 10.74% reduction.
2019-05-07 09:56:33 -07:00
Adlai Holler 64c43c0ded Add a new "global drawing" experiment to use UIGraphicsRenderer (#1469)
* Add a new "global drawing" experiment to use UIGraphicsRenderer everywhere, when available

* Fix logic

* Use preferredFormat
2019-05-02 20:42:23 -07:00
Michael Zuccarino bb6c89e3ba Cover the other background dealloc surfaces (#1464) 2019-04-23 12:15:23 -07:00
Huy Nguyen 3120c4e4ee Disable ASAssertLocked and ASAssertUnlocked (#1412) 2019-04-19 23:22:53 -07:00
Adlai Holler 38a67dd328 Shut down graphics contexts experiment (#1458)
* Shut down graphics contexts experiment

* Remove dead import

* Remove gone class
2019-04-18 18:36:39 -07:00
Adlai Holler a4957bbbf2 Revert "Have image nodes draw into opaque contexts automatically if possible (#1432)" (#1443)
This reverts commit 28522ce977.
2019-04-04 07:28:32 -07:00
Adlai Holler 28522ce977 Have image nodes draw into opaque contexts automatically if possible (#1432)
* Have image nodes draw into opaque contexts if the image is opaque and it fills the context

* Call backingSize once
2019-03-29 11:16:35 -07:00
Adlai Holler 9cd0d58373 Rename ASDN C++ namespace to AS (#1366)
* Rename ASDN C++ namespace to "AS." Referring to the framework as ASDisplayNode is pretty out-dated and verbose. See CoreAnimation which usees CA for their internal namespace.

More using

* More cases
2019-03-09 12:14:58 -08:00
Michael Schneider d4efe95ec5 Improve separation of code for layout method types (#1305)
* Improve separation of code for layout method types

* Address PR comments

- Delegate to layout spec engine if the node is a layout spec node but yoga engine was asked for calculate the layout
- Change ASLayoutType to ASLayoutEngineType
- Improve layout engine fall through code
2019-01-28 07:41:49 -08:00
Adlai Holler 2a4b77b6d5 Remove let and var macros now that we're all-C++ (#1312)
* Remove let and var macros now that we're all-C++

* Another fix

* More!

* And more!
2019-01-17 10:16:53 -08:00
Huy Nguyen a255953d34 Avoid using global Mutex variables (#1252)
After 5c9815f, some Mutexes are used as global C++ variables which are loaded before main(). Since the Mutex constructor checks for unfair lock experiment, it triggers an experiment configuration load, and our app isn't ready to respond that early in the process.
2018-11-26 17:25:38 -08:00
Adlai Holler 5c9815f46d ASThread: Remove Locker, Unlocker, and SharedMutex (#1213)
* ASThread: Remove Locker, Unlocker, and SharedMutex

* Remove extra line

* Kick the CI

* Move C++ down

* Fix thing
2018-11-05 13:26:36 -08:00
Huy Nguyen e745aded7d [ASImageNode] Fix a threading issue which can cause a display completion block to never be executed (#1148)
- Clear _displayCompletionBlock while we still have the node's instance lock. Because it may not be the same block by the time the lock is reacquired. In other words, it can happen that another thread sets a new display block after this thread releases the lock but before it reacquires it. And we don't want to clear out the new block.
- Reduce a lock/unlock pair which should help perf a tiny bit.
2018-11-04 16:28:48 -08:00
Eric Jensen 565da7d493 Add missing NS_NOESCAPE in overwritten methods (#1139)
Fixes -Wmissing-noescape warnings
2018-10-04 09:33:08 -07:00
Michael Schneider f759d5cc7d Improve locking around clearContents (#1107)
* Improve locking around clearContents

* Add changelog
2018-09-14 08:48:19 -07:00
Garrett Moon 1fe241df91 #trivial Shouldn't hold the lock while adding subnodes (#1091)
* Shouldn't hold the lock while adding subnodes

* Add comments, good call @nguyenhuy
2018-08-30 22:04:40 -07:00
Garrett Moon cae37623fd Add subnode should not be called with the lock held. (#1088) 2018-08-30 09:30:34 -07:00
appleguy 465abb1ded [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses). (#1077)
* [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses)

With permission of the Facebook Open Source team, we are simplifying the Texture
license so that clients can rely on the Apache 2 terms that most of Texture is
already covered by. This means that code originally forked from AsyncDisplayKit
will be re-licensed from "BSD 3-clause + PATENTS v2" to Apache 2 without a
PATENTS file.

After getting confirmation that the updates to these core files look good, we'll
propagate this new license header to all files (in this same PR) and get sign-off
from all parties before landing.

* [License] Update all Texture source files to be pure Apache 2.

* Changelog entry for Apache 2 license update.

* Revert "[License] Update all Texture source files to be pure Apache 2."

This reverts commit ffa0fbbba9.

* [License] Update all Texture source files to be pure Apache 2, maintaining copyrights.

* [License] Update CONTRIBUTING, README, Podspec & Dangerfile.
2018-08-28 07:39:18 -07:00
Michael Schneider 9e2947e7fb Revert "Optimize drawing code + add examples how to round corners (#996)" (#1055)
This reverts commit eb4c21c545.
2018-07-31 04:40:18 -07:00
Michael Schneider eb4c21c545 Optimize drawing code + add examples how to round corners (#996)
* Use CoreGraphics for drawing and cropping of node content

* Smaller fixes
2018-07-26 09:44:10 -07:00
Huy Nguyen 0dc97fbb2f Stricter locking assertions (#1024)
- Rename `ASDisplayNodeAssertLockUnownedByCurrentThread` to `ASAssertUnlocked`, and `ASDisplayNodeAssertLockOwnedByCurrentThread` to `ASAssertLocked` -> shorter and hopefully easier to distinguish between the two.
- Add assertions to `_locked_` and `_u_` (i.e "unlocked") methods.
- Turn `CHECK_LOCKING_SAFETY` flag on by default. After #1022 and #1023, we're in a good shape to actually enforce locked/unlocked requirements of internal methods. Our test suite passed, and we'll test more at Pinterest after the sync this week.
- Fix ASVideoNode to avoid calling `play` while holding the lock. That method inserts a subnode and must be called lock free.
- Simplify `_loaded(node)` to only nil-check `_layer` because regardless of whether the node is view or layer backed, the layer should always be set if loaded. Use it throughout.
- Other minor changes.
2018-07-13 14:58:16 -07:00
Michael Schneider 55abeed743 Introduce let / var macros and some further cleanup (#1012)
* Introduce let / var and some further cleanup

* Address first comments

* Update changelog

* Move the const before auto
2018-07-10 09:37:53 -07:00
Adlai Holler dbe469a94a Standardize "extern" decls on AS_EXTERN (#972)
* Standardize "extern" decls on AS_EXTERN

* Rebase & remove from implementation files
2018-06-18 15:53:34 -07:00
Adlai Holler cac14e0bce Standardize Property Declaration Style in Core Classes (#870)
* Audit property attributes for core classes

* Update style guide

* Go crazy

* Update changelog
2018-05-24 14:42:43 -07:00
Adlai Holler 0f9b1e6789 Make objects conform to NSLocking (#851)
* Make display node, layout spec, and style conform to NSLocking so that users/subclasses can access their locks

* Update the changelog

* Align slashes

* Put it back, when we're in ASDisplayNode

* Go a little further

* Put back the changes I didn't mean to commit

* Kick the CI

* Fix yoga build

* Put back non-locking change

* Address comments from Scott
2018-03-25 10:46:04 -07:00
Adlai Holler c3ae4474d0 NoCopyRendering experiment: Fix possible memory leak if image node rendering is canceled #trivial (#765)
* Fix memory leak if image node rendering is canceled

* Update comment
2018-01-23 10:45:34 -08:00
Adlai Holler 1d105c2056 Add an experimental "no-copy" renderer (#741)
* Add "ASGraphicsContext" to skip copying our rendered images

* Zero the buffer before making a context

* Update license header

* Update dangerfile

* Make it a runtime flag

* Restore GState for good measure

* Free buffer if end without image

* Enable the experiment, and cut out the middle-man

* Fix typo
2018-01-13 19:19:08 -08:00
Adlai Holler ff608c92bf [Minor Breaking API] Make deallocation queues more reliable (#651)
* Make our async deallocation functions take a double pointer, so we can be sure we've released before the queue drains

* Make it a class property

* Fix the return type

* Use a locker

* Improve release notes
2017-11-02 10:45:34 -07:00
Huy Nguyen 8e0aa1ea73 Fix crashes caused by failing to unlock or destroy a static mutex while the app is being terminated (#577)
* Fix crashes caused by failing to unlock or destroy a static mutex while the app is being terminated

* Allocate static mutexes on the heap memory to avoid destruction at app exit

* ASThread to use ASDisplayNodeCAssert() instead of assert()
2017-09-22 11:53:41 +01:00
Huy Nguyen 9df6909d71 [ASImageNode] Always dealloc images in a background queue (#561)
* ASImageNode to always dealloc its images in a background queue

* Update CHANGELOG
2017-09-11 13:33:30 -07:00
appleguy 65fabf49d7 [ASImageNode] Enable .clipsToBounds by default (fix .cornerRadius, GIFs overflow). (#466)
* [ASImageNode] Enable .clipsToBounds by default (fix .cornerRadius, GIFs overflow).

We've seen a number of bugs reported over time that .cornerRadius didn't work on
ASNetworkImageNode. This wasn't much of a concern because cornerRadius is very
inefficient anyway, and there are better ways to round corners, but it should
certainly work.

It turns out that clipsToBounds has been off for images, and this ultimately
was behind another issue recently seen wehre decoded GIFs would spill outside
the bounds area to overlap nearby content.

Although there is some risk of behavior change from this, I think the risk
is fairly small, and in most cases it will probably fix behaviors in a way
that doesn't cause problems for the app.

We should consider if this property should be on for all ASDisplayNodes,
but for now it would be a great step to be confident it's on for all
ASImageNodes.

* Update changelog for ImageNode Clipping.
2017-08-20 03:17:46 -07:00