diff options
Diffstat (limited to 'libs/surfaceflinger')
-rw-r--r-- | libs/surfaceflinger/Android.mk | 8 | ||||
-rw-r--r-- | libs/surfaceflinger/Layer.cpp | 12 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBase.cpp | 42 | ||||
-rw-r--r-- | libs/surfaceflinger/SurfaceFlinger.cpp | 15 | ||||
-rw-r--r-- | libs/surfaceflinger/SurfaceFlinger.h | 5 |
5 files changed, 73 insertions, 9 deletions
diff --git a/libs/surfaceflinger/Android.mk b/libs/surfaceflinger/Android.mk index 86eb78d..bf74089 100644 --- a/libs/surfaceflinger/Android.mk +++ b/libs/surfaceflinger/Android.mk @@ -38,8 +38,12 @@ LOCAL_SHARED_LIBRARIES := \ libEGL \ libGLESv1_CM \ libbinder \ - libui \ - libsurfaceflinger_client + libui + +ifneq ($(BOARD_USES_ECLAIR_LIBCAMERA),true) + LOCAL_SHARED_LIBRARIES += \ + libsurfaceflinger_client +endif LOCAL_C_INCLUDES := \ $(call include-path-for, corecg graphics) diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp index ce7e9aa..2c7b4af 100644 --- a/libs/surfaceflinger/Layer.cpp +++ b/libs/surfaceflinger/Layer.cpp @@ -133,10 +133,14 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h, mNeedsBlending = (info.h_alpha - info.l_alpha) > 0; mNoEGLImageForSwBuffers = !(hwFlags & DisplayHardware::CACHED_BUFFERS); - // we use the red index - int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED); - int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED); - mNeedsDithering = layerRedsize > displayRedSize; + if (mFlinger->getUseDithering()) { + // we use the red index + int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED); + int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED); + mNeedsDithering = layerRedsize > displayRedSize; + } else { + mNeedsDithering = false; + } for (size_t i=0 ; i<NUM_BUFFERS ; i++) { mBuffers[i] = new GraphicBuffer(); diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp index a8b735e..f78d140 100644 --- a/libs/surfaceflinger/LayerBase.cpp +++ b/libs/surfaceflinger/LayerBase.cpp @@ -33,6 +33,12 @@ #include "SurfaceFlinger.h" #include "DisplayHardware/DisplayHardware.h" +#define RENDER_EFFECT_NIGHT 1 +#define RENDER_EFFECT_TERMINAL 2 +#define RENDER_EFFECT_BLUE 3 +#define RENDER_EFFECT_AMBER 4 +#define RENDER_EFFECT_SALMON 5 +#define RENDER_EFFECT_FUSCIA 6 namespace android { @@ -401,7 +407,10 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const glEnable(GL_TEXTURE_2D); - if (UNLIKELY(s.alpha < 0xFF)) { + int renderEffect = mFlinger->getRenderEffect(); + bool noEffect = renderEffect == 0; + + if (UNLIKELY(s.alpha < 0xFF) && noEffect) { // We have an alpha-modulation. We need to modulate all // texture components by alpha because we're always using // premultiplied alpha. @@ -423,7 +432,7 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const glEnable(GL_BLEND); glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA); glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env); - } else { + } else if (noEffect) { glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glColor4x(0x10000, 0x10000, 0x10000, 0x10000); if (needsBlending()) { @@ -433,6 +442,35 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const } else { glDisable(GL_BLEND); } + } else { + // Apply a render effect, which is simple color masks for now. + GLenum env, src; + env = GL_MODULATE; + src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA; + const GGLfixed alpha = (s.alpha << 16)/255; + switch (renderEffect) { + case RENDER_EFFECT_NIGHT: + glColor4x(alpha, 0, 0, alpha); + break; + case RENDER_EFFECT_TERMINAL: + glColor4x(0, alpha, 0, alpha); + break; + case RENDER_EFFECT_BLUE: + glColor4x(0, 0, alpha, alpha); + break; + case RENDER_EFFECT_AMBER: + glColor4x(alpha, alpha*0.75, 0, alpha); + break; + case RENDER_EFFECT_SALMON: + glColor4x(alpha, alpha*0.5, alpha*0.5, alpha); + break; + case RENDER_EFFECT_FUSCIA: + glColor4x(alpha, 0, alpha*0.5, alpha); + break; + } + glEnable(GL_BLEND); + glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA); + glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env); } Region::const_iterator it = clip.begin(); diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp index 0722fda..b868cd1 100644 --- a/libs/surfaceflinger/SurfaceFlinger.cpp +++ b/libs/surfaceflinger/SurfaceFlinger.cpp @@ -184,13 +184,15 @@ SurfaceFlinger::SurfaceFlinger() mFreezeDisplayTime(0), mDebugRegion(0), mDebugBackground(0), + mRenderEffect(0), mDebugInSwapBuffers(0), mLastSwapBufferTime(0), mDebugInTransaction(0), mLastTransactionTime(0), mBootFinished(false), mConsoleSignals(0), - mSecureFrameBuffer(0) + mSecureFrameBuffer(0), + mUseDithering(true) { init(); } @@ -205,9 +207,14 @@ void SurfaceFlinger::init() mDebugRegion = atoi(value); property_get("debug.sf.showbackground", value, "0"); mDebugBackground = atoi(value); + property_get("debug.sf.render_effect", value, "0"); + mRenderEffect = atoi(value); + property_get("persist.sys.use_dithering", value, "1"); + mUseDithering = atoi(value) == 1; LOGI_IF(mDebugRegion, "showupdates enabled"); LOGI_IF(mDebugBackground, "showbackground enabled"); + LOGI_IF(mUseDithering, "dithering enabled"); } SurfaceFlinger::~SurfaceFlinger() @@ -1692,12 +1699,18 @@ status_t SurfaceFlinger::onTransact( reply->writeInt32(0); reply->writeInt32(mDebugRegion); reply->writeInt32(mDebugBackground); + reply->writeInt32(mRenderEffect); return NO_ERROR; case 1013: { Mutex::Autolock _l(mStateLock); const DisplayHardware& hw(graphicPlane(0).displayHardware()); reply->writeInt32(hw.getPageFlipCount()); } + case 1014: { // RENDER_EFFECT + // TODO: filter to only allow valid effects + mRenderEffect = data.readInt32(); + return NO_ERROR; + } return NO_ERROR; } } diff --git a/libs/surfaceflinger/SurfaceFlinger.h b/libs/surfaceflinger/SurfaceFlinger.h index d75dc15..812fd43 100644 --- a/libs/surfaceflinger/SurfaceFlinger.h +++ b/libs/surfaceflinger/SurfaceFlinger.h @@ -174,6 +174,9 @@ public: overlay_control_device_t* getOverlayEngine() const; + inline int getRenderEffect() const { return mRenderEffect; } + inline int getUseDithering() const { return mUseDithering; } + status_t removeLayer(const sp<LayerBase>& layer); status_t addLayer(const sp<LayerBase>& layer); @@ -354,6 +357,7 @@ private: // don't use a lock for these, we don't care int mDebugRegion; int mDebugBackground; + int mRenderEffect; volatile nsecs_t mDebugInSwapBuffers; nsecs_t mLastSwapBufferTime; volatile nsecs_t mDebugInTransaction; @@ -372,6 +376,7 @@ private: // only written in the main thread, only read in other threads volatile int32_t mSecureFrameBuffer; + bool mUseDithering; }; // --------------------------------------------------------------------------- |