libgui: Add plumbing for active rectangle
This change adds the plumbing to SurfaceTextureClient, BufferQueue, and
SurfaceTexture to get the active rectangle passed to the ANativeWindow to
the buffer consumer.
Change-Id: I35da0889b266327ebb079b6a7136fa3e2e8b00e6
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index 6c38cde..e7fac3d 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -170,6 +170,7 @@
mFrameNumber(0),
mBuf(INVALID_BUFFER_SLOT) {
mCrop.makeInvalid();
+ mActiveRect.makeInvalid();
}
// mGraphicBuffer points to the buffer allocated for this slot or is NULL
// if no buffer has been allocated.
@@ -191,9 +192,13 @@
// mFrameNumber is the number of the queued frame for this slot.
uint64_t mFrameNumber;
- // buf is the slot index of this buffer
+ // mBuf is the slot index of this buffer
int mBuf;
+ // mActiveRect is the active rectangle for the buffer. Pixels outside
+ // this rectangle are considered completely transparent for the purposes
+ // of window composition.
+ Rect mActiveRect;
};
// The following public functions is the consumer facing interface
@@ -297,6 +302,7 @@
mAcquireCalled(false),
mNeedsCleanupOnRelease(false) {
mCrop.makeInvalid();
+ mActiveRect.makeInvalid();
}
// mGraphicBuffer points to the buffer allocated for this slot or is NULL
@@ -353,6 +359,12 @@
// mCrop is the current crop rectangle for this buffer slot.
Rect mCrop;
+ // mActiveRect is the current active rectangle for this buffer slot.
+ // Pixels outside of this rectangle are to be treated as completely
+ // transparent during window composition. The rectangle is in buffer
+ // pixel coordinates.
+ Rect mActiveRect;
+
// mTransform is the current transform flags for this buffer slot.
uint32_t mTransform;
diff --git a/include/gui/ISurfaceTexture.h b/include/gui/ISurfaceTexture.h
index 1e33764..7abc7db 100644
--- a/include/gui/ISurfaceTexture.h
+++ b/include/gui/ISurfaceTexture.h
@@ -86,21 +86,25 @@
// QueueBufferInput must be a POD structure
struct QueueBufferInput {
inline QueueBufferInput(int64_t timestamp,
- const Rect& crop, int scalingMode, uint32_t transform)
+ const Rect& crop, int scalingMode, uint32_t transform,
+ const Rect& activeRect)
: timestamp(timestamp), crop(crop), scalingMode(scalingMode),
- transform(transform) { }
+ transform(transform), activeRect(activeRect) { }
inline void deflate(int64_t* outTimestamp, Rect* outCrop,
- int* outScalingMode, uint32_t* outTransform) const {
+ int* outScalingMode, uint32_t* outTransform,
+ Rect* outActiveRect) const {
*outTimestamp = timestamp;
*outCrop = crop;
*outScalingMode = scalingMode;
*outTransform = transform;
+ *outActiveRect = activeRect;
}
private:
int64_t timestamp;
Rect crop;
int scalingMode;
uint32_t transform;
+ Rect activeRect;
};
// QueueBufferOutput must be a POD structure
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index f4ed226..7540ed8 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -151,13 +151,16 @@
// texture as returned by updateTexImage().
GLenum getCurrentTextureTarget() const;
- // getCurrentCrop returns the cropping rectangle of the current buffer
+ // getCurrentCrop returns the cropping rectangle of the current buffer.
Rect getCurrentCrop() const;
- // getCurrentTransform returns the transform of the current buffer
+ // getCurrentActiveRect returns the active rectangle of the current buffer.
+ Rect getCurrentActiveRect() const;
+
+ // getCurrentTransform returns the transform of the current buffer.
uint32_t getCurrentTransform() const;
- // getCurrentScalingMode returns the scaling mode of the current buffer
+ // getCurrentScalingMode returns the scaling mode of the current buffer.
uint32_t getCurrentScalingMode() const;
// isSynchronousMode returns whether the SurfaceTexture is currently in
@@ -270,6 +273,12 @@
// It gets set each time updateTexImage is called.
Rect mCurrentCrop;
+ // mCurrentActiveRect is the active rectangle that applies to the current
+ // texture. It gets set each time updateTexImage is called. All pixels
+ // outside the active rectangle are be considered completely transparent for
+ // the purpose of window composition.
+ Rect mCurrentActiveRect;
+
// mCurrentTransform is the transform identifier for the current texture. It
// gets set each time updateTexImage is called.
uint32_t mCurrentTransform;
diff --git a/include/gui/SurfaceTextureClient.h b/include/gui/SurfaceTextureClient.h
index 7fd9be5..c4d4320 100644
--- a/include/gui/SurfaceTextureClient.h
+++ b/include/gui/SurfaceTextureClient.h
@@ -83,6 +83,7 @@
int dispatchSetUsage(va_list args);
int dispatchLock(va_list args);
int dispatchUnlockAndPost(va_list args);
+ int dispatchSetActiveRect(va_list args);
protected:
virtual int cancelBuffer(ANativeWindowBuffer* buffer);
@@ -106,6 +107,7 @@
virtual int setUsage(uint32_t reqUsage);
virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds);
virtual int unlockAndPost();
+ virtual int setActiveRect(Rect const* rect);
enum { NUM_BUFFER_SLOTS = BufferQueue::NUM_BUFFER_SLOTS };
enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 };
@@ -165,6 +167,10 @@
// buffer that gets queued. It is set by calling setTransform.
uint32_t mTransform;
+ // mActiveRect is the active rectangle that will be used for the next buffer
+ // that gets queued. It is set by calling setActiveRect.
+ Rect mActiveRect;
+
// mDefaultWidth is default width of the buffers, regardless of the
// native_window_set_buffers_dimensions call.
uint32_t mDefaultWidth;