File: DisplayedContentSample.java

package info (click to toggle)
android-platform-frameworks-base 1%3A10.0.0%2Br36-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 321,788 kB
  • sloc: java: 962,234; cpp: 274,314; xml: 242,770; python: 5,060; sh: 1,432; ansic: 494; makefile: 47; sed: 19
file content (96 lines) | stat: -rw-r--r-- 3,813 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.display;

/**
 * @hide
 */
public final class DisplayedContentSample {
    private long mNumFrames;
    private long[] mSamplesComponent0;
    private long[] mSamplesComponent1;
    private long[] mSamplesComponent2;
    private long[] mSamplesComponent3;

    /**
     * Construct an object representing a color histogram of pixels that were displayed on screen.
     *
     * @param numFrames The number of frames represented by this sample.
     * @param mSamplesComponent0 is a histogram counting how many times and for how long a pixel
     * of a given value was displayed onscreen for FORMAT_COMPONENT_0. The buckets of the
     * histogram are evenly weighted, the number of buckets is device specific.
     * The units are in pixels * milliseconds, with 1 pixel millisecond being 1 pixel displayed
     * onscreen for 1ms.
     * eg, for RGBA_8888, if sampleComponent0 is {100, 50, 30, 20},  then red component was
     * onscreen for 100 pixel milliseconds in range 0x00->0x3F, 30 pixel milliseconds in
     * range 0x40->0x7F, etc.
     * @param mSamplesComponent1 is the same sample definition as sampleComponent0, but for the
     * second component of format.
     * @param mSamplesComponent2 is the same sample definition as sampleComponent0, but for the
     * third component of format.
     * @param mSamplesComponent3 is the same sample definition as sampleComponent0, but for the
     * fourth component of format.
     */
    public DisplayedContentSample(long numFrames,
            long[] sampleComponent0,
            long[] sampleComponent1,
            long[] sampleComponent2,
            long[] sampleComponent3) {
        mNumFrames = numFrames;
        mSamplesComponent0 = sampleComponent0;
        mSamplesComponent1 = sampleComponent1;
        mSamplesComponent2 = sampleComponent2;
        mSamplesComponent3 = sampleComponent3;
    }

    public enum ColorComponent {
        CHANNEL0,
        CHANNEL1,
        CHANNEL2,
        CHANNEL3,
    }

    /**
     * Returns a color histogram according to component channel.
     *
     * @param component the component to return, according to the PixelFormat ordering
     * (eg, for RGBA, CHANNEL0 is R, CHANNEL1 is G, etc).
     *
     * @return an evenly weighted histogram counting how many times a pixel was
     *         displayed onscreen that fell into the corresponding bucket, with the first entry
     *         corresponding to the normalized 0.0 value, and the last corresponding to the 1.0
     *         value for that PixelFormat component.
     */
    public long[] getSampleComponent(ColorComponent component) {
        switch (component) {
            case CHANNEL0: return mSamplesComponent0;
            case CHANNEL1: return mSamplesComponent1;
            case CHANNEL2: return mSamplesComponent2;
            case CHANNEL3: return mSamplesComponent3;
            default: throw new ArrayIndexOutOfBoundsException();
        }
    }

    /**
     * Return the number of frames this sample was collected over.
     *
     * @return  the number of frames that this sample was collected over.
     */
    public long getNumFrames() {
        return mNumFrames;
    }
}