Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
CABackdropLayer: Difference between revisions - iPhone Development Wiki

CABackdropLayer: Difference between revisions

From iPhone Development Wiki
(created it)
 
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[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.
[[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. [[File:Statistics_type1_check.png|200px|thumb|right|Screenshot from IDA of the -statisticsValues method]]
== Type1 statistics ==
type1 statistics gathers:
* time
* color average (RGB values).
* luminance standard deviation
How to enable example (this is pseudo code '''at best'''):
<source lang="objc">
// 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}
</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>
{{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.

Error creating thumbnail: File missing
Screenshot from IDA of the -statisticsValues method

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;