diff options
26 files changed, 220 insertions, 553 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/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h index 370253a9c1..b9deafcd3b 100644 --- a/include/ui/GraphicBuffer.h +++ b/include/ui/GraphicBuffer.h @@ -62,6 +62,7 @@ public: USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE, USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER, USAGE_HW_2D = GRALLOC_USAGE_HW_2D, + USAGE_HW_COMPOSER = GRALLOC_USAGE_HW_COMPOSER, USAGE_HW_MASK = GRALLOC_USAGE_HW_MASK }; diff --git a/include/ui/KeycodeLabels.h b/include/ui/KeycodeLabels.h index 8383957cdf..2efe8ca0ee 100755 --- a/include/ui/KeycodeLabels.h +++ b/include/ui/KeycodeLabels.h @@ -278,6 +278,8 @@ static const KeycodeLabel AXES[] = { { "WHEEL", 21 }, { "GAS", 22 }, { "BRAKE", 23 }, + { "DISTANCE", 24 }, + { "TILT", 25 }, { "GENERIC_1", 32 }, { "GENERIC_2", 33 }, { "GENERIC_3", 34 }, 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/Surface.cpp b/libs/gui/Surface.cpp index 54d04aada8..ff45fa3470 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -351,13 +351,13 @@ int Surface::query(int what, int* value) const { // ---------------------------------------------------------------------------- -status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn) { +status_t Surface::lock(SurfaceInfo* other, Region* inOutDirtyRegion) { ANativeWindow_Buffer outBuffer; ARect temp; ARect* inOutDirtyBounds = NULL; - if (dirtyIn) { - temp = dirtyIn->getBounds(); + if (inOutDirtyRegion) { + temp = inOutDirtyRegion->getBounds(); inOutDirtyBounds = &temp; } @@ -371,6 +371,11 @@ status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn) { other->format = uint32_t(outBuffer.format); other->bits = outBuffer.bits; } + + if (inOutDirtyRegion) { + inOutDirtyRegion->set( static_cast<Rect const&>(temp) ); + } + return err; } 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/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp index ac9b33b61c..79a01a3512 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/SurfaceTexture.cpp @@ -608,6 +608,9 @@ status_t SurfaceTexture::disconnect(int api) { if (mConnectedApi == api) { drainQueueAndFreeBuffersLocked(); mConnectedApi = NO_CONNECTED_API; + mNextCrop.makeInvalid(); + mNextScalingMode = NATIVE_WINDOW_SCALING_MODE_FREEZE; + mNextTransform = 0; mDequeueCondition.signal(); } else { LOGE("disconnect: connected to another api (cur=%d, req=%d)", @@ -1022,7 +1025,7 @@ void SurfaceTexture::dump(String8& result, const char* prefix, mCurrentCrop.top, mCurrentCrop.right, mCurrentCrop.bottom, mCurrentTransform, mCurrentTexture, prefix, mNextCrop.left, mNextCrop.top, mNextCrop.right, mNextCrop.bottom, - mCurrentTransform, fifoSize, fifo.string() + mNextTransform, fifoSize, fifo.string() ); result.append(buffer); diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp index 5a35b4d482..710ef94b88 100644 --- a/libs/gui/SurfaceTextureClient.cpp +++ b/libs/gui/SurfaceTextureClient.cpp @@ -407,8 +407,15 @@ int SurfaceTextureClient::disconnect(int api) { LOGV("SurfaceTextureClient::disconnect"); Mutex::Autolock lock(mMutex); int err = mSurfaceTexture->disconnect(api); - if (!err && api == NATIVE_WINDOW_API_CPU) { - mConnectedToCpu = false; + if (!err) { + freeAllBuffers(); + mReqFormat = 0; + mReqWidth = 0; + mReqHeight = 0; + mReqUsage = 0; + if (api == NATIVE_WINDOW_API_CPU) { + mConnectedToCpu = false; + } } return err; } 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/opengl/libagl/state.cpp b/opengl/libagl/state.cpp index 8b4136a456..90e9612b83 100644 --- a/opengl/libagl/state.cpp +++ b/opengl/libagl/state.cpp @@ -191,6 +191,9 @@ static void enable_disable(ogles_context_t* c, GLenum cap, int enabled) // these need to fall through into the rasterizer c->rasterizer.procs.enableDisable(c, cap, enabled); break; + case GL_TEXTURE_EXTERNAL_OES: + c->rasterizer.procs.enableDisable(c, GL_TEXTURE_2D, enabled); + break; case GL_MULTISAMPLE: case GL_SAMPLE_ALPHA_TO_COVERAGE: diff --git a/opengl/libagl/texture.cpp b/opengl/libagl/texture.cpp index 8eb17c4355..88e865124e 100644 --- a/opengl/libagl/texture.cpp +++ b/opengl/libagl/texture.cpp @@ -633,7 +633,7 @@ void generateMipmap(ogles_context_t* c, GLint level) static void texParameterx( GLenum target, GLenum pname, GLfixed param, ogles_context_t* c) { - if (target != GL_TEXTURE_2D) { + if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) { ogles_error(c, GL_INVALID_ENUM); return; } @@ -866,7 +866,7 @@ void glActiveTexture(GLenum texture) void glBindTexture(GLenum target, GLuint texture) { ogles_context_t* c = ogles_context_t::get(); - if (target != GL_TEXTURE_2D) { + if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) { ogles_error(c, GL_INVALID_ENUM); return; } @@ -1012,7 +1012,7 @@ void glTexParameteriv( GLenum target, GLenum pname, const GLint* params) { ogles_context_t* c = ogles_context_t::get(); - if (target != GGL_TEXTURE_2D) { + if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) { ogles_error(c, GL_INVALID_ENUM); return; } @@ -1605,7 +1605,7 @@ void glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed w, GLfixed h) { void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) { ogles_context_t* c = ogles_context_t::get(); - if (target != GL_TEXTURE_2D) { + if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) { ogles_error(c, GL_INVALID_ENUM); return; } diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 10cea22bbd..7e85230313 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -454,13 +454,6 @@ EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) EGLBoolean result = s->cnx->egl.eglDestroySurface( dp->disp[s->impl].dpy, s->surface); if (result == EGL_TRUE) { - ANativeWindow* const window = s->win.get(); - if (window != NULL) { - native_window_set_buffers_format(window, 0); - if (native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL)) { - LOGE("EGLNativeWindowType %p disconnected failed", window); - } - } _s.terminate(); } return result; @@ -682,6 +675,9 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw, setGLHooksThreadSpecific(&gHooksNoContext); egl_tls_t::setContext(EGL_NO_CONTEXT); } + } else { + // this will LOGE the error + result = setError(c->cnx->egl.eglGetError(), EGL_FALSE); } return result; } diff --git a/opengl/libs/EGL/egl_object.h b/opengl/libs/EGL/egl_object.h index 3459a8a8de..d2b737897a 100644 --- a/opengl/libs/EGL/egl_object.h +++ b/opengl/libs/EGL/egl_object.h @@ -125,7 +125,15 @@ void egl_object_t::LocalRef<N,T>::terminate() { class egl_surface_t: public egl_object_t { protected: - ~egl_surface_t() {} + ~egl_surface_t() { + ANativeWindow* const window = win.get(); + if (window != NULL) { + native_window_set_buffers_format(window, 0); + if (native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL)) { + LOGE("EGLNativeWindowType %p disconnected failed", window); + } + } + } public: typedef egl_object_t::LocalRef<egl_surface_t, EGLSurface> Ref; @@ -232,4 +240,3 @@ egl_sync_t* get_sync(EGLSyncKHR sync) { // ---------------------------------------------------------------------------- #endif // ANDROID_EGL_OBJECT_H - diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 64eaecc86b..edbc7b0235 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -196,13 +196,12 @@ void Layer::setGeometry(hwc_layer_t* hwcl) * 1) buffer orientation/flip/mirror * 2) state transformation (window manager) * 3) layer orientation (screen orientation) - * mOrientation is already the composition of (2) and (3) + * mTransform is already the composition of (2) and (3) * (NOTE: the matrices are multiplied in reverse order) */ const Transform bufferOrientation(mCurrentTransform); - const Transform layerOrientation(mOrientation); - const Transform tr(layerOrientation * bufferOrientation); + const Transform tr(mTransform * bufferOrientation); // this gives us only the "orientation" component of the transform const uint32_t finalTransform = tr.getOrientation(); @@ -213,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; @@ -233,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) { @@ -245,9 +232,19 @@ void Layer::setPerFrameData(hwc_layer_t* hwcl) { } } -static inline uint16_t pack565(int r, int g, int b) { - return (r<<11)|(g<<5)|b; +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)) { @@ -261,7 +258,8 @@ void Layer::onDraw(const Region& clip) const // figure out if there is something below us Region under; - const SurfaceFlinger::LayerVector& drawingLayers(mFlinger->mDrawingState.layersSortedByZ); + const SurfaceFlinger::LayerVector& drawingLayers( + mFlinger->mDrawingState.layersSortedByZ); const size_t count = drawingLayers.size(); for (size_t i=0 ; i<count ; ++i) { const sp<LayerBase>& layer(drawingLayers[i]); @@ -277,7 +275,7 @@ void Layer::onDraw(const Region& clip) const return; } - GLenum target = mSurfaceTexture->getCurrentTextureTarget(); + const GLenum target = GL_TEXTURE_EXTERNAL_OES; glBindTexture(target, mTextureName); if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) { // TODO: we could be more subtle with isFixedSize() @@ -419,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()); @@ -435,14 +432,29 @@ 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; } - const GLenum target(mSurfaceTexture->getCurrentTextureTarget()); - glTexParameterx(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterx(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // update the layer size and release freeze-lock const Layer::State& front(drawingState()); @@ -450,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); } @@ -542,9 +553,9 @@ void Layer::dump(String8& result, char* buffer, size_t SIZE) const snprintf(buffer, SIZE, " " "format=%2d, activeBuffer=[%4ux%4u:%4u,%3X]," - " freezeLock=%p, queued-frames=%d\n", + " freezeLock=%p, transform-hint=0x%02x, queued-frames=%d\n", mFormat, w0, h0, s0,f0, - getFreezeLock().get(), mQueuedFrames); + getFreezeLock().get(), getTransformHint(), mQueuedFrames); result.append(buffer); @@ -560,9 +571,21 @@ uint32_t Layer::getEffectiveUsage(uint32_t usage) const // need a hardware-protected path to external video sink usage |= GraphicBuffer::USAGE_PROTECTED; } + usage |= GraphicBuffer::USAGE_HW_COMPOSER; return usage; } +uint32_t Layer::getTransformHint() const { + uint32_t orientation = 0; + if (!mFlinger->mDebugDisableTransformHint) { + orientation = getOrientation(); + if (orientation & Transform::ROT_INVALID) { + orientation = 0; + } + } + return orientation; +} + // --------------------------------------------------------------------------- diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 5f0be8074a..d06a35f017 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -89,6 +89,7 @@ private: void onFrameQueued(); virtual sp<ISurface> createSurface(); uint32_t getEffectiveUsage(uint32_t usage) const; + uint32_t getTransformHint() const; bool isCropped() const; static bool getOpacityForFormat(uint32_t format); diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp index 7bf73d9aee..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++; @@ -257,9 +256,8 @@ void LayerBase::validateVisibility(const Transform& planeTransform) // cache a few things... mOrientation = tr.getOrientation(); + mTransform = tr; mTransformedBounds = tr.makeBounds(w, h); - mLeft = tr.tx(); - mTop = tr.ty(); } void LayerBase::lockPageFlip(bool& recomputeVisibleRegions) @@ -334,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; @@ -475,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 a3d36444bc..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; @@ -247,10 +245,9 @@ private: protected: // cached during validateVisibility() int32_t mOrientation; + 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/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 50afb3d8bd..598220fd4c 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -93,6 +93,7 @@ SurfaceFlinger::SurfaceFlinger() mDebugBackground(0), mDebugDDMS(0), mDebugDisableHWC(0), + mDebugDisableTransformHint(0), mDebugInSwapBuffers(0), mLastSwapBufferTime(0), mDebugInTransaction(0), @@ -822,7 +823,7 @@ void SurfaceFlinger::handleWorkList() hwc_layer_t* const cur(hwc.getLayers()); for (size_t i=0 ; cur && i<count ; i++) { currentLayers[i]->setGeometry(&cur[i]); - if (mDebugDisableHWC) { + if (mDebugDisableHWC || mDebugRegion) { cur[i].compositionType = HWC_FRAMEBUFFER; cur[i].flags |= HWC_SKIP_LAYER; } @@ -974,6 +975,10 @@ void SurfaceFlinger::debugFlashRegions() { const DisplayHardware& hw(graphicPlane(0).displayHardware()); const uint32_t flags = hw.getFlags(); + const int32_t height = hw.getHeight(); + if (mInvalidRegion.isEmpty()) { + return; + } if (!((flags & DisplayHardware::SWAP_RECTANGLE) || (flags & DisplayHardware::BUFFER_PRESERVED))) { @@ -999,26 +1004,21 @@ void SurfaceFlinger::debugFlashRegions() while (it != end) { const Rect& r = *it++; GLfloat vertices[][2] = { - { r.left, r.top }, - { r.left, r.bottom }, - { r.right, r.bottom }, - { r.right, r.top } + { r.left, height - r.top }, + { r.left, height - r.bottom }, + { r.right, height - r.bottom }, + { r.right, height - r.top } }; glVertexPointer(2, GL_FLOAT, 0, vertices); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } - if (mInvalidRegion.isEmpty()) { - mDirtyRegion.dump("mDirtyRegion"); - mInvalidRegion.dump("mInvalidRegion"); - } hw.flip(mInvalidRegion); if (mDebugRegion > 1) usleep(mDebugRegion * 1000); glEnable(GL_SCISSOR_TEST); - //mDirtyRegion.dump("mDirtyRegion"); } void SurfaceFlinger::drawWormhole() const @@ -1581,7 +1581,7 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args) HWComposer& hwc(hw.getHwComposer()); snprintf(buffer, SIZE, " h/w composer %s and %s\n", hwc.initCheck()==NO_ERROR ? "present" : "not present", - mDebugDisableHWC ? "disabled" : "enabled"); + (mDebugDisableHWC || mDebugRegion) ? "disabled" : "enabled"); result.append(buffer); hwc.dump(result, buffer, SIZE); @@ -1660,21 +1660,15 @@ status_t SurfaceFlinger::onTransact( case 1002: // SHOW_UPDATES n = data.readInt32(); mDebugRegion = n ? n : (mDebugRegion ? 0 : 1); + invalidateHwcGeometry(); + repaintEverything(); return NO_ERROR; case 1003: // SHOW_BACKGROUND n = data.readInt32(); mDebugBackground = n ? 1 : 0; return NO_ERROR; - case 1008: // toggle use of hw composer - n = data.readInt32(); - mDebugDisableHWC = n ? 1 : 0; - invalidateHwcGeometry(); - // fall-through... case 1004:{ // repaint everything - Mutex::Autolock _l(mStateLock); - const DisplayHardware& hw(graphicPlane(0).displayHardware()); - mDirtyRegion.set(hw.bounds()); // careful that's not thread-safe - signalEvent(); + repaintEverything(); return NO_ERROR; } case 1005:{ // force transaction @@ -1690,6 +1684,18 @@ status_t SurfaceFlinger::onTransact( mFreezeCount = data.readInt32(); mFreezeDisplayTime = 0; return NO_ERROR; + case 1008: // toggle use of hw composer + n = data.readInt32(); + mDebugDisableHWC = n ? 1 : 0; + invalidateHwcGeometry(); + repaintEverything(); + return NO_ERROR; + case 1009: // toggle use of transform hint + n = data.readInt32(); + mDebugDisableTransformHint = n ? 1 : 0; + invalidateHwcGeometry(); + repaintEverything(); + return NO_ERROR; case 1010: // interrogate. reply->writeInt32(0); reply->writeInt32(0); @@ -1707,6 +1713,13 @@ status_t SurfaceFlinger::onTransact( return err; } +void SurfaceFlinger::repaintEverything() { + Mutex::Autolock _l(mStateLock); + const DisplayHardware& hw(graphicPlane(0).displayHardware()); + mDirtyRegion.set(hw.bounds()); // careful that's not thread-safe + signalEvent(); +} + // --------------------------------------------------------------------------- status_t SurfaceFlinger::renderScreenToTextureLocked(DisplayID dpy, @@ -2194,14 +2207,17 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy, return BAD_VALUE; // make sure none of the layers are protected - const Vector< sp<LayerBase> >& layers(mVisibleLayersSortedByZ); + const LayerVector& layers(mDrawingState.layersSortedByZ); const size_t count = layers.size(); for (size_t i=0 ; i<count ; ++i) { const sp<LayerBase>& layer(layers[i]); - const uint32_t z = layer->drawingState().z; - if (z >= minLayerZ && z <= maxLayerZ) { - if (layer->isProtected()) { - return INVALID_OPERATION; + const uint32_t flags = layer->drawingState().flags; + if (!(flags & ISurfaceComposer::eLayerHidden)) { + const uint32_t z = layer->drawingState().z; + if (z >= minLayerZ && z <= maxLayerZ) { + if (layer->isProtected()) { + return INVALID_OPERATION; + } } } } @@ -2257,9 +2273,12 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy, for (size_t i=0 ; i<count ; ++i) { const sp<LayerBase>& layer(layers[i]); - const uint32_t z = layer->drawingState().z; - if (z >= minLayerZ && z <= maxLayerZ) { - layer->drawForSreenShot(); + const uint32_t flags = layer->drawingState().flags; + if (!(flags & ISurfaceComposer::eLayerHidden)) { + const uint32_t z = layer->drawingState().z; + if (z >= minLayerZ && z <= maxLayerZ) { + layer->drawForSreenShot(); + } } } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 1738238abe..5f8eb08683 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -278,6 +278,7 @@ private: void handleRepaint(); void postFramebuffer(); void composeSurfaces(const Region& dirty); + void repaintEverything(); ssize_t addClientLayer(const sp<Client>& client, @@ -373,6 +374,7 @@ private: int mDebugBackground; int mDebugDDMS; int mDebugDisableHWC; + int mDebugDisableTransformHint; volatile nsecs_t mDebugInSwapBuffers; nsecs_t mLastSwapBufferTime; volatile nsecs_t mDebugInTransaction; diff --git a/services/surfaceflinger/SurfaceTextureLayer.cpp b/services/surfaceflinger/SurfaceTextureLayer.cpp index 79cd0c3140..4390ca19fc 100644 --- a/services/surfaceflinger/SurfaceTextureLayer.cpp +++ b/services/surfaceflinger/SurfaceTextureLayer.cpp @@ -57,16 +57,10 @@ status_t SurfaceTextureLayer::queueBuffer(int buf, int64_t timestamp, status_t res = SurfaceTexture::queueBuffer(buf, timestamp, outWidth, outHeight, outTransform); - sp<Layer> layer(mLayer.promote()); if (layer != NULL) { - uint32_t orientation = layer->getOrientation(); - if (orientation & Transform::ROT_INVALID) { - orientation = 0; - } - *outTransform = orientation; + *outTransform = layer->getTransformHint(); } - return res; } diff --git a/services/surfaceflinger/TextureManager.cpp b/services/surfaceflinger/TextureManager.cpp deleted file mode 100644 index bb63c37985..0000000000 --- a/services/surfaceflinger/TextureManager.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <stdlib.h> -#include <stdint.h> -#include <sys/types.h> - -#include <utils/Errors.h> -#include <utils/Log.h> - -#include <ui/GraphicBuffer.h> - -#include <GLES/gl.h> -#include <GLES/glext.h> - -#include <hardware/hardware.h> - -#include "clz.h" -#include "DisplayHardware/DisplayHardware.h" -#include "GLExtensions.h" -#include "TextureManager.h" - -namespace android { - -// --------------------------------------------------------------------------- - -TextureManager::TextureManager() - : mGLExtensions(GLExtensions::getInstance()) -{ -} - -GLenum TextureManager::getTextureTarget(const Image* image) { -#if defined(GL_OES_EGL_image_external) - switch (image->target) { - case Texture::TEXTURE_EXTERNAL: - return GL_TEXTURE_EXTERNAL_OES; - } -#endif - return GL_TEXTURE_2D; -} - -status_t TextureManager::initTexture(Texture* texture) -{ - if (texture->name != -1UL) - return INVALID_OPERATION; - - GLuint textureName = -1; - glGenTextures(1, &textureName); - texture->name = textureName; - texture->width = 0; - texture->height = 0; - - const GLenum target = GL_TEXTURE_2D; - glBindTexture(target, textureName); - glTexParameterx(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterx(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - - return NO_ERROR; -} - -status_t TextureManager::initTexture(Image* pImage, int32_t format) -{ - if (pImage->name != -1UL) - return INVALID_OPERATION; - - GLuint textureName = -1; - glGenTextures(1, &textureName); - pImage->name = textureName; - pImage->width = 0; - pImage->height = 0; - - GLenum target = GL_TEXTURE_2D; -#if defined(GL_OES_EGL_image_external) - if (GLExtensions::getInstance().haveTextureExternal()) { - if (format && isYuvFormat(format)) { - target = GL_TEXTURE_EXTERNAL_OES; - pImage->target = Texture::TEXTURE_EXTERNAL; - } - } -#endif - - glBindTexture(target, textureName); - glTexParameterx(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterx(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - - return NO_ERROR; -} - -bool TextureManager::isSupportedYuvFormat(int format) -{ - switch (format) { - case HAL_PIXEL_FORMAT_YV12: - return true; - } - return false; -} - -bool TextureManager::isYuvFormat(int format) -{ - switch (format) { - // supported YUV formats - case HAL_PIXEL_FORMAT_YV12: - // Legacy/deprecated YUV formats - case HAL_PIXEL_FORMAT_YCbCr_422_SP: - case HAL_PIXEL_FORMAT_YCrCb_420_SP: - case HAL_PIXEL_FORMAT_YCbCr_422_I: - return true; - } - - // Any OEM format needs to be considered - if (format>=0x100 && format<=0x1FF) - return true; - - return false; -} - -status_t TextureManager::initEglImage(Image* pImage, - EGLDisplay dpy, const sp<GraphicBuffer>& buffer) -{ - status_t err = NO_ERROR; - if (!pImage->dirty) return err; - - // free the previous image - if (pImage->image != EGL_NO_IMAGE_KHR) { - eglDestroyImageKHR(dpy, pImage->image); - pImage->image = EGL_NO_IMAGE_KHR; - } - - // construct an EGL_NATIVE_BUFFER_ANDROID - ANativeWindowBuffer* clientBuf = buffer->getNativeBuffer(); - - // create the new EGLImageKHR - const EGLint attrs[] = { - EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, - EGL_NONE, EGL_NONE - }; - pImage->image = eglCreateImageKHR( - dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, - (EGLClientBuffer)clientBuf, attrs); - - if (pImage->image != EGL_NO_IMAGE_KHR) { - if (pImage->name == -1UL) { - initTexture(pImage, buffer->format); - } - const GLenum target = getTextureTarget(pImage); - glBindTexture(target, pImage->name); - glEGLImageTargetTexture2DOES(target, (GLeglImageOES)pImage->image); - GLint error = glGetError(); - if (error != GL_NO_ERROR) { - LOGE("glEGLImageTargetTexture2DOES(%p) failed err=0x%04x", - pImage->image, error); - err = INVALID_OPERATION; - } else { - // Everything went okay! - pImage->dirty = false; - pImage->width = clientBuf->width; - pImage->height = clientBuf->height; - } - } else { - LOGE("eglCreateImageKHR() failed. err=0x%4x", eglGetError()); - err = INVALID_OPERATION; - } - return err; -} - -status_t TextureManager::loadTexture(Texture* texture, - const Region& dirty, const GGLSurface& t) -{ - if (texture->name == -1UL) { - status_t err = initTexture(texture); - LOGE_IF(err, "loadTexture failed in initTexture (%s)", strerror(err)); - if (err != NO_ERROR) return err; - } - - if (texture->target != Texture::TEXTURE_2D) - return INVALID_OPERATION; - - glBindTexture(GL_TEXTURE_2D, texture->name); - - /* - * In OpenGL ES we can't specify a stride with glTexImage2D (however, - * GL_UNPACK_ALIGNMENT is a limited form of stride). - * So if the stride here isn't representable with GL_UNPACK_ALIGNMENT, we - * need to do something reasonable (here creating a bigger texture). - * - * extra pixels = (((stride - width) * pixelsize) / GL_UNPACK_ALIGNMENT); - * - * This situation doesn't happen often, but some h/w have a limitation - * for their framebuffer (eg: must be multiple of 8 pixels), and - * we need to take that into account when using these buffers as - * textures. - * - * This should never be a problem with POT textures - */ - - int unpack = __builtin_ctz(t.stride * bytesPerPixel(t.format)); - unpack = 1 << ((unpack > 3) ? 3 : unpack); - glPixelStorei(GL_UNPACK_ALIGNMENT, unpack); - - /* - * round to POT if needed - */ - if (!mGLExtensions.haveNpot()) { - texture->NPOTAdjust = true; - } - - if (texture->NPOTAdjust) { - // find the smallest power-of-two that will accommodate our surface - texture->potWidth = 1 << (31 - clz(t.width)); - texture->potHeight = 1 << (31 - clz(t.height)); - if (texture->potWidth < t.width) texture->potWidth <<= 1; - if (texture->potHeight < t.height) texture->potHeight <<= 1; - texture->wScale = float(t.width) / texture->potWidth; - texture->hScale = float(t.height) / texture->potHeight; - } else { - texture->potWidth = t.width; - texture->potHeight = t.height; - } - - Rect bounds(dirty.bounds()); - GLvoid* data = 0; - if (texture->width != t.width || texture->height != t.height) { - texture->width = t.width; - texture->height = t.height; - - // texture size changed, we need to create a new one - bounds.set(Rect(t.width, t.height)); - if (t.width == texture->potWidth && - t.height == texture->potHeight) { - // we can do it one pass - data = t.data; - } - - if (t.format == HAL_PIXEL_FORMAT_RGB_565) { - glTexImage2D(GL_TEXTURE_2D, 0, - GL_RGB, texture->potWidth, texture->potHeight, 0, - GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data); - } else if (t.format == HAL_PIXEL_FORMAT_RGBA_4444) { - glTexImage2D(GL_TEXTURE_2D, 0, - GL_RGBA, texture->potWidth, texture->potHeight, 0, - GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data); - } else if (t.format == HAL_PIXEL_FORMAT_RGBA_8888 || - t.format == HAL_PIXEL_FORMAT_RGBX_8888) { - glTexImage2D(GL_TEXTURE_2D, 0, - GL_RGBA, texture->potWidth, texture->potHeight, 0, - GL_RGBA, GL_UNSIGNED_BYTE, data); - } else if (isSupportedYuvFormat(t.format)) { - // just show the Y plane of YUV buffers - glTexImage2D(GL_TEXTURE_2D, 0, - GL_LUMINANCE, texture->potWidth, texture->potHeight, 0, - GL_LUMINANCE, GL_UNSIGNED_BYTE, data); - } else { - // oops, we don't handle this format! - LOGE("texture=%d, using format %d, which is not " - "supported by the GL", texture->name, t.format); - } - } - if (!data) { - if (t.format == HAL_PIXEL_FORMAT_RGB_565) { - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, bounds.top, t.width, bounds.height(), - GL_RGB, GL_UNSIGNED_SHORT_5_6_5, - t.data + bounds.top*t.stride*2); - } else if (t.format == HAL_PIXEL_FORMAT_RGBA_4444) { - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, bounds.top, t.width, bounds.height(), - GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, - t.data + bounds.top*t.stride*2); - } else if (t.format == HAL_PIXEL_FORMAT_RGBA_8888 || - t.format == HAL_PIXEL_FORMAT_RGBX_8888) { - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, bounds.top, t.width, bounds.height(), - GL_RGBA, GL_UNSIGNED_BYTE, - t.data + bounds.top*t.stride*4); - } else if (isSupportedYuvFormat(t.format)) { - // just show the Y plane of YUV buffers - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, bounds.top, t.width, bounds.height(), - GL_LUMINANCE, GL_UNSIGNED_BYTE, - t.data + bounds.top*t.stride); - } - } - return NO_ERROR; -} - -void TextureManager::activateTexture(const Texture& texture, bool filter) -{ - const GLenum target = getTextureTarget(&texture); - if (target == GL_TEXTURE_2D) { - glBindTexture(GL_TEXTURE_2D, texture.name); - glEnable(GL_TEXTURE_2D); -#if defined(GL_OES_EGL_image_external) - if (GLExtensions::getInstance().haveTextureExternal()) { - glDisable(GL_TEXTURE_EXTERNAL_OES); - } - } else { - glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture.name); - glEnable(GL_TEXTURE_EXTERNAL_OES); - glDisable(GL_TEXTURE_2D); -#endif - } - - if (filter) { - glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } else { - glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - } -} - -void TextureManager::deactivateTextures() -{ - glDisable(GL_TEXTURE_2D); -#if defined(GL_OES_EGL_image_external) - if (GLExtensions::getInstance().haveTextureExternal()) { - glDisable(GL_TEXTURE_EXTERNAL_OES); - } -#endif -} - -// --------------------------------------------------------------------------- - -}; // namespace android diff --git a/services/surfaceflinger/TextureManager.h b/services/surfaceflinger/TextureManager.h deleted file mode 100644 index 18c4348693..0000000000 --- a/services/surfaceflinger/TextureManager.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_TEXTURE_MANAGER_H -#define ANDROID_TEXTURE_MANAGER_H - -#include <stdint.h> -#include <sys/types.h> - -#include <EGL/egl.h> -#include <EGL/eglext.h> -#include <GLES/gl.h> - -#include <ui/Region.h> - -#include <pixelflinger/pixelflinger.h> - -namespace android { - -// --------------------------------------------------------------------------- - -class GLExtensions; -class GraphicBuffer; - -// --------------------------------------------------------------------------- - -struct Image { - enum { TEXTURE_2D=0, TEXTURE_EXTERNAL=1 }; - Image() : name(-1U), image(EGL_NO_IMAGE_KHR), width(0), height(0), - dirty(1), target(TEXTURE_2D) { } - GLuint name; - EGLImageKHR image; - GLuint width; - GLuint height; - unsigned dirty : 1; - unsigned target : 1; -}; - -struct Texture : public Image { - Texture() : Image(), NPOTAdjust(0) { } - GLuint potWidth; - GLuint potHeight; - GLfloat wScale; - GLfloat hScale; - unsigned NPOTAdjust : 1; -}; - -// --------------------------------------------------------------------------- - -class TextureManager { - const GLExtensions& mGLExtensions; - static status_t initTexture(Image* texture, int32_t format); - static status_t initTexture(Texture* texture); - static bool isSupportedYuvFormat(int format); - static bool isYuvFormat(int format); - static GLenum getTextureTarget(const Image* pImage); -public: - - TextureManager(); - - // load bitmap data into the active buffer - status_t loadTexture(Texture* texture, - const Region& dirty, const GGLSurface& t); - - // make active buffer an EGLImage if needed - status_t initEglImage(Image* texture, - EGLDisplay dpy, const sp<GraphicBuffer>& buffer); - - // activate a texture - static void activateTexture(const Texture& texture, bool filter); - - // deactivate a texture - static void deactivateTextures(); -}; - -// --------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_TEXTURE_MANAGER_H 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(); |