diff options
author | Mathias Agopian <mathias@google.com> | 2010-08-24 17:56:40 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-08-24 17:56:40 -0700 |
commit | bce2e90ca9bc2277a4816b7996f84506df411cf9 (patch) | |
tree | 2a1902282acfebe7f68a202a4c43ffbeb0e9df6d /libs/surfaceflinger_client | |
parent | 8d9d751a8f09a0199d1d22a3f8267eb51f919cc0 (diff) | |
parent | bc4389edfbb5777aec1a9af7863b2ca3ade2fa64 (diff) | |
download | frameworks_base-bce2e90ca9bc2277a4816b7996f84506df411cf9.zip frameworks_base-bce2e90ca9bc2277a4816b7996f84506df411cf9.tar.gz frameworks_base-bce2e90ca9bc2277a4816b7996f84506df411cf9.tar.bz2 |
am bc4389ed: am 8395b462: Merge "fix [2931513] Add support for setting the orientation of an ANativeWindow" into gingerbread
Merge commit 'bc4389edfbb5777aec1a9af7863b2ca3ade2fa64'
* commit 'bc4389edfbb5777aec1a9af7863b2ca3ade2fa64':
fix [2931513] Add support for setting the orientation of an ANativeWindow
Diffstat (limited to 'libs/surfaceflinger_client')
-rw-r--r-- | libs/surfaceflinger_client/SharedBufferStack.cpp | 46 | ||||
-rw-r--r-- | libs/surfaceflinger_client/Surface.cpp | 22 |
2 files changed, 68 insertions, 0 deletions
diff --git a/libs/surfaceflinger_client/SharedBufferStack.cpp b/libs/surfaceflinger_client/SharedBufferStack.cpp index 47ec78a..4c01cd2 100644 --- a/libs/surfaceflinger_client/SharedBufferStack.cpp +++ b/libs/surfaceflinger_client/SharedBufferStack.cpp @@ -75,6 +75,14 @@ status_t SharedBufferStack::setCrop(int buffer, const Rect& crop) return NO_ERROR; } +status_t SharedBufferStack::setTransform(int buffer, uint8_t transform) +{ + if (uint32_t(buffer) >= NUM_BUFFER_MAX) + return BAD_INDEX; + buffers[buffer].transform = transform; + return NO_ERROR; +} + status_t SharedBufferStack::setDirtyRegion(int buffer, const Region& dirty) { if (uint32_t(buffer) >= NUM_BUFFER_MAX) @@ -137,6 +145,26 @@ Region SharedBufferStack::getDirtyRegion(int buffer) const return res; } +Rect SharedBufferStack::getCrop(int buffer) const +{ + Rect res(-1, -1); + if (uint32_t(buffer) >= NUM_BUFFER_MAX) + return res; + res.left = buffers[buffer].crop.l; + res.top = buffers[buffer].crop.t; + res.right = buffers[buffer].crop.r; + res.bottom = buffers[buffer].crop.b; + return res; +} + +uint32_t SharedBufferStack::getTransform(int buffer) const +{ + if (uint32_t(buffer) >= NUM_BUFFER_MAX) + return 0; + return buffers[buffer].transform; +} + + // ---------------------------------------------------------------------------- SharedBufferBase::SharedBufferBase(SharedClient* sharedClient, @@ -428,6 +456,12 @@ status_t SharedBufferClient::setCrop(int buf, const Rect& crop) return stack.setCrop(buf, crop); } +status_t SharedBufferClient::setTransform(int buf, uint32_t transform) +{ + SharedBufferStack& stack( *mSharedStack ); + return stack.setTransform(buf, uint8_t(transform)); +} + status_t SharedBufferClient::setDirtyRegion(int buf, const Region& reg) { SharedBufferStack& stack( *mSharedStack ); @@ -544,6 +578,18 @@ Region SharedBufferServer::getDirtyRegion(int buf) const return stack.getDirtyRegion(buf); } +Rect SharedBufferServer::getCrop(int buf) const +{ + SharedBufferStack& stack( *mSharedStack ); + return stack.getCrop(buf); +} + +uint32_t SharedBufferServer::getTransform(int buf) const +{ + SharedBufferStack& stack( *mSharedStack ); + return stack.getTransform(buf); +} + /* * NOTE: this is not thread-safe on the server-side, meaning * 'head' cannot move during this operation. The client-side diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp index f524476..2bc5fad 100644 --- a/libs/surfaceflinger_client/Surface.cpp +++ b/libs/surfaceflinger_client/Surface.cpp @@ -429,8 +429,10 @@ void Surface::init() const_cast<int&>(ANativeWindow::maxSwapInterval) = 1; const_cast<uint32_t&>(ANativeWindow::flags) = 0; + mNextBufferTransform = 0; mConnected = 0; mSwapRectangle.makeInvalid(); + mNextBufferCrop = Rect(0,0); // two buffers by default mBuffers.setCapacity(2); mBuffers.insertAt(0, 2); @@ -641,6 +643,7 @@ int Surface::queueBuffer(android_native_buffer_t* buffer) } int32_t bufIdx = getBufferIndex(GraphicBuffer::getSelf(buffer)); + mSharedBufferClient->setTransform(bufIdx, mNextBufferTransform); mSharedBufferClient->setCrop(bufIdx, mNextBufferCrop); mSharedBufferClient->setDirtyRegion(bufIdx, mDirtyRegion); err = mSharedBufferClient->queue(bufIdx); @@ -695,6 +698,9 @@ int Surface::perform(int operation, va_list args) case NATIVE_WINDOW_SET_BUFFERS_GEOMETRY: res = dispatch_set_buffers_geometry( args ); break; + case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM: + res = dispatch_set_buffers_transform( args ); + break; default: res = NAME_NOT_FOUND; break; @@ -729,6 +735,11 @@ int Surface::dispatch_set_buffers_geometry(va_list args) { return setBuffersGeometry(w, h, f); } +int Surface::dispatch_set_buffers_transform(va_list args) { + int transform = va_arg(args, int); + return setBuffersTransform(transform); +} + void Surface::setUsage(uint32_t reqUsage) { Mutex::Autolock _l(mSurfaceLock); @@ -775,6 +786,10 @@ int Surface::disconnect(int api) int Surface::crop(Rect const* rect) { + // empty/invalid rects are not allowed + if (rect->isEmpty()) + return BAD_VALUE; + Mutex::Autolock _l(mSurfaceLock); // TODO: validate rect size mNextBufferCrop = *rect; @@ -814,6 +829,13 @@ int Surface::setBuffersGeometry(int w, int h, int format) return NO_ERROR; } +int Surface::setBuffersTransform(int transform) +{ + Mutex::Autolock _l(mSurfaceLock); + mNextBufferTransform = transform; + return NO_ERROR; +} + // ---------------------------------------------------------------------------- int Surface::getConnectedApi() const |