diff options
| -rw-r--r-- | include/private/surfaceflinger/LayerState.h | 4 | ||||
| -rw-r--r-- | include/surfaceflinger/SurfaceComposerClient.h | 2 | ||||
| -rw-r--r-- | include/utils/threads.h | 7 | ||||
| -rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 6 | ||||
| -rw-r--r-- | libs/gui/tests/Android.mk | 10 | ||||
| -rw-r--r-- | libs/utils/Threads.cpp | 35 | ||||
| -rw-r--r-- | services/surfaceflinger/Layer.cpp | 53 | ||||
| -rw-r--r-- | services/surfaceflinger/LayerBase.cpp | 18 | ||||
| -rw-r--r-- | services/surfaceflinger/LayerBase.h | 6 | ||||
| -rw-r--r-- | services/surfaceflinger/Transform.cpp | 12 | ||||
| -rw-r--r-- | services/surfaceflinger/Transform.h | 4 |
11 files changed, 104 insertions, 53 deletions
diff --git a/include/private/surfaceflinger/LayerState.h b/include/private/surfaceflinger/LayerState.h index d2fed418f0..3eb5c99f6f 100644 --- a/include/private/surfaceflinger/LayerState.h +++ b/include/private/surfaceflinger/LayerState.h @@ -54,8 +54,8 @@ struct layer_state_t { }; SurfaceID surface; uint32_t what; - int32_t x; - int32_t y; + float x; + float y; uint32_t z; uint32_t w; uint32_t h; diff --git a/include/surfaceflinger/SurfaceComposerClient.h b/include/surfaceflinger/SurfaceComposerClient.h index 7fbbfb24f0..ace0735c66 100644 --- a/include/surfaceflinger/SurfaceComposerClient.h +++ b/include/surfaceflinger/SurfaceComposerClient.h @@ -145,7 +145,7 @@ public: status_t setAlpha(SurfaceID id, float alpha=1.0f); status_t setFreezeTint(SurfaceID id, uint32_t tint); status_t setMatrix(SurfaceID id, float dsdx, float dtdx, float dsdy, float dtdy); - status_t setPosition(SurfaceID id, int32_t x, int32_t y); + status_t setPosition(SurfaceID id, float x, float y); status_t setSize(SurfaceID id, uint32_t w, uint32_t h); status_t destroySurface(SurfaceID sid); diff --git a/include/utils/threads.h b/include/utils/threads.h index c84a9b448c..c685625055 100644 --- a/include/utils/threads.h +++ b/include/utils/threads.h @@ -143,6 +143,13 @@ extern int androidSetThreadSchedulingGroup(pid_t tid, int grp); // in either case errno is set. Thread ID zero means current thread. extern int androidSetThreadPriority(pid_t tid, int prio); +// Get the current scheduling group of a particular thread. Normally returns +// one of the ANDROID_TGROUP constants other than ANDROID_TGROUP_DEFAULT. +// Returns ANDROID_TGROUP_DEFAULT if no pthread support (e.g. on host) or if +// scheduling groups are disabled. Returns INVALID_OPERATION if unexpected error. +// Thread ID zero means current thread. +extern int androidGetThreadSchedulingGroup(pid_t tid); + #ifdef __cplusplus } #endif diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 3b0ffea0ff..00a4bf63ca 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -102,7 +102,7 @@ class Composer : public Singleton<Composer> public: status_t setPosition(const sp<SurfaceComposerClient>& client, SurfaceID id, - int32_t x, int32_t y); + float x, float y); status_t setSize(const sp<SurfaceComposerClient>& client, SurfaceID id, uint32_t w, uint32_t h); status_t setLayer(const sp<SurfaceComposerClient>& client, SurfaceID id, @@ -161,7 +161,7 @@ layer_state_t* Composer::getLayerStateLocked( } status_t Composer::setPosition(const sp<SurfaceComposerClient>& client, - SurfaceID id, int32_t x, int32_t y) { + SurfaceID id, float x, float y) { Mutex::Autolock _l(mLock); layer_state_t* s = getLayerStateLocked(client, id); if (!s) @@ -372,7 +372,7 @@ status_t SurfaceComposerClient::setFreezeTint(SurfaceID id, uint32_t tint) { return getComposer().setFreezeTint(this, id, tint); } -status_t SurfaceComposerClient::setPosition(SurfaceID id, int32_t x, int32_t y) { +status_t SurfaceComposerClient::setPosition(SurfaceID id, float x, float y) { return getComposer().setPosition(this, id, x, y); } diff --git a/libs/gui/tests/Android.mk b/libs/gui/tests/Android.mk index 0308af3abf..55ac1330e9 100644 --- a/libs/gui/tests/Android.mk +++ b/libs/gui/tests/Android.mk @@ -1,4 +1,4 @@ -# Build the unit tests. +# Build the unit tests, LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) @@ -22,17 +22,15 @@ LOCAL_SHARED_LIBRARIES := \ libui \ libutils \ -LOCAL_STATIC_LIBRARIES := \ - libgtest \ - libgtest_main \ - LOCAL_C_INCLUDES := \ bionic \ bionic/libstdc++/include \ external/gtest/include \ external/stlport/stlport \ -include $(BUILD_EXECUTABLE) +# Build the binary to $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE) +# to integrate with auto-test framework. +include $(BUILD_NATIVE_TEST) # Include subdirectory makefiles # ============================================================ diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp index d18c0a2f5a..02c380b0e5 100644 --- a/libs/utils/Threads.cpp +++ b/libs/utils/Threads.cpp @@ -368,6 +368,41 @@ int androidSetThreadPriority(pid_t tid, int pri) return rc; } +int androidGetThreadSchedulingGroup(pid_t tid) +{ + int ret = ANDROID_TGROUP_DEFAULT; + +#if defined(HAVE_PTHREADS) + // convention is to not call get/set_sched_policy methods if disabled by property + pthread_once(&gDoSchedulingGroupOnce, checkDoSchedulingGroup); + if (gDoSchedulingGroup) { + SchedPolicy policy; + // get_sched_policy does not support tid == 0 + if (tid == 0) { + tid = androidGetTid(); + } + if (get_sched_policy(tid, &policy) < 0) { + ret = INVALID_OPERATION; + } else { + switch (policy) { + case SP_BACKGROUND: + ret = ANDROID_TGROUP_BG_NONINTERACT; + break; + case SP_FOREGROUND: + ret = ANDROID_TGROUP_FG_BOOST; + break; + default: + // should not happen, as enum SchedPolicy does not have any other values + ret = INVALID_OPERATION; + break; + } + } + } +#endif + + return ret; +} + namespace android { /* diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index f8925b840f..edbc7b0235 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -212,19 +212,6 @@ void Layer::setGeometry(hwc_layer_t* hwcl) } else { hwcl->transform = finalTransform; } -} - -void Layer::setPerFrameData(hwc_layer_t* hwcl) { - const sp<GraphicBuffer>& buffer(mActiveBuffer); - if (buffer == NULL) { - // this can happen if the client never drew into this layer yet, - // or if we ran out of memory. In that case, don't let - // HWC handle it. - hwcl->flags |= HWC_SKIP_LAYER; - hwcl->handle = NULL; - } else { - hwcl->handle = buffer->handle; - } if (isCropped()) { hwcl->sourceCrop.left = mCurrentCrop.left; @@ -232,6 +219,7 @@ void Layer::setPerFrameData(hwc_layer_t* hwcl) { hwcl->sourceCrop.right = mCurrentCrop.right; hwcl->sourceCrop.bottom = mCurrentCrop.bottom; } else { + const sp<GraphicBuffer>& buffer(mActiveBuffer); hwcl->sourceCrop.left = 0; hwcl->sourceCrop.top = 0; if (buffer != NULL) { @@ -244,6 +232,19 @@ void Layer::setPerFrameData(hwc_layer_t* hwcl) { } } +void Layer::setPerFrameData(hwc_layer_t* hwcl) { + const sp<GraphicBuffer>& buffer(mActiveBuffer); + if (buffer == NULL) { + // this can happen if the client never drew into this layer yet, + // or if we ran out of memory. In that case, don't let + // HWC handle it. + hwcl->flags |= HWC_SKIP_LAYER; + hwcl->handle = NULL; + } else { + hwcl->handle = buffer->handle; + } +} + void Layer::onDraw(const Region& clip) const { if (CC_UNLIKELY(mActiveBuffer == 0)) { @@ -416,8 +417,7 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) return; } - mActiveBuffer = mSurfaceTexture->getCurrentBuffer(); - mSurfaceTexture->getTransformMatrix(mTextureMatrix); + sp<GraphicBuffer> newFrontBuffer(mSurfaceTexture->getCurrentBuffer()); const Rect crop(mSurfaceTexture->getCurrentCrop()); const uint32_t transform(mSurfaceTexture->getCurrentTransform()); @@ -432,7 +432,23 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) mFlinger->invalidateHwcGeometry(); } - mCurrentOpacity = getOpacityForFormat(mActiveBuffer->format); + GLfloat textureMatrix[16]; + mSurfaceTexture->getTransformMatrix(textureMatrix); + if (memcmp(textureMatrix, mTextureMatrix, sizeof(textureMatrix))) { + memcpy(mTextureMatrix, textureMatrix, sizeof(textureMatrix)); + mFlinger->invalidateHwcGeometry(); + } + + uint32_t bufWidth = newFrontBuffer->getWidth(); + uint32_t bufHeight = newFrontBuffer->getHeight(); + if (mActiveBuffer != NULL) { + if (bufWidth != uint32_t(mActiveBuffer->width) || + bufHeight != uint32_t(mActiveBuffer->height)) { + mFlinger->invalidateHwcGeometry(); + } + } + + mCurrentOpacity = getOpacityForFormat(newFrontBuffer->format); if (oldOpacity != isOpaque()) { recomputeVisibleRegions = true; } @@ -446,15 +462,14 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) // FIXME: mPostedDirtyRegion = dirty & bounds mPostedDirtyRegion.set(front.w, front.h); + // update active buffer + mActiveBuffer = newFrontBuffer; if ((front.w != front.requested_w) || (front.h != front.requested_h)) { // check that we received a buffer of the right size // (Take the buffer's orientation into account) - sp<GraphicBuffer> newFrontBuffer(mActiveBuffer); - uint32_t bufWidth = newFrontBuffer->getWidth(); - uint32_t bufHeight = newFrontBuffer->getHeight(); if (mCurrentTransform & Transform::ROT_90) { swap(bufWidth, bufHeight); } diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp index 4cc245a110..603fb607ba 100644 --- a/services/surfaceflinger/LayerBase.cpp +++ b/services/surfaceflinger/LayerBase.cpp @@ -45,7 +45,6 @@ LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display) mFlinger(flinger), mFiltering(false), mNeedsFiltering(false), mOrientation(0), - mLeft(0), mTop(0), mTransactionFlags(0), mPremultipliedAlpha(true), mName("unnamed"), mDebug(false), mInvalidate(0) @@ -119,7 +118,7 @@ uint32_t LayerBase::setTransactionFlags(uint32_t flags) { return android_atomic_or(flags, &mTransactionFlags); } -bool LayerBase::setPosition(int32_t x, int32_t y) { +bool LayerBase::setPosition(float x, float y) { if (mCurrentState.transform.tx() == x && mCurrentState.transform.ty() == y) return false; mCurrentState.sequence++; @@ -259,8 +258,6 @@ void LayerBase::validateVisibility(const Transform& planeTransform) mOrientation = tr.getOrientation(); mTransform = tr; mTransformedBounds = tr.makeBounds(w, h); - mLeft = tr.tx(); - mTop = tr.ty(); } void LayerBase::lockPageFlip(bool& recomputeVisibleRegions) @@ -335,17 +332,18 @@ void LayerBase::setGeometry(hwc_layer_t* hwcl) reinterpret_cast<hwc_rect_t const *>( visibleRegionScreen.getArray( &hwcl->visibleRegionScreen.numRects)); -} -void LayerBase::setPerFrameData(hwc_layer_t* hwcl) { - hwcl->compositionType = HWC_FRAMEBUFFER; - hwcl->handle = NULL; hwcl->sourceCrop.left = 0; hwcl->sourceCrop.top = 0; hwcl->sourceCrop.right = mTransformedBounds.width(); hwcl->sourceCrop.bottom = mTransformedBounds.height(); } +void LayerBase::setPerFrameData(hwc_layer_t* hwcl) { + hwcl->compositionType = HWC_FRAMEBUFFER; + hwcl->handle = NULL; +} + void LayerBase::setFiltering(bool filtering) { mFiltering = filtering; @@ -476,10 +474,10 @@ void LayerBase::dump(String8& result, char* buffer, size_t SIZE) const snprintf(buffer, SIZE, "+ %s %p\n" " " - "z=%9d, pos=(%4d,%4d), size=(%4d,%4d), " + "z=%9d, pos=(%g,%g), size=(%4d,%4d), " "isOpaque=%1d, needsDithering=%1d, invalidate=%1d, " "alpha=0x%02x, flags=0x%08x, tr=[%.2f, %.2f][%.2f, %.2f]\n", - getTypeId(), this, s.z, tx(), ty(), s.w, s.h, + getTypeId(), this, s.z, s.transform.tx(), s.transform.ty(), s.w, s.h, isOpaque(), needsDithering(), contentDirty, s.alpha, s.flags, s.transform[0][0], s.transform[0][1], diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h index 2cd3a9435e..d20f06ac87 100644 --- a/services/surfaceflinger/LayerBase.h +++ b/services/surfaceflinger/LayerBase.h @@ -84,7 +84,7 @@ public: String8 getName() const; // modify current state - bool setPosition(int32_t x, int32_t y); + bool setPosition(float x, float y); bool setLayer(uint32_t z); bool setSize(uint32_t w, uint32_t h); bool setAlpha(uint8_t alpha); @@ -217,8 +217,6 @@ public: inline State& currentState() { return mCurrentState; } int32_t getOrientation() const { return mOrientation; } - int tx() const { return mLeft; } - int ty() const { return mTop; } protected: const GraphicPlane& graphicPlane(int dpy) const; @@ -250,8 +248,6 @@ protected: Transform mTransform; GLfloat mVertices[4][2]; Rect mTransformedBounds; - int mLeft; - int mTop; // these are protected by an external lock State mCurrentState; diff --git a/services/surfaceflinger/Transform.cpp b/services/surfaceflinger/Transform.cpp index 05b7527563..ba345ce45b 100644 --- a/services/surfaceflinger/Transform.cpp +++ b/services/surfaceflinger/Transform.cpp @@ -91,12 +91,12 @@ bool Transform::transformed() const { return type() > TRANSLATE; } -int Transform::tx() const { - return floorf(mMatrix[2][0] + 0.5f); +float Transform::tx() const { + return mMatrix[2][0]; } -int Transform::ty() const { - return floorf(mMatrix[2][1] + 0.5f); +float Transform::ty() const { + return mMatrix[2][1]; } void Transform::reset() { @@ -239,7 +239,9 @@ Region Transform::transform(const Region& reg) const out.set(transform(reg.bounds())); } } else { - out = reg.translate(tx(), ty()); + int xpos = floorf(tx() + 0.5f); + int ypos = floorf(ty() + 0.5f); + out = reg.translate(xpos, ypos); } return out; } diff --git a/services/surfaceflinger/Transform.h b/services/surfaceflinger/Transform.h index 8fa5b86ffa..ec74243d2d 100644 --- a/services/surfaceflinger/Transform.h +++ b/services/surfaceflinger/Transform.h @@ -64,8 +64,8 @@ public: uint32_t getOrientation() const; float const* operator [] (int i) const; // returns column i - int tx() const; - int ty() const; + float tx() const; + float ty() const; // modify the transform void reset(); |