Merge "Add a h/w composer API to allow the HAL to trigger a redraw"
This commit is contained in:
commit
bc64f9ad37
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
#include "GLExtensions.h"
|
#include "GLExtensions.h"
|
||||||
#include "HWComposer.h"
|
#include "HWComposer.h"
|
||||||
|
#include "SurfaceFlinger.h"
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ DisplayHardware::DisplayHardware(
|
|||||||
const sp<SurfaceFlinger>& flinger,
|
const sp<SurfaceFlinger>& flinger,
|
||||||
uint32_t dpy)
|
uint32_t dpy)
|
||||||
: DisplayHardwareBase(flinger, dpy),
|
: DisplayHardwareBase(flinger, dpy),
|
||||||
mFlags(0), mHwc(0)
|
mFlinger(flinger), mFlags(0), mHwc(0)
|
||||||
{
|
{
|
||||||
init(dpy);
|
init(dpy);
|
||||||
}
|
}
|
||||||
@ -310,7 +311,7 @@ void DisplayHardware::init(uint32_t dpy)
|
|||||||
|
|
||||||
|
|
||||||
// initialize the H/W composer
|
// initialize the H/W composer
|
||||||
mHwc = new HWComposer();
|
mHwc = new HWComposer(mFlinger);
|
||||||
if (mHwc->initCheck() == NO_ERROR) {
|
if (mHwc->initCheck() == NO_ERROR) {
|
||||||
mHwc->setFrameBuffer(mDisplay, mSurface);
|
mHwc->setFrameBuffer(mDisplay, mSurface);
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ private:
|
|||||||
void init(uint32_t displayIndex) __attribute__((noinline));
|
void init(uint32_t displayIndex) __attribute__((noinline));
|
||||||
void fini() __attribute__((noinline));
|
void fini() __attribute__((noinline));
|
||||||
|
|
||||||
|
sp<SurfaceFlinger> mFlinger;
|
||||||
EGLDisplay mDisplay;
|
EGLDisplay mDisplay;
|
||||||
EGLSurface mSurface;
|
EGLSurface mSurface;
|
||||||
EGLContext mContext;
|
EGLContext mContext;
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
|
|
||||||
~DisplayHardwareBase();
|
~DisplayHardwareBase();
|
||||||
|
|
||||||
// console managment
|
// console management
|
||||||
void releaseScreen() const;
|
void releaseScreen() const;
|
||||||
void acquireScreen() const;
|
void acquireScreen() const;
|
||||||
bool isScreenAcquired() const;
|
bool isScreenAcquired() const;
|
||||||
|
@ -30,12 +30,14 @@
|
|||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
|
|
||||||
#include "HWComposer.h"
|
#include "HWComposer.h"
|
||||||
|
#include "SurfaceFlinger.h"
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
HWComposer::HWComposer()
|
HWComposer::HWComposer(const sp<SurfaceFlinger>& flinger)
|
||||||
: mModule(0), mHwc(0), mList(0), mCapacity(0),
|
: mFlinger(flinger),
|
||||||
|
mModule(0), mHwc(0), mList(0), mCapacity(0),
|
||||||
mDpy(EGL_NO_DISPLAY), mSur(EGL_NO_SURFACE)
|
mDpy(EGL_NO_DISPLAY), mSur(EGL_NO_SURFACE)
|
||||||
{
|
{
|
||||||
int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &mModule);
|
int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &mModule);
|
||||||
@ -44,6 +46,13 @@ HWComposer::HWComposer()
|
|||||||
err = hwc_open(mModule, &mHwc);
|
err = hwc_open(mModule, &mHwc);
|
||||||
LOGE_IF(err, "%s device failed to initialize (%s)",
|
LOGE_IF(err, "%s device failed to initialize (%s)",
|
||||||
HWC_HARDWARE_COMPOSER, strerror(-err));
|
HWC_HARDWARE_COMPOSER, strerror(-err));
|
||||||
|
if (err == 0) {
|
||||||
|
if (mHwc->registerProcs) {
|
||||||
|
mCBContext.hwc = this;
|
||||||
|
mCBContext.procs.invalidate = &hook_invalidate;
|
||||||
|
mHwc->registerProcs(mHwc, &mCBContext.procs);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +67,14 @@ status_t HWComposer::initCheck() const {
|
|||||||
return mHwc ? NO_ERROR : NO_INIT;
|
return mHwc ? NO_ERROR : NO_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HWComposer::hook_invalidate(struct hwc_procs* procs) {
|
||||||
|
reinterpret_cast<cb_context *>(procs)->hwc->invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HWComposer::invalidate() {
|
||||||
|
mFlinger->signalEvent();
|
||||||
|
}
|
||||||
|
|
||||||
void HWComposer::setFrameBuffer(EGLDisplay dpy, EGLSurface sur) {
|
void HWComposer::setFrameBuffer(EGLDisplay dpy, EGLSurface sur) {
|
||||||
mDpy = (hwc_display_t)dpy;
|
mDpy = (hwc_display_t)dpy;
|
||||||
mSur = (hwc_surface_t)sur;
|
mSur = (hwc_surface_t)sur;
|
||||||
|
@ -24,16 +24,19 @@
|
|||||||
|
|
||||||
#include <hardware/hwcomposer.h>
|
#include <hardware/hwcomposer.h>
|
||||||
|
|
||||||
|
#include <utils/StrongPointer.h>
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
class String8;
|
class String8;
|
||||||
|
class SurfaceFlinger;
|
||||||
|
|
||||||
class HWComposer
|
class HWComposer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HWComposer();
|
HWComposer(const sp<SurfaceFlinger>& flinger);
|
||||||
~HWComposer();
|
~HWComposer();
|
||||||
|
|
||||||
status_t initCheck() const;
|
status_t initCheck() const;
|
||||||
@ -60,12 +63,21 @@ public:
|
|||||||
void dump(String8& out, char* scratch, size_t SIZE) const;
|
void dump(String8& out, char* scratch, size_t SIZE) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct cb_context {
|
||||||
|
hwc_procs_t procs;
|
||||||
|
HWComposer* hwc;
|
||||||
|
};
|
||||||
|
static void hook_invalidate(struct hwc_procs* procs);
|
||||||
|
void invalidate();
|
||||||
|
|
||||||
|
sp<SurfaceFlinger> mFlinger;
|
||||||
hw_module_t const* mModule;
|
hw_module_t const* mModule;
|
||||||
hwc_composer_device_t* mHwc;
|
hwc_composer_device_t* mHwc;
|
||||||
hwc_layer_list_t* mList;
|
hwc_layer_list_t* mList;
|
||||||
size_t mCapacity;
|
size_t mCapacity;
|
||||||
hwc_display_t mDpy;
|
hwc_display_t mDpy;
|
||||||
hwc_surface_t mSur;
|
hwc_surface_t mSur;
|
||||||
|
cb_context mCBContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user