summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger/DisplayHardware
diff options
context:
space:
mode:
authorMichael Lentine <mlentine@google.com>2014-07-18 15:34:25 -0700
committerMichael Lentine <mlentine@google.com>2014-07-30 14:36:25 -0700
commit47e45405d1533aa73307014f7bf371e118695cf3 (patch)
treecabc47d4088308ed27b799d998a6d4a705e18058 /services/surfaceflinger/DisplayHardware
parent1f6078aef71b1d3f080cd565adbec350c71088dd (diff)
downloadframeworks_native-47e45405d1533aa73307014f7bf371e118695cf3.zip
frameworks_native-47e45405d1533aa73307014f7bf371e118695cf3.tar.gz
frameworks_native-47e45405d1533aa73307014f7bf371e118695cf3.tar.bz2
Allow for resizing of Virtual Displays.
Modify SurfaceFlinger to use VirtualDisplaySurface in all cases when a virtual display is used. Add functionality in VirtualDisplaySurface to resize the buffers aquired in the QueueBufferOutput. Add transaction support in SurfaceFlinger for resize. Add the modification of the size in DisplayDevice. Change-Id: Iae7e3556dc06fd18d470adbbd76f7255f6e6dd6b Tested: None
Diffstat (limited to 'services/surfaceflinger/DisplayHardware')
-rw-r--r--services/surfaceflinger/DisplayHardware/DisplaySurface.h2
-rw-r--r--services/surfaceflinger/DisplayHardware/FramebufferSurface.h4
-rw-r--r--services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp42
-rw-r--r--services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h9
4 files changed, 46 insertions, 11 deletions
diff --git a/services/surfaceflinger/DisplayHardware/DisplaySurface.h b/services/surfaceflinger/DisplayHardware/DisplaySurface.h
index 1db3eb8..e60c4fb 100644
--- a/services/surfaceflinger/DisplayHardware/DisplaySurface.h
+++ b/services/surfaceflinger/DisplayHardware/DisplaySurface.h
@@ -72,6 +72,8 @@ public:
virtual void dump(String8& result) const = 0;
+ virtual void resizeBuffers(const uint32_t w, const uint32_t h) = 0;
+
protected:
DisplaySurface() {}
virtual ~DisplaySurface() {}
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
index ba72ce3..d0bf22b 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
@@ -49,6 +49,10 @@ public:
// has a non-virtual dump() with the same signature.
virtual void dump(String8& result) const;
+ // Cannot resize a buffers in a FramebufferSurface. Only works with virtual
+ // displays.
+ virtual void resizeBuffers(const uint32_t /*w*/, const uint32_t /*h*/) { };
+
private:
virtual ~FramebufferSurface() { }; // this class cannot be overloaded
diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
index ad7cd25..ca04495 100644
--- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
@@ -68,6 +68,8 @@ VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
int sinkWidth, sinkHeight;
sink->query(NATIVE_WINDOW_WIDTH, &sinkWidth);
sink->query(NATIVE_WINDOW_HEIGHT, &sinkHeight);
+ mSinkBufferWidth = sinkWidth;
+ mSinkBufferHeight = sinkHeight;
// Pick the buffer format to request from the sink when not rendering to it
// with GLES. If the consumer needs CPU access, use the default format
@@ -104,10 +106,6 @@ status_t VirtualDisplaySurface::beginFrame(bool mustRecompose) {
"Unexpected beginFrame() in %s state", dbgStateStr());
mDbgState = DBG_STATE_BEGUN;
- uint32_t transformHint, numPendingBuffers;
- mQueueBufferOutput.deflate(&mSinkBufferWidth, &mSinkBufferHeight,
- &transformHint, &numPendingBuffers);
-
return refreshOutputBuffer();
}
@@ -259,8 +257,20 @@ void VirtualDisplaySurface::onFrameCommitted() {
void VirtualDisplaySurface::dump(String8& /* result */) const {
}
+void VirtualDisplaySurface::resizeBuffers(const uint32_t w, const uint32_t h) {
+ uint32_t tmpW, tmpH, transformHint, numPendingBuffers;
+ mQueueBufferOutput.deflate(&tmpW, &tmpH, &transformHint, &numPendingBuffers);
+ mQueueBufferOutput.inflate(w, h, transformHint, numPendingBuffers);
+
+ mSinkBufferWidth = w;
+ mSinkBufferHeight = h;
+}
+
status_t VirtualDisplaySurface::requestBuffer(int pslot,
sp<GraphicBuffer>* outBuf) {
+ if (mDisplayId < 0)
+ return mSource[SOURCE_SINK]->requestBuffer(pslot, outBuf);
+
VDS_LOGW_IF(mDbgState != DBG_STATE_GLES,
"Unexpected requestBuffer pslot=%d in %s state",
pslot, dbgStateStr());
@@ -275,6 +285,7 @@ status_t VirtualDisplaySurface::setBufferCount(int bufferCount) {
status_t VirtualDisplaySurface::dequeueBuffer(Source source,
uint32_t format, uint32_t usage, int* sslot, sp<Fence>* fence) {
+ LOG_FATAL_IF(mDisplayId < 0, "mDisplayId=%d but should not be < 0.", mDisplayId);
// Don't let a slow consumer block us
bool async = (source == SOURCE_SINK);
@@ -319,6 +330,9 @@ status_t VirtualDisplaySurface::dequeueBuffer(Source source,
status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool async,
uint32_t w, uint32_t h, uint32_t format, uint32_t usage) {
+ if (mDisplayId < 0)
+ return mSource[SOURCE_SINK]->dequeueBuffer(pslot, fence, async, w, h, format, usage);
+
VDS_LOGW_IF(mDbgState != DBG_STATE_PREPARED,
"Unexpected dequeueBuffer() in %s state", dbgStateStr());
mDbgState = DBG_STATE_GLES;
@@ -399,6 +413,9 @@ status_t VirtualDisplaySurface::attachBuffer(int* /* outSlot */,
status_t VirtualDisplaySurface::queueBuffer(int pslot,
const QueueBufferInput& input, QueueBufferOutput* output) {
+ if (mDisplayId < 0)
+ return mSource[SOURCE_SINK]->queueBuffer(pslot, input, output);
+
VDS_LOGW_IF(mDbgState != DBG_STATE_GLES,
"Unexpected queueBuffer(pslot=%d) in %s state", pslot,
dbgStateStr());
@@ -452,6 +469,9 @@ status_t VirtualDisplaySurface::queueBuffer(int pslot,
}
void VirtualDisplaySurface::cancelBuffer(int pslot, const sp<Fence>& fence) {
+ if (mDisplayId < 0)
+ return mSource[SOURCE_SINK]->cancelBuffer(mapProducer2SourceSlot(source, pslot), fence);
+
VDS_LOGW_IF(mDbgState != DBG_STATE_GLES,
"Unexpected cancelBuffer(pslot=%d) in %s state", pslot,
dbgStateStr());
@@ -462,7 +482,17 @@ void VirtualDisplaySurface::cancelBuffer(int pslot, const sp<Fence>& fence) {
}
int VirtualDisplaySurface::query(int what, int* value) {
- return mSource[SOURCE_SINK]->query(what, value);
+ switch (what) {
+ case NATIVE_WINDOW_WIDTH:
+ *value = mSinkBufferWidth;
+ break;
+ case NATIVE_WINDOW_HEIGHT:
+ *value = mSinkBufferHeight;
+ break;
+ default:
+ return mSource[SOURCE_SINK]->query(what, value);
+ }
+ return NO_ERROR;
}
status_t VirtualDisplaySurface::connect(const sp<IProducerListener>& listener,
@@ -501,8 +531,6 @@ void VirtualDisplaySurface::updateQueueBufferOutput(
void VirtualDisplaySurface::resetPerFrameState() {
mCompositionType = COMPOSITION_UNKNOWN;
- mSinkBufferWidth = 0;
- mSinkBufferHeight = 0;
mFbFence = Fence::NO_FENCE;
mOutputFence = Fence::NO_FENCE;
mOutputProducerSlot = -1;
diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
index 5c00ab4..363dce2 100644
--- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
+++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
@@ -87,6 +87,7 @@ public:
virtual status_t advanceFrame();
virtual void onFrameCommitted();
virtual void dump(String8& result) const;
+ virtual void resizeBuffers(const uint32_t w, const uint32_t h);
private:
enum Source {SOURCE_SINK = 0, SOURCE_SCRATCH = 1};
@@ -168,6 +169,10 @@ private:
// to the sink, we have to return the previous version.
QueueBufferOutput mQueueBufferOutput;
+ // Details of the current sink buffer. These become valid when a buffer is
+ // dequeued from the sink, and are used when queueing the buffer.
+ uint32_t mSinkBufferWidth, mSinkBufferHeight;
+
//
// Intra-frame state
//
@@ -176,10 +181,6 @@ private:
// Valid after prepareFrame(), cleared in onFrameCommitted.
CompositionType mCompositionType;
- // Details of the current sink buffer. These become valid when a buffer is
- // dequeued from the sink, and are used when queueing the buffer.
- uint32_t mSinkBufferWidth, mSinkBufferHeight;
-
// mFbFence is the fence HWC should wait for before reading the framebuffer
// target buffer.
sp<Fence> mFbFence;