• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.hardware.display;
18 
19 /**
20  * @hide
21  */
22 public final class DisplayedContentSample {
23     private long mNumFrames;
24     private long[] mSamplesComponent0;
25     private long[] mSamplesComponent1;
26     private long[] mSamplesComponent2;
27     private long[] mSamplesComponent3;
28 
29     /**
30      * Construct an object representing a color histogram of pixels that were displayed on screen.
31      *
32      * @param numFrames The number of frames represented by this sample.
33      * @param mSamplesComponent0 is a histogram counting how many times and for how long a pixel
34      * of a given value was displayed onscreen for FORMAT_COMPONENT_0. The buckets of the
35      * histogram are evenly weighted, the number of buckets is device specific.
36      * The units are in pixels * milliseconds, with 1 pixel millisecond being 1 pixel displayed
37      * onscreen for 1ms.
38      * eg, for RGBA_8888, if sampleComponent0 is {100, 50, 30, 20},  then red component was
39      * onscreen for 100 pixel milliseconds in range 0x00->0x3F, 30 pixel milliseconds in
40      * range 0x40->0x7F, etc.
41      * @param mSamplesComponent1 is the same sample definition as sampleComponent0, but for the
42      * second component of format.
43      * @param mSamplesComponent2 is the same sample definition as sampleComponent0, but for the
44      * third component of format.
45      * @param mSamplesComponent3 is the same sample definition as sampleComponent0, but for the
46      * fourth component of format.
47      */
DisplayedContentSample(long numFrames, long[] sampleComponent0, long[] sampleComponent1, long[] sampleComponent2, long[] sampleComponent3)48     public DisplayedContentSample(long numFrames,
49             long[] sampleComponent0,
50             long[] sampleComponent1,
51             long[] sampleComponent2,
52             long[] sampleComponent3) {
53         mNumFrames = numFrames;
54         mSamplesComponent0 = sampleComponent0;
55         mSamplesComponent1 = sampleComponent1;
56         mSamplesComponent2 = sampleComponent2;
57         mSamplesComponent3 = sampleComponent3;
58     }
59 
60     public enum ColorComponent {
61         CHANNEL0,
62         CHANNEL1,
63         CHANNEL2,
64         CHANNEL3,
65     }
66 
67     /**
68      * Returns a color histogram according to component channel.
69      *
70      * @param component the component to return, according to the PixelFormat ordering
71      * (eg, for RGBA, CHANNEL0 is R, CHANNEL1 is G, etc).
72      *
73      * @return an evenly weighted histogram counting how many times a pixel was
74      *         displayed onscreen that fell into the corresponding bucket, with the first entry
75      *         corresponding to the normalized 0.0 value, and the last corresponding to the 1.0
76      *         value for that PixelFormat component.
77      */
getSampleComponent(ColorComponent component)78     public long[] getSampleComponent(ColorComponent component) {
79         switch (component) {
80             case CHANNEL0: return mSamplesComponent0;
81             case CHANNEL1: return mSamplesComponent1;
82             case CHANNEL2: return mSamplesComponent2;
83             case CHANNEL3: return mSamplesComponent3;
84             default: throw new ArrayIndexOutOfBoundsException();
85         }
86     }
87 
88     /**
89      * Return the number of frames this sample was collected over.
90      *
91      * @return  the number of frames that this sample was collected over.
92      */
getNumFrames()93     public long getNumFrames() {
94         return mNumFrames;
95     }
96 }
97