summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2012-09-04 19:30:46 -0700
committerMathias Agopian <mathias@google.com>2012-09-04 19:30:46 -0700
commit00e8c7a88a5b9c4104a71013a713acd3e4d3b77b (patch)
tree71fd225e0f7f8dd1a909c64c97718989aa8f06c2
parentda8d0a5c0cf9d41915d3b106cad4aaec3e767c11 (diff)
downloadframeworks_native-00e8c7a88a5b9c4104a71013a713acd3e4d3b77b.zip
frameworks_native-00e8c7a88a5b9c4104a71013a713acd3e4d3b77b.tar.gz
frameworks_native-00e8c7a88a5b9c4104a71013a713acd3e4d3b77b.tar.bz2
display projection API now has a single function instead of 3
Change-Id: I9bf46d372b77d547486d4bbe6f1953ec8c65e98f
-rw-r--r--include/gui/SurfaceComposerClient.h20
-rw-r--r--include/private/gui/LayerState.h8
-rw-r--r--libs/gui/SurfaceComposerClient.cpp60
-rw-r--r--services/surfaceflinger/DisplayDevice.cpp21
-rw-r--r--services/surfaceflinger/DisplayDevice.h4
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp27
6 files changed, 51 insertions, 89 deletions
diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
index a143d81..57c72c9 100644
--- a/include/gui/SurfaceComposerClient.h
+++ b/include/gui/SurfaceComposerClient.h
@@ -121,11 +121,21 @@ public:
const sp<ISurfaceTexture>& surface);
static void setDisplayLayerStack(const sp<IBinder>& token,
uint32_t layerStack);
- static void setDisplayOrientation(const sp<IBinder>& token,
- uint32_t orientation);
- static void setDisplayViewport(const sp<IBinder>& token,
- const Rect& viewport);
- static void setDisplayFrame(const sp<IBinder>& token, const Rect& frame);
+
+ /* setDisplayProjection() defines the projection of layer stacks
+ * to a given display.
+ *
+ * - orientation defines the display's orientation.
+ * - layerStackRect defines which area of the window manager coordinate
+ * space will be used.
+ * - displayRect defines where on the display will layerStackRect be
+ * mapped to. displayRect is specified post-orientation, that is
+ * it uses the orientation seen by the end-user.
+ */
+ static void setDisplayProjection(const sp<IBinder>& token,
+ uint32_t orientation,
+ const Rect& layerStackRect,
+ const Rect& displayRect);
private:
virtual void onFirstRef();
diff --git a/include/private/gui/LayerState.h b/include/private/gui/LayerState.h
index 65d9eb3..a7eb48c 100644
--- a/include/private/gui/LayerState.h
+++ b/include/private/gui/LayerState.h
@@ -107,11 +107,9 @@ struct DisplayState {
};
enum {
- eSurfaceChanged = 0x01,
- eLayerStackChanged = 0x02,
- eOrientationChanged = 0x04,
- eViewportChanged = 0x08,
- eFrameChanged = 0x10
+ eSurfaceChanged = 0x01,
+ eLayerStackChanged = 0x02,
+ eDisplayProjectionChanged = 0x04
};
uint32_t what;
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index e4922a4..814036e 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -119,9 +119,10 @@ public:
void setDisplaySurface(const sp<IBinder>& token, const sp<ISurfaceTexture>& surface);
void setDisplayLayerStack(const sp<IBinder>& token, uint32_t layerStack);
- void setDisplayOrientation(const sp<IBinder>& token, uint32_t orientation);
- void setDisplayViewport(const sp<IBinder>& token, const Rect& viewport);
- void setDisplayFrame(const sp<IBinder>& token, const Rect& frame);
+ void setDisplayProjection(const sp<IBinder>& token,
+ uint32_t orientation,
+ const Rect& layerStackRect,
+ const Rect& displayRect);
static void closeGlobalTransaction(bool synchronous) {
Composer::getInstance().closeGlobalTransactionImpl(synchronous);
@@ -326,39 +327,19 @@ void Composer::setDisplayLayerStack(const sp<IBinder>& token,
s.what |= DisplayState::eLayerStackChanged;
}
-void Composer::setDisplayOrientation(const sp<IBinder>& token,
- uint32_t orientation) {
+void Composer::setDisplayProjection(const sp<IBinder>& token,
+ uint32_t orientation,
+ const Rect& layerStackRect,
+ const Rect& displayRect) {
Mutex::Autolock _l(mLock);
DisplayState& s(getDisplayStateLocked(token));
s.orientation = orientation;
- s.what |= DisplayState::eOrientationChanged;
+ s.viewport = layerStackRect;
+ s.frame = displayRect;
+ s.what |= DisplayState::eDisplayProjectionChanged;
mForceSynchronous = true; // TODO: do we actually still need this?
}
-// FIXME: get rid of this eventually
-status_t Composer::setOrientation(int orientation) {
- sp<ISurfaceComposer> sm(ComposerService::getComposerService());
- sp<IBinder> token(sm->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
- Composer::setDisplayOrientation(token, orientation);
- return NO_ERROR;
-}
-
-void Composer::setDisplayViewport(const sp<IBinder>& token,
- const Rect& viewport) {
- Mutex::Autolock _l(mLock);
- DisplayState& s(getDisplayStateLocked(token));
- s.viewport = viewport;
- s.what |= DisplayState::eViewportChanged;
-}
-
-void Composer::setDisplayFrame(const sp<IBinder>& token,
- const Rect& frame) {
- Mutex::Autolock _l(mLock);
- DisplayState& s(getDisplayStateLocked(token));
- s.frame = frame;
- s.what |= DisplayState::eFrameChanged;
-}
-
// ---------------------------------------------------------------------------
SurfaceComposerClient::SurfaceComposerClient()
@@ -520,19 +501,12 @@ void SurfaceComposerClient::setDisplayLayerStack(const sp<IBinder>& token,
Composer::getInstance().setDisplayLayerStack(token, layerStack);
}
-void SurfaceComposerClient::setDisplayOrientation(const sp<IBinder>& token,
- uint32_t orientation) {
- Composer::getInstance().setDisplayOrientation(token, orientation);
-}
-
-void SurfaceComposerClient::setDisplayViewport(const sp<IBinder>& token,
- const Rect& viewport) {
- Composer::getInstance().setDisplayViewport(token, viewport);
-}
-
-void SurfaceComposerClient::setDisplayFrame(const sp<IBinder>& token,
- const Rect& frame) {
- Composer::getInstance().setDisplayFrame(token, frame);
+void SurfaceComposerClient::setDisplayProjection(const sp<IBinder>& token,
+ uint32_t orientation,
+ const Rect& layerStackRect,
+ const Rect& displayRect) {
+ Composer::getInstance().setDisplayProjection(token, orientation,
+ layerStackRect, displayRect);
}
// ----------------------------------------------------------------------------
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index cf781d3..01ae1c2 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -150,7 +150,7 @@ void DisplayDevice::init(EGLConfig config)
mHwcDisplayId = mFlinger->allocateHwcDisplayId(mType);
// initialize the display orientation transform.
- DisplayDevice::setOrientation(DisplayState::eOrientationDefault);
+ setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
}
uint32_t DisplayDevice::getPageFlipCount() const {
@@ -298,25 +298,14 @@ status_t DisplayDevice::orientationToTransfrom(
return NO_ERROR;
}
-void DisplayDevice::setOrientation(int orientation) {
+void DisplayDevice::setProjection(int orientation,
+ const Rect& viewport, const Rect& frame) {
mOrientation = orientation;
+ mViewport = viewport;
+ mFrame = frame;
updateGeometryTransform();
}
-void DisplayDevice::setViewport(const Rect& viewport) {
- if (viewport.isValid()) {
- mViewport = viewport;
- updateGeometryTransform();
- }
-}
-
-void DisplayDevice::setFrame(const Rect& frame) {
- if (frame.isValid()) {
- mFrame = frame;
- updateGeometryTransform();
- }
-}
-
void DisplayDevice::updateGeometryTransform() {
int w = mDisplayWidth;
int h = mDisplayHeight;
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 12a0152..8122b9d 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -94,9 +94,7 @@ public:
Region getDirtyRegion(bool repaintEverything) const;
void setLayerStack(uint32_t stack);
- void setOrientation(int orientation);
- void setViewport(const Rect& viewport);
- void setFrame(const Rect& frame);
+ void setProjection(int orientation, const Rect& viewport, const Rect& frame);
int getOrientation() const { return mOrientation; }
const Transform& getTransform() const { return mGlobalTransform; }
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index ed91d44..f6dd62a 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -972,14 +972,12 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
if (state.layerStack != draw[i].layerStack) {
disp->setLayerStack(state.layerStack);
}
- if (state.orientation != draw[i].orientation) {
- disp->setOrientation(state.orientation);
- }
- if (state.viewport != draw[i].viewport) {
- disp->setViewport(state.viewport);
- }
- if (state.frame != draw[i].frame) {
- disp->setFrame(state.frame);
+ if ((state.orientation != draw[i].orientation)
+ || (state.viewport != draw[i].viewport)
+ || (state.frame != draw[i].frame))
+ {
+ disp->setProjection(state.orientation,
+ state.viewport, state.viewport);
}
}
}
@@ -997,9 +995,8 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
sp<DisplayDevice> disp = new DisplayDevice(this,
state.type, display, stc, 0, mEGLConfig);
disp->setLayerStack(state.layerStack);
- disp->setOrientation(state.orientation);
- disp->setViewport(state.viewport);
- disp->setFrame(state.frame);
+ disp->setProjection(state.orientation,
+ state.viewport, state.viewport);
mDisplays.add(display, disp);
}
}
@@ -1499,19 +1496,15 @@ uint32_t SurfaceFlinger::setDisplayStateLocked(const DisplayState& s)
flags |= eDisplayTransactionNeeded;
}
}
- if (what & DisplayState::eOrientationChanged) {
+ if (what & DisplayState::eDisplayProjectionChanged) {
if (disp.orientation != s.orientation) {
disp.orientation = s.orientation;
flags |= eDisplayTransactionNeeded;
}
- }
- if (what & DisplayState::eFrameChanged) {
if (disp.frame != s.frame) {
disp.frame = s.frame;
flags |= eDisplayTransactionNeeded;
}
- }
- if (what & DisplayState::eViewportChanged) {
if (disp.viewport != s.viewport) {
disp.viewport = s.viewport;
flags |= eDisplayTransactionNeeded;
@@ -1732,7 +1725,7 @@ void SurfaceFlinger::onInitializeDisplays() {
Vector<ComposerState> state;
Vector<DisplayState> displays;
DisplayState d;
- d.what = DisplayState::eOrientationChanged;
+ d.what = DisplayState::eDisplayProjectionChanged;
d.token = mDefaultDisplays[DisplayDevice::DISPLAY_PRIMARY];
d.orientation = DisplayState::eOrientationDefault;
displays.add(d);