Add a h/w composer API to allow the HAL to trigger a redraw
This is useful in various situations, for instance if the HAL wants to change its compositing strategy. Bug: 4488017 Change-Id: I5afc14e5917c6db7926d7417d48677d5aba50caa
This commit is contained in:
parent
d05b34a079
commit
c7d14e2471
@ -40,6 +40,7 @@
|
||||
|
||||
#include "GLExtensions.h"
|
||||
#include "HWComposer.h"
|
||||
#include "SurfaceFlinger.h"
|
||||
|
||||
using namespace android;
|
||||
|
||||
@ -75,7 +76,7 @@ DisplayHardware::DisplayHardware(
|
||||
const sp<SurfaceFlinger>& flinger,
|
||||
uint32_t dpy)
|
||||
: DisplayHardwareBase(flinger, dpy),
|
||||
mFlags(0), mHwc(0)
|
||||
mFlinger(flinger), mFlags(0), mHwc(0)
|
||||
{
|
||||
init(dpy);
|
||||
}
|
||||
@ -310,7 +311,7 @@ void DisplayHardware::init(uint32_t dpy)
|
||||
|
||||
|
||||
// initialize the H/W composer
|
||||
mHwc = new HWComposer();
|
||||
mHwc = new HWComposer(mFlinger);
|
||||
if (mHwc->initCheck() == NO_ERROR) {
|
||||
mHwc->setFrameBuffer(mDisplay, mSurface);
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ private:
|
||||
void init(uint32_t displayIndex) __attribute__((noinline));
|
||||
void fini() __attribute__((noinline));
|
||||
|
||||
sp<SurfaceFlinger> mFlinger;
|
||||
EGLDisplay mDisplay;
|
||||
EGLSurface mSurface;
|
||||
EGLContext mContext;
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
|
||||
~DisplayHardwareBase();
|
||||
|
||||
// console managment
|
||||
// console management
|
||||
void releaseScreen() const;
|
||||
void acquireScreen() const;
|
||||
bool isScreenAcquired() const;
|
||||
|
@ -30,12 +30,14 @@
|
||||
#include <EGL/egl.h>
|
||||
|
||||
#include "HWComposer.h"
|
||||
#include "SurfaceFlinger.h"
|
||||
|
||||
namespace android {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
HWComposer::HWComposer()
|
||||
: mModule(0), mHwc(0), mList(0), mCapacity(0),
|
||||
HWComposer::HWComposer(const sp<SurfaceFlinger>& flinger)
|
||||
: mFlinger(flinger),
|
||||
mModule(0), mHwc(0), mList(0), mCapacity(0),
|
||||
mDpy(EGL_NO_DISPLAY), mSur(EGL_NO_SURFACE)
|
||||
{
|
||||
int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &mModule);
|
||||
@ -44,6 +46,13 @@ HWComposer::HWComposer()
|
||||
err = hwc_open(mModule, &mHwc);
|
||||
LOGE_IF(err, "%s device failed to initialize (%s)",
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
mDpy = (hwc_display_t)dpy;
|
||||
mSur = (hwc_surface_t)sur;
|
||||
|
@ -24,16 +24,19 @@
|
||||
|
||||
#include <hardware/hwcomposer.h>
|
||||
|
||||
#include <utils/StrongPointer.h>
|
||||
|
||||
namespace android {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class String8;
|
||||
class SurfaceFlinger;
|
||||
|
||||
class HWComposer
|
||||
{
|
||||
public:
|
||||
|
||||
HWComposer();
|
||||
HWComposer(const sp<SurfaceFlinger>& flinger);
|
||||
~HWComposer();
|
||||
|
||||
status_t initCheck() const;
|
||||
@ -60,12 +63,21 @@ public:
|
||||
void dump(String8& out, char* scratch, size_t SIZE) const;
|
||||
|
||||
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;
|
||||
hwc_composer_device_t* mHwc;
|
||||
hwc_layer_list_t* mList;
|
||||
size_t mCapacity;
|
||||
hwc_display_t mDpy;
|
||||
hwc_surface_t mSur;
|
||||
cb_context mCBContext;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user