sdm: fix null pointer dereference and vector initialization.
Change-Id: I25bb8daa6b49223a443a31d1ae17560ed6fca486 Signed-off-by: Pramodh Kumar Mukunda <pkmuku@codeaurora.org>
This commit is contained in:
committed by
Uday Kiran Pichika
parent
65788dca88
commit
927729d9ea
@@ -509,8 +509,10 @@ bool IsUBwcEnabled(int format, gralloc1_producer_usage_t prod_usage,
|
|||||||
// Query GPU for UBWC only if buffer is intended to be used by GPU.
|
// Query GPU for UBWC only if buffer is intended to be used by GPU.
|
||||||
if ((cons_usage & GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE) ||
|
if ((cons_usage & GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE) ||
|
||||||
(prod_usage & GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET)) {
|
(prod_usage & GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET)) {
|
||||||
|
if (AdrenoMemInfo::GetInstance()) {
|
||||||
enable = AdrenoMemInfo::GetInstance()->IsUBWCSupportedByGPU(format);
|
enable = AdrenoMemInfo::GetInstance()->IsUBWCSupportedByGPU(format);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Allow UBWC, only if CPU usage flags are not set
|
// Allow UBWC, only if CPU usage flags are not set
|
||||||
if (enable && !(CpuCanAccess(prod_usage, cons_usage))) {
|
if (enable && !(CpuCanAccess(prod_usage, cons_usage))) {
|
||||||
@@ -675,8 +677,10 @@ void GetAlignedWidthAndHeight(const BufferInfo &info, unsigned int *alignedw,
|
|||||||
int tile = ubwc_enabled;
|
int tile = ubwc_enabled;
|
||||||
|
|
||||||
if (IsUncompressedRGBFormat(format)) {
|
if (IsUncompressedRGBFormat(format)) {
|
||||||
|
if (AdrenoMemInfo::GetInstance()) {
|
||||||
AdrenoMemInfo::GetInstance()->AlignUnCompressedRGB(width, height, format, tile, alignedw,
|
AdrenoMemInfo::GetInstance()->AlignUnCompressedRGB(width, height, format, tile, alignedw,
|
||||||
alignedh);
|
alignedh);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,7 +690,9 @@ void GetAlignedWidthAndHeight(const BufferInfo &info, unsigned int *alignedw,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsCompressedRGBFormat(format)) {
|
if (IsCompressedRGBFormat(format)) {
|
||||||
|
if (AdrenoMemInfo::GetInstance()) {
|
||||||
AdrenoMemInfo::GetInstance()->AlignCompressedRGB(width, height, format, alignedw, alignedh);
|
AdrenoMemInfo::GetInstance()->AlignCompressedRGB(width, height, format, alignedw, alignedh);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -698,6 +704,9 @@ void GetAlignedWidthAndHeight(const BufferInfo &info, unsigned int *alignedw,
|
|||||||
switch (format) {
|
switch (format) {
|
||||||
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
|
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
|
||||||
case HAL_PIXEL_FORMAT_YCbCr_420_SP:
|
case HAL_PIXEL_FORMAT_YCbCr_420_SP:
|
||||||
|
if (AdrenoMemInfo::GetInstance() == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
alignment = AdrenoMemInfo::GetInstance()->GetGpuPixelAlignment();
|
alignment = AdrenoMemInfo::GetInstance()->GetGpuPixelAlignment();
|
||||||
aligned_w = ALIGN(width, alignment);
|
aligned_w = ALIGN(width, alignment);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ HWCBufferAllocator::HWCBufferAllocator() {
|
|||||||
} else {
|
} else {
|
||||||
gralloc1_open(module_, &gralloc_device_);
|
gralloc1_open(module_, &gralloc_device_);
|
||||||
}
|
}
|
||||||
|
if (gralloc_device_ != nullptr) {
|
||||||
ReleaseBuffer_ = reinterpret_cast<GRALLOC1_PFN_RELEASE>(
|
ReleaseBuffer_ = reinterpret_cast<GRALLOC1_PFN_RELEASE>(
|
||||||
gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_RELEASE));
|
gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_RELEASE));
|
||||||
Perform_ = reinterpret_cast<GRALLOC1_PFN_PERFORM>(
|
Perform_ = reinterpret_cast<GRALLOC1_PFN_PERFORM>(
|
||||||
@@ -55,6 +56,7 @@ HWCBufferAllocator::HWCBufferAllocator() {
|
|||||||
Lock_ = reinterpret_cast<GRALLOC1_PFN_LOCK>(
|
Lock_ = reinterpret_cast<GRALLOC1_PFN_LOCK>(
|
||||||
gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_LOCK));
|
gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_LOCK));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HWCBufferAllocator::~HWCBufferAllocator() {
|
HWCBufferAllocator::~HWCBufferAllocator() {
|
||||||
if (gralloc_device_ != nullptr) {
|
if (gralloc_device_ != nullptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user