hwc: Fix klockwork errors
Resolving klockwork errors to avoid memory leaks, improper assignments in liboverlay. Change-Id: I82ac6ae782c7b783e89999b832bbd1d361376b9f
This commit is contained in:
@@ -271,7 +271,12 @@ IAllocController* IAllocController::getInstance(void)
|
|||||||
//-------------- IonController-----------------------//
|
//-------------- IonController-----------------------//
|
||||||
IonController::IonController()
|
IonController::IonController()
|
||||||
{
|
{
|
||||||
mIonAlloc = new IonAlloc();
|
allocateIonMem();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IonController::allocateIonMem()
|
||||||
|
{
|
||||||
|
mIonAlloc = new IonAlloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
int IonController::allocate(alloc_data& data, int usage)
|
int IonController::allocate(alloc_data& data, int usage)
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class IonController : public IAllocController {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
IonAlloc* mIonAlloc;
|
IonAlloc* mIonAlloc;
|
||||||
|
void allocateIonMem();
|
||||||
|
|
||||||
};
|
};
|
||||||
} //end namespace gralloc
|
} //end namespace gralloc
|
||||||
|
|||||||
@@ -105,6 +105,9 @@ int gralloc_device_open(const hw_module_t* module, const char* name,
|
|||||||
gpu_context_t *dev;
|
gpu_context_t *dev;
|
||||||
IAllocController* alloc_ctrl = IAllocController::getInstance();
|
IAllocController* alloc_ctrl = IAllocController::getInstance();
|
||||||
dev = new gpu_context_t(m, alloc_ctrl);
|
dev = new gpu_context_t(m, alloc_ctrl);
|
||||||
|
if(!dev)
|
||||||
|
return status;
|
||||||
|
|
||||||
*device = &dev->common;
|
*device = &dev->common;
|
||||||
status = 0;
|
status = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -811,7 +811,7 @@ struct copybit_device_t* CopyBit::getCopyBitDevice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CopyBit::CopyBit(hwc_context_t *ctx, const int& dpy) : mIsModeOn(false),
|
CopyBit::CopyBit(hwc_context_t *ctx, const int& dpy) : mIsModeOn(false),
|
||||||
mCopyBitDraw(false), mCurRenderBufferIndex(0) {
|
mCopyBitDraw(false), mCurRenderBufferIndex(0), mEngine(0) {
|
||||||
|
|
||||||
getBufferSizeAndDimensions(ctx->dpyAttr[dpy].xres,
|
getBufferSizeAndDimensions(ctx->dpyAttr[dpy].xres,
|
||||||
ctx->dpyAttr[dpy].yres,
|
ctx->dpyAttr[dpy].yres,
|
||||||
|
|||||||
@@ -283,14 +283,13 @@ int Overlay::comparePipePriority(utils::eDest pipe1Index,
|
|||||||
|
|
||||||
bool Overlay::commit(utils::eDest dest) {
|
bool Overlay::commit(utils::eDest dest) {
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
int index = (int)dest;
|
validate((int)dest);
|
||||||
validate(index);
|
|
||||||
|
|
||||||
if(mPipeBook[index].mPipe->commit()) {
|
if(mPipeBook[dest].mPipe->commit()) {
|
||||||
ret = true;
|
ret = true;
|
||||||
PipeBook::setUse((int)dest);
|
PipeBook::setUse((int)dest);
|
||||||
} else {
|
} else {
|
||||||
int dpy = mPipeBook[index].mDisplay;
|
int dpy = mPipeBook[dest].mDisplay;
|
||||||
for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
|
for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
|
||||||
if (mPipeBook[i].mDisplay == dpy) {
|
if (mPipeBook[i].mDisplay == dpy) {
|
||||||
PipeBook::resetAllocation(i);
|
PipeBook::resetAllocation(i);
|
||||||
@@ -303,52 +302,46 @@ bool Overlay::commit(utils::eDest dest) {
|
|||||||
|
|
||||||
bool Overlay::queueBuffer(int fd, uint32_t offset,
|
bool Overlay::queueBuffer(int fd, uint32_t offset,
|
||||||
utils::eDest dest) {
|
utils::eDest dest) {
|
||||||
int index = (int)dest;
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
validate(index);
|
validate((int)dest);
|
||||||
//Queue only if commit() has succeeded (and the bit set)
|
//Queue only if commit() has succeeded (and the bit set)
|
||||||
if(PipeBook::isUsed((int)dest)) {
|
if(PipeBook::isUsed((int)dest)) {
|
||||||
ret = mPipeBook[index].mPipe->queueBuffer(fd, offset);
|
ret = mPipeBook[dest].mPipe->queueBuffer(fd, offset);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::setCrop(const utils::Dim& d,
|
void Overlay::setCrop(const utils::Dim& d,
|
||||||
utils::eDest dest) {
|
utils::eDest dest) {
|
||||||
int index = (int)dest;
|
validate((int)dest);
|
||||||
validate(index);
|
mPipeBook[dest].mPipe->setCrop(d);
|
||||||
mPipeBook[index].mPipe->setCrop(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::setColor(const uint32_t color,
|
void Overlay::setColor(const uint32_t color,
|
||||||
utils::eDest dest) {
|
utils::eDest dest) {
|
||||||
int index = (int)dest;
|
validate((int)dest);
|
||||||
validate(index);
|
mPipeBook[dest].mPipe->setColor(color);
|
||||||
mPipeBook[index].mPipe->setColor(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::setPosition(const utils::Dim& d,
|
void Overlay::setPosition(const utils::Dim& d,
|
||||||
utils::eDest dest) {
|
utils::eDest dest) {
|
||||||
int index = (int)dest;
|
validate((int)dest);
|
||||||
validate(index);
|
mPipeBook[dest].mPipe->setPosition(d);
|
||||||
mPipeBook[index].mPipe->setPosition(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::setTransform(const int orient,
|
void Overlay::setTransform(const int orient,
|
||||||
utils::eDest dest) {
|
utils::eDest dest) {
|
||||||
int index = (int)dest;
|
validate((int)dest);
|
||||||
validate(index);
|
|
||||||
|
|
||||||
utils::eTransform transform =
|
utils::eTransform transform =
|
||||||
static_cast<utils::eTransform>(orient);
|
static_cast<utils::eTransform>(orient);
|
||||||
mPipeBook[index].mPipe->setTransform(transform);
|
mPipeBook[dest].mPipe->setTransform(transform);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::setSource(const utils::PipeArgs args,
|
void Overlay::setSource(const utils::PipeArgs args,
|
||||||
utils::eDest dest) {
|
utils::eDest dest) {
|
||||||
int index = (int)dest;
|
validate((int)dest);
|
||||||
validate(index);
|
|
||||||
|
|
||||||
PipeArgs newArgs(args);
|
PipeArgs newArgs(args);
|
||||||
if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_VG) {
|
if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_VG) {
|
||||||
@@ -363,13 +356,12 @@ void Overlay::setSource(const utils::PipeArgs args,
|
|||||||
clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA);
|
clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA);
|
||||||
}
|
}
|
||||||
|
|
||||||
mPipeBook[index].mPipe->setSource(newArgs);
|
mPipeBook[dest].mPipe->setSource(newArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::setVisualParams(const MetaData_t& metadata, utils::eDest dest) {
|
void Overlay::setVisualParams(const MetaData_t& metadata, utils::eDest dest) {
|
||||||
int index = (int)dest;
|
validate((int)dest);
|
||||||
validate(index);
|
mPipeBook[dest].mPipe->setVisualParams(metadata);
|
||||||
mPipeBook[index].mPipe->setVisualParams(metadata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Overlay* Overlay::getInstance() {
|
Overlay* Overlay::getInstance() {
|
||||||
@@ -530,7 +522,7 @@ void Overlay::clear(int dpy) {
|
|||||||
|
|
||||||
bool Overlay::validateAndSet(const int& dpy, const int& fbFd) {
|
bool Overlay::validateAndSet(const int& dpy, const int& fbFd) {
|
||||||
GenericPipe* pipeArray[PipeBook::NUM_PIPES];
|
GenericPipe* pipeArray[PipeBook::NUM_PIPES];
|
||||||
memset(&pipeArray, 0, sizeof(pipeArray));
|
memset(pipeArray, 0, sizeof(GenericPipe*)*(PipeBook::NUM_PIPES));
|
||||||
|
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
|
for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user