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 | 60 | ||||
-rw-r--r-- | libs/surfaceflinger/SurfaceFlinger.cpp | 39 | ||||
-rw-r--r-- | libs/surfaceflinger/SurfaceFlinger.h | 11 |
5 files changed, 120 insertions, 10 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..046c7c3 100644 --- a/libs/surfaceflinger/LayerBase.cpp +++ b/libs/surfaceflinger/LayerBase.cpp @@ -33,6 +33,15 @@ #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 +#define RENDER_EFFECT_N1_CALIBRATED_N 7 +#define RENDER_EFFECT_N1_CALIBRATED_R 8 +#define RENDER_EFFECT_N1_CALIBRATED_C 9 namespace android { @@ -401,7 +410,14 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const glEnable(GL_TEXTURE_2D); - if (UNLIKELY(s.alpha < 0xFF)) { + int renderEffect = mFlinger->getRenderEffect(); + int renderColorR = mFlinger->getRenderColorR(); + int renderColorG = mFlinger->getRenderColorG(); + int renderColorB = mFlinger->getRenderColorB(); + + 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 +439,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 +449,44 @@ 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; + case RENDER_EFFECT_N1_CALIBRATED_N: + glColor4x(alpha*renderColorR/1000, alpha*renderColorG/1000, alpha*renderColorB/1000, alpha); + break; + case RENDER_EFFECT_N1_CALIBRATED_R: + glColor4x(alpha*(renderColorR-50)/1000, alpha*renderColorG/1000, alpha*(renderColorB-30)/1000, alpha); + break; + case RENDER_EFFECT_N1_CALIBRATED_C: + glColor4x(alpha*renderColorR/1000, alpha*renderColorG/1000, alpha*(renderColorB+30)/1000, 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(); @@ -826,4 +880,4 @@ sp<OverlayRef> LayerBaseClient::Surface::createOverlay( // --------------------------------------------------------------------------- -}; // namespace android +}; // namespace android
\ No newline at end of file diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp index 0722fda..9e327ec 100644 --- a/libs/surfaceflinger/SurfaceFlinger.cpp +++ b/libs/surfaceflinger/SurfaceFlinger.cpp @@ -184,13 +184,18 @@ SurfaceFlinger::SurfaceFlinger() mFreezeDisplayTime(0), mDebugRegion(0), mDebugBackground(0), + mRenderEffect(0), + mRenderColorR(0), + mRenderColorG(0), + mRenderColorB(0), mDebugInSwapBuffers(0), mLastSwapBufferTime(0), mDebugInTransaction(0), mLastTransactionTime(0), mBootFinished(false), mConsoleSignals(0), - mSecureFrameBuffer(0) + mSecureFrameBuffer(0), + mUseDithering(true) { init(); } @@ -205,9 +210,23 @@ 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); + + // default calibration color set (disabled by default) + property_get("debug.sf.render_color_red", value, "975"); + mRenderColorR = atoi(value); + property_get("debug.sf.render_color_green", value, "937"); + mRenderColorG = atoi(value); + property_get("debug.sf.render_color_blue", value, "824"); + mRenderColorB = 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 +1711,30 @@ 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; + } + case 1015: { // RENDER_COLOR_RED + mRenderColorR = data.readInt32(); + return NO_ERROR; + } + case 1016: { // RENDER_COLOR_GREEN + mRenderColorG = data.readInt32(); + return NO_ERROR; + } + case 1017: { // RENDER_COLOR_BLUE + mRenderColorB = data.readInt32(); + return NO_ERROR; + } return NO_ERROR; } } diff --git a/libs/surfaceflinger/SurfaceFlinger.h b/libs/surfaceflinger/SurfaceFlinger.h index d75dc15..1bfdb1b 100644 --- a/libs/surfaceflinger/SurfaceFlinger.h +++ b/libs/surfaceflinger/SurfaceFlinger.h @@ -174,6 +174,12 @@ public: overlay_control_device_t* getOverlayEngine() const; + inline int getRenderEffect() const { return mRenderEffect; } + inline int getRenderColorR() const { return mRenderColorR; } + inline int getRenderColorG() const { return mRenderColorG; } + inline int getRenderColorB() const { return mRenderColorB; } + inline int getUseDithering() const { return mUseDithering; } + status_t removeLayer(const sp<LayerBase>& layer); status_t addLayer(const sp<LayerBase>& layer); @@ -354,6 +360,10 @@ private: // don't use a lock for these, we don't care int mDebugRegion; int mDebugBackground; + int mRenderEffect; + int mRenderColorR; + int mRenderColorG; + int mRenderColorB; volatile nsecs_t mDebugInSwapBuffers; nsecs_t mLastSwapBufferTime; volatile nsecs_t mDebugInTransaction; @@ -372,6 +382,7 @@ private: // only written in the main thread, only read in other threads volatile int32_t mSecureFrameBuffer; + bool mUseDithering; }; // --------------------------------------------------------------------------- |