No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
This information was gathered by inspecting the -[CABackdropLayer statisticsValues] method. More info is in the screenshot. [[File:Statistics_type1_check.png|200px|thumb|right|Screenshot from IDA of the -statisticsValues method]] | This information was gathered by inspecting the -[CABackdropLayer statisticsValues] method. More info is in the screenshot. [[File:Statistics_type1_check.png|200px|thumb|right|Screenshot from IDA of the -statisticsValues method]] | ||
== | == Type1 statistics == | ||
type1 statistics gathers: | type1 statistics gathers: | ||
* time | * time | ||
* color average ( | * color average (RGB values). | ||
* luminance standard deviation | * luminance standard deviation | ||
Line 17: | Line 17: | ||
MyWindow *w = [[MyWindow alloc] initWithFrame:f]; | MyWindow *w = [[MyWindow alloc] initWithFrame:f]; | ||
w.hidden = NO; | w.hidden = NO; | ||
// 2) Set the type | // 2) Set the type | ||
w.layer.statisticsType = | w.layer.statisticsType = kCABackdropStatisticsType1; | ||
// optional: set the interval, by default it is 0.25 | |||
// optional: set the interval (in seconds), by default it is 0.25. | |||
w.layer.statisticsInterval = 5; | w.layer.statisticsInterval = 5; | ||
// finally just call -statisticsValues. An NSDictionary is returned. | // finally just call -statisticsValues. An NSDictionary is returned. | ||
[w.layer statisticsValues] | [w.layer statisticsValues] | ||
@{"type":"type1","time":46141.687733625,"blueAverage":0.1781699346405229,"greenAverage":0.1045315904139434,"luminanceStandardDeviation":0.1162156672244852,"redAverage":0.06554829339143065} | @{"type":"type1","time":46141.687733625,"blueAverage":0.1781699346405229,"greenAverage":0.1045315904139434,"luminanceStandardDeviation":0.1162156672244852,"redAverage":0.06554829339143065} | ||
</source> | |||
== Exported Keys and Types == | |||
Add this to your `class-dump`-ed CABackdropLayer.h header file (should be used instead of plain strings). | |||
<source lang="objc"> | |||
/* Statistics Types */ | |||
extern NSString *kCABackdropStatisticsType1; | |||
extern NSString *kCABackdropStatisticsNone; | |||
/* Statisctics Type1 keys */ | |||
extern NSString *kCABackdropStatisticsRedAverage; | |||
extern NSString *kCABackdropStatisticsGreenAverage; | |||
extern NSString *kCABackdropStatisticsBlueAverage; | |||
extern NSString *kCABackdropStatisticsLuminanceStandardDeviation; | |||
extern NSString *kCABackdropStatisticsType; | |||
extern NSString *kCABackdropStatisticsTime; | |||
</source> | </source> | ||
{{occlass|library=QuartzCore.framework|navbox=1}} | {{occlass|library=QuartzCore.framework|navbox=1}} |
Latest revision as of 16:19, 27 June 2015
CABackdropLayer is a subclass of CALayer that clones the content behind it as its own contents. It's useful for applying effects that only apply to some part of the screen, which might be made up of any number of layers behind it.
Gathering Statistics With CABackdropLayer
CABackdropLayer supports gathering various statistics about the contents it clones. Several "statistics types" might be supported, although, currently, it seems (from reversing this feature), that only one type is supported: "type1".
This information was gathered by inspecting the -[CABackdropLayer statisticsValues] method. More info is in the screenshot.
Type1 statistics
type1 statistics gathers:
- time
- color average (RGB values).
- luminance standard deviation
How to enable example (this is pseudo code at best):
// 1) create a window from a subclass that has its layerClass defined as CABackdropLayer.
MyWindow *w = [[MyWindow alloc] initWithFrame:f];
w.hidden = NO;
// 2) Set the type
w.layer.statisticsType = kCABackdropStatisticsType1;
// optional: set the interval (in seconds), by default it is 0.25.
w.layer.statisticsInterval = 5;
// finally just call -statisticsValues. An NSDictionary is returned.
[w.layer statisticsValues]
@{"type":"type1","time":46141.687733625,"blueAverage":0.1781699346405229,"greenAverage":0.1045315904139434,"luminanceStandardDeviation":0.1162156672244852,"redAverage":0.06554829339143065}
Exported Keys and Types
Add this to your `class-dump`-ed CABackdropLayer.h header file (should be used instead of plain strings).
/* Statistics Types */
extern NSString *kCABackdropStatisticsType1;
extern NSString *kCABackdropStatisticsNone;
/* Statisctics Type1 keys */
extern NSString *kCABackdropStatisticsRedAverage;
extern NSString *kCABackdropStatisticsGreenAverage;
extern NSString *kCABackdropStatisticsBlueAverage;
extern NSString *kCABackdropStatisticsLuminanceStandardDeviation;
extern NSString *kCABackdropStatisticsType;
extern NSString *kCABackdropStatisticsTime;
|