1 /*
2 * Copyright Samsung Electronics Co.,LTD. * Copyright (C) 2016 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 #include <log/log.h>
18
19 #include <hardware/exynos/acryl.h>
20
21 #include "acrylic_internal.h"
22
AcrylicPerformanceRequest()23 AcrylicPerformanceRequest::AcrylicPerformanceRequest()
24 : mNumFrames(0), mNumAllocFrames(0), mFrames(NULL)
25 {
26 }
27
~AcrylicPerformanceRequest()28 AcrylicPerformanceRequest::~AcrylicPerformanceRequest()
29 {
30 delete [] mFrames;
31 }
32
reset(int num_frames)33 bool AcrylicPerformanceRequest::reset(int num_frames)
34 {
35 if (num_frames == 0) {
36 delete [] mFrames;
37 mFrames = NULL;
38 } else if (num_frames > mNumAllocFrames) {
39 delete [] mFrames;
40 mFrames = new AcrylicPerformanceRequestFrame[num_frames];
41 if (mFrames == NULL) {
42 ALOGE("Failed to allocate PerformanceRequestFrame[%d]", num_frames);
43 return false;
44 }
45
46 mNumAllocFrames = num_frames;
47 }
48
49 mNumFrames = num_frames;
50
51 return true;
52 }
53
AcrylicPerformanceRequestFrame()54 AcrylicPerformanceRequestFrame::AcrylicPerformanceRequestFrame()
55 : mNumLayers(0), mNumAllocLayers(0), mFrameRate(60),
56 mHasBackgroundLayer(false), mLayers(NULL)
57 {
58 }
59
60
~AcrylicPerformanceRequestFrame()61 AcrylicPerformanceRequestFrame::~AcrylicPerformanceRequestFrame()
62 {
63 delete [] mLayers;
64 }
65
reset(int num_layers)66 bool AcrylicPerformanceRequestFrame::reset(int num_layers)
67 {
68 if (num_layers == 0) {
69 delete [] mLayers;
70 mLayers = NULL;
71 } else if (num_layers > mNumAllocLayers) {
72 mLayers = new AcrylicPerformanceRequestLayer[num_layers];
73 if (mLayers == NULL) {
74 ALOGE("Failed to allocate PerformanceRequestLayer[%d]", num_layers);
75 return false;
76 }
77
78 mNumAllocLayers = num_layers;
79 }
80
81 mNumLayers = num_layers;
82
83 return true;
84 }
85