summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDileep Marchya <dmarchya@codeaurora.org>2016-06-17 17:36:11 +0530
committerDileep Marchya <dmarchya@codeaurora.org>2016-07-01 10:26:15 +0530
commitc84dc1bea2d361558e5eaf9f87bf581efe3ac442 (patch)
tree07e6bf604a6784f4646780f7eb3c169ce12f1463
parent13f964b7b88c1fdbbea6c405ac3b415425d03085 (diff)
downloaddisplay-c84dc1bea2d361558e5eaf9f87bf581efe3ac442.tar.gz
sdm: Replace dynamic arrays with vectors.
Change-Id: I8047c505bb91058f4386232613b5932412ab48d3 CRs-Fixed: 1029997
-rw-r--r--sdm/libs/core/core_impl.cpp26
-rw-r--r--sdm/libs/core/core_impl.h2
-rw-r--r--sdm/libs/core/display_base.cpp11
-rw-r--r--sdm/libs/core/display_base.h2
-rw-r--r--sdm/libs/core/display_hdmi.cpp4
-rw-r--r--sdm/libs/core/fb/hw_device.cpp7
-rw-r--r--sdm/libs/core/fb/hw_device.h3
-rw-r--r--sdm/libs/core/fb/hw_events.cpp10
-rw-r--r--[-rwxr-xr-x]sdm/libs/core/fb/hw_events.h10
-rw-r--r--sdm/libs/core/fb/hw_hdmi.cpp47
-rw-r--r--sdm/libs/core/fb/hw_hdmi.h9
-rw-r--r--sdm/libs/core/fb/hw_primary.cpp7
-rw-r--r--sdm/libs/core/resource_default.cpp3
-rw-r--r--sdm/libs/core/resource_default.h3
-rw-r--r--sdm/libs/hwc/hwc_display_primary.cpp16
-rw-r--r--sdm/libs/hwc/hwc_display_primary.h2
-rw-r--r--sdm/libs/hwc/hwc_session.cpp20
-rw-r--r--sdm/libs/hwc/hwc_session.h4
-rw-r--r--sdm/libs/hwc2/hwc_session.cpp18
-rw-r--r--sdm/libs/hwc2/hwc_session.h4
20 files changed, 71 insertions, 137 deletions
diff --git a/sdm/libs/core/core_impl.cpp b/sdm/libs/core/core_impl.cpp
index da85c9e2..66eb8466 100644
--- a/sdm/libs/core/core_impl.cpp
+++ b/sdm/libs/core/core_impl.cpp
@@ -71,31 +71,25 @@ DisplayError CoreImpl::Init() {
goto CleanupOnError;
}
- hw_resource_ = new HWResourceInfo();
- if (!hw_resource_) {
- error = kErrorMemory;
- goto CleanupOnError;
- }
-
- error = hw_info_intf_->GetHWResourceInfo(hw_resource_);
+ error = hw_info_intf_->GetHWResourceInfo(&hw_resource_);
if (error != kErrorNone) {
goto CleanupOnError;
}
- error = comp_mgr_.Init(*hw_resource_, extension_intf_, buffer_sync_handler_);
+ error = comp_mgr_.Init(hw_resource_, extension_intf_, buffer_sync_handler_);
if (error != kErrorNone) {
goto CleanupOnError;
}
- if (extension_intf_ && hw_resource_->hw_rot_info.num_rotator) {
- error = extension_intf_->CreateRotator(hw_resource_->hw_rot_info, buffer_allocator_,
+ if (extension_intf_ && hw_resource_.hw_rot_info.num_rotator) {
+ error = extension_intf_->CreateRotator(hw_resource_.hw_rot_info, buffer_allocator_,
buffer_sync_handler_, &rotator_intf_);
if (error != kErrorNone) {
DLOGW("rotation is not supported");
}
}
- error = ColorManagerProxy::Init(*hw_resource_);
+ error = ColorManagerProxy::Init(hw_resource_);
// if failed, doesn't affect display core functionalities.
if (error != kErrorNone) {
DLOGW("Unable creating color manager and continue without it.");
@@ -108,17 +102,13 @@ CleanupOnError:
HWInfoInterface::Destroy(hw_info_intf_);
}
- if (hw_resource_) {
- delete hw_resource_;
- }
-
return error;
}
DisplayError CoreImpl::Deinit() {
SCOPE_LOCK(locker_);
- if (extension_intf_ && hw_resource_->hw_rot_info.num_rotator) {
+ if (extension_intf_ && hw_resource_.hw_rot_info.num_rotator) {
extension_intf_->DestroyRotator(rotator_intf_);
}
@@ -127,10 +117,6 @@ DisplayError CoreImpl::Deinit() {
comp_mgr_.Deinit();
HWInfoInterface::Destroy(hw_info_intf_);
- if (hw_resource_) {
- delete hw_resource_;
- }
-
return kErrorNone;
}
diff --git a/sdm/libs/core/core_impl.h b/sdm/libs/core/core_impl.h
index 2d0e2d2d..c2e98c3f 100644
--- a/sdm/libs/core/core_impl.h
+++ b/sdm/libs/core/core_impl.h
@@ -65,7 +65,7 @@ class CoreImpl : public CoreInterface {
Locker locker_;
BufferAllocator *buffer_allocator_;
BufferSyncHandler *buffer_sync_handler_;
- HWResourceInfo *hw_resource_ = NULL;
+ HWResourceInfo hw_resource_;
CompManager comp_mgr_;
HWInfoInterface *hw_info_intf_ = NULL;
RotatorInterface *rotator_intf_ = NULL;
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index e143639b..469767d9 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -122,10 +122,6 @@ DisplayError DisplayBase::Deinit() {
rotator_intf_->UnregisterDisplay(display_rotator_ctx_);
}
- if (color_modes_) {
- delete[] color_modes_;
- }
-
if (color_mgr_) {
delete color_mgr_;
color_mgr_ = NULL;
@@ -742,14 +738,15 @@ DisplayError DisplayBase::GetColorModes(uint32_t *mode_count,
return kErrorNotSupported;
}
- if (color_modes_ == NULL) {
- color_modes_ = new SDEDisplayMode[num_color_modes_];
+ if (!color_modes_.size()) {
+ color_modes_.resize(num_color_modes_);
- DisplayError error = color_mgr_->ColorMgrGetModes(&num_color_modes_, color_modes_);
+ DisplayError error = color_mgr_->ColorMgrGetModes(&num_color_modes_, color_modes_.data());
if (error != kErrorNone) {
DLOGE("Failed");
return error;
}
+
for (uint32_t i = 0; i < num_color_modes_; i++) {
DLOGV_IF(kTagQDCM, "Color Mode[%d]: Name = %s mode_id = %d", i, color_modes_[i].name,
color_modes_[i].id);
diff --git a/sdm/libs/core/display_base.h b/sdm/libs/core/display_base.h
index b802ea66..ed944caa 100644
--- a/sdm/libs/core/display_base.h
+++ b/sdm/libs/core/display_base.h
@@ -146,7 +146,7 @@ class DisplayBase : public DisplayInterface {
HWEventsInterface *hw_events_intf_ = NULL;
bool disable_pu_one_frame_ = false;
uint32_t num_color_modes_ = 0;
- SDEDisplayMode *color_modes_ = NULL;
+ std::vector<SDEDisplayMode> color_modes_;
typedef std::map<std::string, SDEDisplayMode *> ColorModeMap;
ColorModeMap color_mode_map_ = {};
HWDisplayAttributes display_attributes_ = {};
diff --git a/sdm/libs/core/display_hdmi.cpp b/sdm/libs/core/display_hdmi.cpp
index a53995b5..8522d9b7 100644
--- a/sdm/libs/core/display_hdmi.cpp
+++ b/sdm/libs/core/display_hdmi.cpp
@@ -26,6 +26,7 @@
#include <utils/debug.h>
#include <map>
#include <utility>
+#include <vector>
#include "display_hdmi.h"
#include "hw_interface.h"
@@ -230,7 +231,7 @@ uint32_t DisplayHDMI::GetBestConfig(HWS3DMode s3d_mode) {
hw_intf_->GetNumDisplayAttributes(&num_modes);
// Get display attribute for each mode
- HWDisplayAttributes *attrib = new HWDisplayAttributes[num_modes];
+ std::vector<HWDisplayAttributes> attrib(num_modes);
for (index = 0; index < num_modes; index++) {
hw_intf_->GetDisplayAttributes(index, &attrib[index]);
}
@@ -265,7 +266,6 @@ uint32_t DisplayHDMI::GetBestConfig(HWS3DMode s3d_mode) {
DLOGW("%s, could not support S3D mode from EDID info. S3D mode is %d",
__FUNCTION__, s3d_mode);
}
- delete[] attrib;
// Used for changing HDMI Resolution - override the best with user set config
uint32_t user_config = UINT32(Debug::GetHDMIResolution());
diff --git a/sdm/libs/core/fb/hw_device.cpp b/sdm/libs/core/fb/hw_device.cpp
index 3092740e..c707847d 100644
--- a/sdm/libs/core/fb/hw_device.cpp
+++ b/sdm/libs/core/fb/hw_device.cpp
@@ -954,7 +954,6 @@ bool HWDevice::EnableHotPlugDetection(int enable) {
}
void HWDevice::ResetDisplayParams() {
- uint32_t dst_scalar_cnt = hw_resource_.hw_dest_scalar_info.count;
memset(&mdp_disp_commit_, 0, sizeof(mdp_disp_commit_));
memset(&mdp_in_layers_, 0, sizeof(mdp_in_layers_));
memset(&mdp_out_layer_, 0, sizeof(mdp_out_layer_));
@@ -963,8 +962,8 @@ void HWDevice::ResetDisplayParams() {
memset(&pp_params_, 0, sizeof(pp_params_));
memset(&igc_lut_data_, 0, sizeof(igc_lut_data_));
- if (mdp_dest_scalar_data_) {
- memset(mdp_dest_scalar_data_, 0, sizeof(mdp_dest_scalar_data_) * dst_scalar_cnt);
+ for (size_t i = 0; i < mdp_dest_scalar_data_.size(); i++) {
+ mdp_dest_scalar_data_[i] = {};
}
for (uint32_t i = 0; i < kMaxSDELayers * 2; i++) {
@@ -976,7 +975,7 @@ void HWDevice::ResetDisplayParams() {
mdp_disp_commit_.commit_v1.output_layer = &mdp_out_layer_;
mdp_disp_commit_.commit_v1.release_fence = -1;
mdp_disp_commit_.commit_v1.retire_fence = -1;
- mdp_disp_commit_.commit_v1.dest_scaler = mdp_dest_scalar_data_;
+ mdp_disp_commit_.commit_v1.dest_scaler = mdp_dest_scalar_data_.data();
}
void HWDevice::SetCSC(LayerCSC source, mdp_color_space *color_space) {
diff --git a/sdm/libs/core/fb/hw_device.h b/sdm/libs/core/fb/hw_device.h
index 033e2bcb..40f4f63e 100644
--- a/sdm/libs/core/fb/hw_device.h
+++ b/sdm/libs/core/fb/hw_device.h
@@ -29,6 +29,7 @@
#include <linux/msm_mdp_ext.h>
#include <linux/mdss_rotator.h>
#include <pthread.h>
+#include <vector>
#include "hw_interface.h"
#include "hw_scale.h"
@@ -145,7 +146,7 @@ class HWDevice : public HWInterface {
bool synchronous_commit_;
HWDisplayAttributes display_attributes_ = {};
HWMixerAttributes mixer_attributes_ = {};
- mdp_destination_scaler_data *mdp_dest_scalar_data_ = NULL;
+ std::vector<mdp_destination_scaler_data> mdp_dest_scalar_data_;
};
} // namespace sdm
diff --git a/sdm/libs/core/fb/hw_events.cpp b/sdm/libs/core/fb/hw_events.cpp
index 5a656ccd..5ae53a4d 100644
--- a/sdm/libs/core/fb/hw_events.cpp
+++ b/sdm/libs/core/fb/hw_events.cpp
@@ -141,14 +141,14 @@ void HWEvents::PopulateHWEventData() {
}
DisplayError HWEvents::Init(int fb_num, HWEventHandler *event_handler,
- std::vector<const char *> *event_list) {
+ vector<const char *> *event_list) {
if (!event_handler)
return kErrorParameters;
event_handler_ = event_handler;
fb_num_ = fb_num;
event_list_ = event_list;
- poll_fds_ = new pollfd[event_list_->size()];
+ poll_fds_.resize(event_list_->size());
event_thread_name_ += " - " + std::to_string(fb_num_);
PopulateHWEventData();
@@ -178,10 +178,6 @@ DisplayError HWEvents::Deinit() {
poll_fds_[i].fd = -1;
}
- delete [] poll_fds_;
-
- poll_fds_ = 0;
-
return kErrorNone;
}
@@ -200,7 +196,7 @@ void* HWEvents::DisplayEventHandler() {
setpriority(PRIO_PROCESS, 0, kThreadPriorityUrgent);
while (!exit_threads_) {
- int error = Sys::poll_(poll_fds_, UINT32(event_list_->size()), -1);
+ int error = Sys::poll_(poll_fds_.data(), UINT32(event_list_->size()), -1);
if (error <= 0) {
DLOGW("poll failed. error = %s", strerror(errno));
diff --git a/sdm/libs/core/fb/hw_events.h b/sdm/libs/core/fb/hw_events.h
index 5d7d23d7..bcc5ef69 100755..100644
--- a/sdm/libs/core/fb/hw_events.h
+++ b/sdm/libs/core/fb/hw_events.h
@@ -36,10 +36,12 @@
namespace sdm {
+using std::vector;
+
class HWEvents : public HWEventsInterface {
public:
DisplayError Init(int fb_num, HWEventHandler *event_handler,
- std::vector<const char *> *event_list);
+ vector<const char *> *event_list);
DisplayError Deinit();
private:
@@ -65,9 +67,9 @@ class HWEvents : public HWEventsInterface {
pollfd InitializePollFd(HWEventData *event_data);
HWEventHandler *event_handler_ = NULL;
- std::vector<const char *> *event_list_ = NULL;
- std::vector<HWEventData> event_data_list_ = {};
- pollfd *poll_fds_ = NULL;
+ vector<const char *> *event_list_ = NULL;
+ vector<HWEventData> event_data_list_ = {};
+ vector<pollfd> poll_fds_;
pthread_t event_thread_;
std::string event_thread_name_ = "SDM_EventThread";
bool exit_threads_ = false;
diff --git a/sdm/libs/core/fb/hw_hdmi.cpp b/sdm/libs/core/fb/hw_hdmi.cpp
index 6140d0fb..d9116e6f 100644
--- a/sdm/libs/core/fb/hw_hdmi.cpp
+++ b/sdm/libs/core/fb/hw_hdmi.cpp
@@ -120,10 +120,7 @@ DisplayError HWHDMI::Init() {
return error;
}
- uint32_t dest_scalar_count = hw_resource_.hw_dest_scalar_info.count;
- if (dest_scalar_count) {
- mdp_dest_scalar_data_ = new mdp_destination_scaler_data[dest_scalar_count];
- }
+ mdp_dest_scalar_data_.resize(hw_resource_.hw_dest_scalar_info.count);
error = ReadEDIDInfo();
if (error != kErrorNone) {
@@ -136,13 +133,6 @@ DisplayError HWHDMI::Init() {
return kErrorHardware;
}
- // Mode look-up table for HDMI
- supported_video_modes_ = new msm_hdmi_mode_timing_info[hdmi_mode_count_];
- if (!supported_video_modes_) {
- Deinit();
- return kErrorMemory;
- }
-
error = ReadTimingInfo();
if (error != kErrorNone) {
Deinit();
@@ -166,18 +156,11 @@ DisplayError HWHDMI::Init() {
}
DisplayError HWHDMI::Deinit() {
- hdmi_mode_count_ = 0;
- if (supported_video_modes_) {
- delete[] supported_video_modes_;
- }
-
- delete [] mdp_dest_scalar_data_;
-
return HWDevice::Deinit();
}
DisplayError HWHDMI::GetNumDisplayAttributes(uint32_t *count) {
- *count = hdmi_mode_count_;
+ *count = UINT32(hdmi_modes_.size());
if (*count <= 0) {
return kErrorHardware;
}
@@ -219,8 +202,14 @@ DisplayError HWHDMI::ReadEDIDInfo() {
char *ptr = edid_str;
const uint32_t edid_count_max = 128;
char *tokens[edid_count_max] = { NULL };
- ParseLine(ptr, tokens, edid_count_max, &hdmi_mode_count_);
- for (uint32_t i = 0; i < hdmi_mode_count_; i++) {
+ uint32_t hdmi_mode_count = 0;
+
+ ParseLine(ptr, tokens, edid_count_max, &hdmi_mode_count);
+
+ supported_video_modes_.resize(hdmi_mode_count);
+
+ hdmi_modes_.resize(hdmi_mode_count);
+ for (uint32_t i = 0; i < hdmi_mode_count; i++) {
hdmi_modes_[i] = UINT32(atoi(tokens[i]));
}
}
@@ -232,13 +221,13 @@ DisplayError HWHDMI::GetDisplayAttributes(uint32_t index,
HWDisplayAttributes *display_attributes) {
DTRACE_SCOPED();
- if (index > hdmi_mode_count_) {
+ if (index >= hdmi_modes_.size()) {
return kErrorNotSupported;
}
// Get the resolution info from the look up table
msm_hdmi_mode_timing_info *timing_mode = &supported_video_modes_[0];
- for (uint32_t i = 0; i < hdmi_mode_count_; i++) {
+ for (uint32_t i = 0; i < hdmi_modes_.size(); i++) {
msm_hdmi_mode_timing_info *cur = &supported_video_modes_[i];
if (cur->video_format == hdmi_modes_[index]) {
timing_mode = cur;
@@ -274,7 +263,7 @@ DisplayError HWHDMI::GetDisplayAttributes(uint32_t index,
DisplayError HWHDMI::SetDisplayAttributes(uint32_t index) {
DTRACE_SCOPED();
- if (index > hdmi_mode_count_) {
+ if (index > hdmi_modes_.size()) {
return kErrorNotSupported;
}
@@ -291,7 +280,7 @@ DisplayError HWHDMI::SetDisplayAttributes(uint32_t index) {
vscreeninfo.upper_margin, vscreeninfo.pixclock/1000000);
msm_hdmi_mode_timing_info *timing_mode = &supported_video_modes_[0];
- for (uint32_t i = 0; i < hdmi_mode_count_; i++) {
+ for (uint32_t i = 0; i < hdmi_modes_.size(); i++) {
msm_hdmi_mode_timing_info *cur = &supported_video_modes_[i];
if (cur->video_format == hdmi_modes_[index]) {
timing_mode = cur;
@@ -345,7 +334,7 @@ DisplayError HWHDMI::SetDisplayAttributes(uint32_t index) {
DisplayError HWHDMI::GetConfigIndex(uint32_t mode, uint32_t *index) {
// Check if the mode is valid and return corresponding index
- for (uint32_t i = 0; i < hdmi_mode_count_; i++) {
+ for (uint32_t i = 0; i < hdmi_modes_.size(); i++) {
if (hdmi_modes_[i] == mode) {
*index = i;
DLOGI("Index = %d for config = %d", *index, mode);
@@ -371,7 +360,7 @@ DisplayError HWHDMI::GetHWScanInfo(HWScanInfo *scan_info) {
}
DisplayError HWHDMI::GetVideoFormat(uint32_t config_index, uint32_t *video_format) {
- if (config_index > hdmi_mode_count_) {
+ if (config_index > hdmi_modes_.size()) {
return kErrorNotSupported;
}
@@ -531,7 +520,7 @@ DisplayError HWHDMI::ReadTimingInfo() {
break;
}
- while (info->video_format && size < kPageSize && config_index < hdmi_mode_count_) {
+ while (info->video_format && size < kPageSize && config_index < hdmi_modes_.size()) {
supported_video_modes_[config_index] = *info;
size += sizeof(msm_hdmi_mode_timing_info);
@@ -601,7 +590,7 @@ DisplayError HWHDMI::GetDisplayS3DSupport(uint32_t index,
char edid_s3d_path[kMaxStringLength] = {'\0'};
snprintf(edid_s3d_path, sizeof(edid_s3d_path), "%s%d/edid_3d_modes", fb_path_, fb_node_index_);
- if (index > hdmi_mode_count_) {
+ if (index > hdmi_modes_.size()) {
return kErrorNotSupported;
}
diff --git a/sdm/libs/core/fb/hw_hdmi.h b/sdm/libs/core/fb/hw_hdmi.h
index 2845708a..d2bd6580 100644
--- a/sdm/libs/core/fb/hw_hdmi.h
+++ b/sdm/libs/core/fb/hw_hdmi.h
@@ -33,6 +33,8 @@
namespace sdm {
+using std::vector;
+
class HWHDMI : public HWDevice {
public:
static DisplayError Create(HWInterface **intf, HWInfoInterface *hw_info_intf,
@@ -85,14 +87,13 @@ class HWHDMI : public HWDevice {
bool IsSupportedS3DMode(HWS3DMode s3d_mode);
void UpdateMixerAttributes();
- uint32_t hdmi_mode_count_;
- uint32_t hdmi_modes_[256];
+ vector<uint32_t> hdmi_modes_;
// Holds the hdmi timing information. Ex: resolution, fps etc.,
- msm_hdmi_mode_timing_info *supported_video_modes_;
+ vector<msm_hdmi_mode_timing_info> supported_video_modes_;
HWScanInfo hw_scan_info_;
uint32_t active_config_index_;
std::map<HWS3DMode, msm_hdmi_s3d_mode> s3d_mode_sdm_to_mdp_;
- std::vector<HWS3DMode> supported_s3d_modes_;
+ vector<HWS3DMode> supported_s3d_modes_;
int active_mdp_s3d_mode_ = HDMI_S3D_NONE;
uint32_t frame_rate_ = 0;
};
diff --git a/sdm/libs/core/fb/hw_primary.cpp b/sdm/libs/core/fb/hw_primary.cpp
index d17f6705..09e7f804 100644
--- a/sdm/libs/core/fb/hw_primary.cpp
+++ b/sdm/libs/core/fb/hw_primary.cpp
@@ -102,10 +102,7 @@ DisplayError HWPrimary::Init() {
return error;
}
- uint32_t dest_scalar_count = hw_resource_.hw_dest_scalar_info.count;
- if (dest_scalar_count) {
- mdp_dest_scalar_data_ = new mdp_destination_scaler_data[dest_scalar_count];
- }
+ mdp_dest_scalar_data_.resize(hw_resource_.hw_dest_scalar_info.count);
error = PopulateDisplayAttributes();
if (error != kErrorNone) {
@@ -192,8 +189,6 @@ void HWPrimary::InitializeConfigs() {
}
DisplayError HWPrimary::Deinit() {
- delete [] mdp_dest_scalar_data_;
-
return HWDevice::Deinit();
}
diff --git a/sdm/libs/core/resource_default.cpp b/sdm/libs/core/resource_default.cpp
index c5907bee..4fc3ce44 100644
--- a/sdm/libs/core/resource_default.cpp
+++ b/sdm/libs/core/resource_default.cpp
@@ -47,7 +47,7 @@ DisplayError ResourceDefault::Init(const HWResourceInfo &hw_res_info) {
return kErrorParameters;
}
- src_pipes_ = new SourcePipe[num_pipe_];
+ src_pipes_.resize(num_pipe_);
hw_res_info_ = hw_res_info;
// Priority order of pipes: VIG, RGB, DMA
@@ -100,7 +100,6 @@ DisplayError ResourceDefault::Init(const HWResourceInfo &hw_res_info) {
}
DisplayError ResourceDefault::Deinit() {
- delete[] src_pipes_;
return kErrorNone;
}
diff --git a/sdm/libs/core/resource_default.h b/sdm/libs/core/resource_default.h
index b57ce947..79e7dcdb 100644
--- a/sdm/libs/core/resource_default.h
+++ b/sdm/libs/core/resource_default.h
@@ -28,6 +28,7 @@
#include <core/display_interface.h>
#include <private/resource_interface.h>
#include <utils/locker.h>
+#include <vector>
#include "hw_interface.h"
@@ -132,7 +133,7 @@ class ResourceDefault : public ResourceInterface {
Locker locker_;
HWResourceInfo hw_res_info_;
HWBlockContext hw_block_ctx_[kHWBlockMax];
- SourcePipe *src_pipes_ = NULL;
+ std::vector<SourcePipe> src_pipes_;
uint32_t num_pipe_ = 0;
};
diff --git a/sdm/libs/hwc/hwc_display_primary.cpp b/sdm/libs/hwc/hwc_display_primary.cpp
index f92ab437..f4775b15 100644
--- a/sdm/libs/hwc/hwc_display_primary.cpp
+++ b/sdm/libs/hwc/hwc_display_primary.cpp
@@ -86,15 +86,11 @@ HWCDisplayPrimary::HWCDisplayPrimary(CoreInterface *core_intf,
hwc_procs_t const **hwc_procs,
qService::QService *qservice)
: HWCDisplay(core_intf, hwc_procs, kPrimary, HWC_DISPLAY_PRIMARY, true, qservice,
- DISPLAY_CLASS_PRIMARY), buffer_allocator_(buffer_allocator), cpu_hint_(NULL) {
+ DISPLAY_CLASS_PRIMARY), buffer_allocator_(buffer_allocator) {
}
int HWCDisplayPrimary::Init() {
- cpu_hint_ = new CPUHint();
- if (cpu_hint_->Init(static_cast<HWCDebugHandler*>(HWCDebugHandler::Get())) != kErrorNone) {
- delete cpu_hint_;
- cpu_hint_ = NULL;
- }
+ cpu_hint_.Init(static_cast<HWCDebugHandler*>(HWCDebugHandler::Get()));
use_metadata_refresh_rate_ = true;
int disable_metadata_dynfps = 0;
@@ -289,14 +285,10 @@ void HWCDisplayPrimary::SetQDCMSolidFillInfo(bool enable, uint32_t color) {
}
void HWCDisplayPrimary::ToggleCPUHint(bool set) {
- if (!cpu_hint_) {
- return;
- }
-
if (set) {
- cpu_hint_->Set();
+ cpu_hint_.Set();
} else {
- cpu_hint_->Reset();
+ cpu_hint_.Reset();
}
}
diff --git a/sdm/libs/hwc/hwc_display_primary.h b/sdm/libs/hwc/hwc_display_primary.h
index 81e510ff..f25a877b 100644
--- a/sdm/libs/hwc/hwc_display_primary.h
+++ b/sdm/libs/hwc/hwc_display_primary.h
@@ -74,7 +74,7 @@ class HWCDisplayPrimary : public HWCDisplay {
DisplayError GetMixerResolution(uint32_t *width, uint32_t *height);
BufferAllocator *buffer_allocator_ = nullptr;
- CPUHint *cpu_hint_ = nullptr;
+ CPUHint cpu_hint_;
bool handle_idle_timeout_ = false;
// Primary output buffer configuration
diff --git a/sdm/libs/hwc/hwc_session.cpp b/sdm/libs/hwc/hwc_session.cpp
index 8a6787a0..95da1430 100644
--- a/sdm/libs/hwc/hwc_session.cpp
+++ b/sdm/libs/hwc/hwc_session.cpp
@@ -129,20 +129,8 @@ int HWCSession::Init() {
return -EINVAL;
}
- buffer_allocator_ = new HWCBufferAllocator();
- if (buffer_allocator_ == NULL) {
- DLOGE("Display core initialization failed due to no memory");
- return -ENOMEM;
- }
-
- buffer_sync_handler_ = new HWCBufferSyncHandler();
- if (buffer_sync_handler_ == NULL) {
- DLOGE("Display core initialization failed due to no memory");
- return -ENOMEM;
- }
-
- DisplayError error = CoreInterface::CreateCore(HWCDebugHandler::Get(), buffer_allocator_,
- buffer_sync_handler_, &core_intf_);
+ DisplayError error = CoreInterface::CreateCore(HWCDebugHandler::Get(), &buffer_allocator_,
+ &buffer_sync_handler_, &core_intf_);
if (error != kErrorNone) {
DLOGE("Display core initialization failed. Error = %d", error);
return -EINVAL;
@@ -169,12 +157,12 @@ int HWCSession::Init() {
}
} else {
// Create and power on primary display
- status = HWCDisplayPrimary::Create(core_intf_, buffer_allocator_, &hwc_procs_, qservice_,
+ status = HWCDisplayPrimary::Create(core_intf_, &buffer_allocator_, &hwc_procs_, qservice_,
&hwc_display_[HWC_DISPLAY_PRIMARY]);
}
} else {
// Create and power on primary display
- status = HWCDisplayPrimary::Create(core_intf_, buffer_allocator_, &hwc_procs_, qservice_,
+ status = HWCDisplayPrimary::Create(core_intf_, &buffer_allocator_, &hwc_procs_, qservice_,
&hwc_display_[HWC_DISPLAY_PRIMARY]);
}
diff --git a/sdm/libs/hwc/hwc_session.h b/sdm/libs/hwc/hwc_session.h
index 2bdae2b2..2a732b2b 100644
--- a/sdm/libs/hwc/hwc_session.h
+++ b/sdm/libs/hwc/hwc_session.h
@@ -133,8 +133,8 @@ class HWCSession : hwc_composer_device_1_t, public qClient::BnQClient {
pthread_t uevent_thread_;
bool uevent_thread_exit_ = false;
const char *uevent_thread_name_ = "HWC_UeventThread";
- HWCBufferAllocator *buffer_allocator_ = NULL;
- HWCBufferSyncHandler *buffer_sync_handler_ = NULL;
+ HWCBufferAllocator buffer_allocator_;
+ HWCBufferSyncHandler buffer_sync_handler_;
HWCColorManager *color_mgr_ = NULL;
bool reset_panel_ = false;
bool secure_display_active_ = false;
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp
index 91e57c57..9344ed6c 100644
--- a/sdm/libs/hwc2/hwc_session.cpp
+++ b/sdm/libs/hwc2/hwc_session.cpp
@@ -94,20 +94,8 @@ int HWCSession::Init() {
return -EINVAL;
}
- buffer_allocator_ = new HWCBufferAllocator();
- if (buffer_allocator_ == NULL) {
- DLOGE("Display core initialization failed due to no memory");
- return -ENOMEM;
- }
-
- buffer_sync_handler_ = new HWCBufferSyncHandler();
- if (buffer_sync_handler_ == NULL) {
- DLOGE("Display core initialization failed due to no memory");
- return -ENOMEM;
- }
-
- DisplayError error = CoreInterface::CreateCore(HWCDebugHandler::Get(), buffer_allocator_,
- buffer_sync_handler_, &core_intf_);
+ DisplayError error = CoreInterface::CreateCore(HWCDebugHandler::Get(), &buffer_allocator_,
+ &buffer_sync_handler_, &core_intf_);
if (error != kErrorNone) {
DLOGE("Display core initialization failed. Error = %d", error);
return -EINVAL;
@@ -125,7 +113,7 @@ int HWCSession::Init() {
&hwc_display_[HWC_DISPLAY_PRIMARY]);
} else {
// Create and power on primary display
- status = HWCDisplayPrimary::Create(core_intf_, buffer_allocator_, &callbacks_, qservice_,
+ status = HWCDisplayPrimary::Create(core_intf_, &buffer_allocator_, &callbacks_, qservice_,
&hwc_display_[HWC_DISPLAY_PRIMARY]);
}
diff --git a/sdm/libs/hwc2/hwc_session.h b/sdm/libs/hwc2/hwc_session.h
index 6af9da58..ce3e27fa 100644
--- a/sdm/libs/hwc2/hwc_session.h
+++ b/sdm/libs/hwc2/hwc_session.h
@@ -175,8 +175,8 @@ class HWCSession : hwc2_device_t, public qClient::BnQClient {
pthread_t uevent_thread_;
bool uevent_thread_exit_ = false;
const char *uevent_thread_name_ = "HWC_UeventThread";
- HWCBufferAllocator *buffer_allocator_ = NULL;
- HWCBufferSyncHandler *buffer_sync_handler_ = NULL;
+ HWCBufferAllocator buffer_allocator_;
+ HWCBufferSyncHandler buffer_sync_handler_;
HWCColorManager *color_mgr_ = NULL;
bool reset_panel_ = false;
bool secure_display_active_ = false;