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