408 Commits

Author SHA1 Message Date
Zhigang Fang
e79fe83ce2 Moving examples deeper so that carthage can build the correct project 2016-10-07 15:52:12 +08:00
billkunz
aefee50a61 PINAnimatedImageManager cleanup in +initialize rather than +load (#249)
Performing cleanup (specifically, calling -cleanupFiles) in +load can delay on-device app launch time noticeably. Let’s try moving this work to +initialize instead.
2016-09-23 16:00:18 -07:00
Jon Parise
de6c8e0ad6 Include a full copy of the Apache-2.0 license (#248)
The previous text is what would go into per-file headers.
2016-09-21 14:48:42 -07:00
Anton Bukov
38d4e01419 [Feature] [Rebased] Add support for in-url base64 encoded images (#246)
* Add support for in-url base64 encoded images

* Added GIF support

* Solution simplified a lot after reading PR comments

* Fix some problems

* Add test and fix compilation error

* Commented memory caching of data urls for now

* Fix issues appeared after rebase

* Fixed bug under OSX

* Used memory cache for data scheme and simplified solution a lot
2016-09-21 14:44:45 -04:00
appleguy
c0f96d4322 Merge pull request #242 from pinterest/AHBlendMode
Use kCGBlendModeCopy when Decoding Images
2016-09-08 21:37:08 -07:00
Adlai Holler
e68a03fe4d Use kCGBlendModeCopy when decoding images 2016-09-05 23:58:16 -07:00
Adlai Holler
1b68fbb3a4 Ensure Opaque Images Have No Alpha Channel (#241)
* Add tests around image alpha components

* Check the value right
2016-09-05 23:11:26 -07:00
Garrett Moon
0d5437cab6 Don't bother archiving / unarchiving data. (#229)
* Don't bother archiving / unarchiving data.

This change upgrades to PINCache 3.0.1-beta which supports
custom archiving and unarchiving.

This allows us to avoid using NSArchiver/Archiver which adds a
small amount of disk space overhead and between .5 and 10 ms (on an iPhone 4)
for each encode / decode.

To support this, we *do* have to add versioning for the cache and
destroy it for the old versions. I considered adding a process to migrate
the images, but because that would have to occur on startup and process
all existing images, it could cause issues for very large image cache
databases, so I decided against that.

* Fix warnings

* Fix invalid object test

* Cleanup, thanks @chrisdanford!
2016-08-20 12:39:34 -07:00
Francisco Sevillano
baf9202da9 Fixed completion handler crash (#233)
* Fixed completion handler crash

* Added comments
2016-08-20 10:54:51 -07:00
Leonardo Ferreira
d5c5c36044 Update README.md, installation by CocoaPods (#232)
* Update README.md, installation by CocoaPods

- Just add second line with WebP subspec to installation by CocoaPods, to clarify "how to install" for users that would like to use WebP images.

* Update README.md, installation by CocoaPods 

- Just add second line with WebP subspec to installation by CocoaPods, to clarify "how to install" for users that would like to use WebP images.
2016-08-12 11:28:31 -07:00
Alex Shevchenko
3a6bc57ae7 Pluggable cache (#225)
* Cache is pluggable now.
PINCache dependency is optional.

* Cleanup

* Fixing wrong commit

* Cleanup

* Renamed PINRemoteImageCaching methods
2016-08-05 15:59:16 -07:00
Garrett Moon
83fe96270b Fixes webp integration for CocoaPods > 1.0. Thanks to SDWebImage for the solution and @yxztj to pointing it out! (#226) 2016-08-05 13:13:42 -07:00
Garrett Moon
03d7d40ab4 Beta 3 3.0.0-beta.3 2016-08-02 16:58:07 -07:00
Garrett Moon
68a0be12a8 Fix Carthage for PINCache beta 2016-08-02 16:57:02 -07:00
Garrett Moon
f76a8c1231 Upgrade PINCache (#223)
* Upgrade PINCache

* Upgrade spec too

* Update the repos

* Updating example
2016-07-22 16:58:16 -07:00
Garrett Moon
ded2e07dd3 Add support for retrying and reduce default timeout. (#215)
* Add support for retrying and reduce default timeout.

* Return HTTP error codes >= 400. Don't retry when failure is sure to occur again.

* Add missing nullability

* Use NSInteger
2016-07-15 16:18:58 -07:00
Garrett Moon
c9f3544c4e Drop support for macOS 10.8 and iOS 6.0. It actually already happened… (#221)
* Drop support for macOS 10.8 and iOS 6.0. It actually already happened with the adoption of NSURLSession.

* Missed one.
2016-07-15 15:41:11 -07:00
Garrett Moon
3dbbfc7591 Without this, the system is likely caching our NSURLResponses which means double caching :( (#219) 2016-07-15 15:02:09 -07:00
Garrett Moon
855d457bcf Support varying pixel lengths (#213)
* Add support for varying pixel lengths.

On some devices the pixel length returned from CGImageCreate
sadly isn't 4 bytes per pixel.
Might be a good idea to support differing lengths.
Encoding this into the format would be a good
thing for sure.
Anyway, that's what this does.

* Add in methods for reading out bitsPerPixel too.
2016-07-15 14:51:58 -07:00
Garrett Moon
2cfc232d11 Adds better support for cancelation (#218)
In order to avoid blocking on the main thread, PINRemoteImage creates
a UUID but does not immediately start a task instead putting it on an
operation queue. This means that a client can request cancelation for
a UUID before its task is created.

Previously, we attempted to handle this by maintaining a set of canceled
UUIDs. This was being done incorrectly however. The logic was to check if,
before creating a task, a UUID was in canceledTasks. If it was, don't
create the task. If it wasn't clear out the canceledTasks list. This
example illustrates why that was erroneous:
1. Request starting a task with UUID #1
2. Request starting a task with UUID #2
3. Request canceling UUID #2
4. Task creation starts for UUID #1
5. UUID one is not in canceledTasks so it is cleared
6. Task creation starts for UUID #2, it is not in canceledTasks
   so the task is created and is not canceled.

This patch changes canceledTasks to a weak hash table and removes
the line which cleared out canceledTasks. As long as there are blocks
(for task creation) referencing the UUID, they will not be removed
from canceledTasks. When no one is referencing the UUIDs any longer,
they will be cleared out.
2016-07-15 14:51:48 -07:00
Garrett Moon
b60c7ca8b8 See what version we're running (#220)
* See what version we're running

* Force 0.39.0
2016-07-15 14:40:40 -07:00
Garrett Moon
55893eee2f ivar no longer used because status is stored on shared version. (#206) 2016-06-07 16:20:00 -07:00
Garrett Moon
097e01cf15 Fix runaway NSData (#205)
* Fix runaway NSData

Previously we were generating all the frames of the GIF and dispatching
to write the data to the disk. This presents a problem if the disk backs
up though and it can end up with theoretically every frame in memory. Instead,
generate a frame and write it one frame at a time. Slower, but prevents
this runaway memory situation.

* Early return on error, thans @rahul-malik & @timonus!
2016-06-07 15:40:43 -07:00
Garrett Moon
3f0659a6dc Fix crash that can occur if image creation failed. (#204)
CFAutorelease crashes if you pass in NULL.
2016-06-03 11:16:09 -07:00
Garrett Moon
e95f161ac2 Beta 2 3.0.0-beta.2 2016-05-03 12:40:43 -07:00
Garrett Moon
182bfe2630 Merge the tvOS spec into the iOS spec to ease integration in downstream projects. (#196) 2016-05-02 16:49:02 -07:00
Garrett Moon
a7ce67a325 3.0.0-beta 2016-04-25 13:11:11 -07:00
Garrett Moon
6ea791b40a Forward port changelog 3.0.0-beta 2016-04-25 11:23:38 -07:00
Diego Torres
6c5b928935 Generate the cacheKey only when necessary (#191) 2016-04-22 11:34:25 -07:00
Garrett Moon
b4a6bcbbc9 Disable 8.4 travis build as its hanging. Will look into re-enabling in the future. 2016-04-19 16:53:24 -07:00
Garrett Moon
13ae9f9a8a Handle errors when writing files. (#190)
* Handle errors when writing files.

* Address comments, fix warning.

* Add comment to explain writing durations to file.
2016-04-19 15:48:28 -07:00
Diego Torres
1d04bf82b2 Use a hashed key when the URL is too long (#189)
* Use a hashed key when the URL is too long

* Added tests for new cacheKey behaviour

* Conform to project style
2016-04-19 15:48:08 -07:00
Garrett Moon
05b24714f4 Materialize object isn't meant to be called on nil objects. (#187) 2016-04-13 10:21:53 -07:00
Garrett Moon
bf1012741c Add error for empty images. (#188) 2016-04-13 10:09:38 -07:00
Wendy Lu
0e81f77d16 Have PINProgressiveImage pass back the quality of the current progressive image (#185)
* Have PINProgressiveImage pass back the quality of the current progressive image
* fix
* Check for nil for imageProgress pointer
* Rename some variables
* Rename a bunch of things
* Update comment
2016-04-13 07:42:37 -07:00
Adlai Holler
632e1bcd2a Modify estimatedRemainingTimeThreshhold Behavior to Match Documentation (#184)
* Modify estimatedRemainingTimeThreshhold behavior to match documentation
* Update documentation on maxProgressiveRenderSize property
* Update the behavior, not the docs
2016-04-11 15:36:50 -07:00
Garrett Moon
e6cf241648 Fix warning, passing in NULL instead of 0 2016-04-11 15:26:25 -07:00
Garrett Moon
a0c421e50f Fix build, need to return results :) 2016-04-11 15:25:11 -07:00
Garrett Moon
8d8922edd1 Merge pull request #183 from Adlai-Holler/PrefetchingReturnsTasks
Make Prefetching Methods Return Tasks
2016-04-11 14:53:26 -07:00
Garrett Moon
c4fb727a74 Merge pull request #182 from Adlai-Holler/IndentationSettings
Set Project Indentation to Spaces
2016-04-11 14:51:56 -07:00
Garrett Moon
e783cf63d1 Merge pull request #180 from pinterest/addPINAnimatedImage
Beta of PINAnimatedImage
2016-04-11 14:41:07 -07:00
Garrett Moon
9dd8ebf8da Better clearing of memory mapped files.
First, prevents a memory leak if users reference self in their PINAnimatedImage completions.

Second, this deletes decoded files when there are no more references to an animated image.
Previously we deleted on app open and exit.

I wasn't going to do this in case you closed a GIF and then reopened, but the more I
thought about it the cost is too high: A user can see their disk size balloon if they view
a bunch of GIFs and then check usage. They could also fill up their space enough while using
the app by viewing GIF after GIF that instability could result.
2016-04-11 13:20:58 -07:00
Adlai Holler
157771425d Another indentation fix 2016-04-09 12:59:58 -07:00
Adlai Holler
6ff9eea9ff Use spaces for indentation 2016-04-09 12:20:23 -07:00
Adlai Holler
df53f5516e Set project indentation to spaces 2016-04-09 12:16:50 -07:00
Adlai Holler
df36ae409b Return tasks from prefetching methods 2016-04-09 12:08:02 -07:00
Garrett Moon
e3d2e07ae7 Addressing Rricky's comments 2016-04-08 16:26:04 -07:00
Garrett Moon
5c5c3f4cba Documentation of PINAnimatedImage 2016-04-08 14:39:08 -07:00
Garrett Moon
f10547d1c5 Fix for file cleanup / prevent crash if memoryMap is nil. 2016-04-08 10:55:06 -07:00
Garrett Moon
9e8132cf68 I can't believe it was a typo 2016-04-06 14:48:51 -07:00