libgui: Add support for post-xform crops.
This change adds support for specifying a crop rectangle to a
SurfaceTextureClient that is in post-transformed coordinate space.
Change-Id: I247901de343e71b32850f7ae3bac62dfa612ad3d
Bug: 6299171
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index e7fac3d..1c80d0c 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -170,7 +170,6 @@
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.
@@ -194,11 +193,6 @@
// 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
@@ -302,7 +296,6 @@
mAcquireCalled(false),
mNeedsCleanupOnRelease(false) {
mCrop.makeInvalid();
- mActiveRect.makeInvalid();
}
// mGraphicBuffer points to the buffer allocated for this slot or is NULL
@@ -359,12 +352,6 @@
// 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 7abc7db..1e33764 100644
--- a/include/gui/ISurfaceTexture.h
+++ b/include/gui/ISurfaceTexture.h
@@ -86,25 +86,21 @@
// QueueBufferInput must be a POD structure
struct QueueBufferInput {
inline QueueBufferInput(int64_t timestamp,
- const Rect& crop, int scalingMode, uint32_t transform,
- const Rect& activeRect)
+ const Rect& crop, int scalingMode, uint32_t transform)
: timestamp(timestamp), crop(crop), scalingMode(scalingMode),
- transform(transform), activeRect(activeRect) { }
+ transform(transform) { }
inline void deflate(int64_t* outTimestamp, Rect* outCrop,
- int* outScalingMode, uint32_t* outTransform,
- Rect* outActiveRect) const {
+ int* outScalingMode, uint32_t* outTransform) 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 7540ed8..91cba76 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -154,9 +154,6 @@
// getCurrentCrop returns the cropping rectangle of the current buffer.
Rect getCurrentCrop() const;
- // getCurrentActiveRect returns the active rectangle of the current buffer.
- Rect getCurrentActiveRect() const;
-
// getCurrentTransform returns the transform of the current buffer.
uint32_t getCurrentTransform() const;
@@ -273,12 +270,6 @@
// 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 c4d4320..b11d572 100644
--- a/include/gui/SurfaceTextureClient.h
+++ b/include/gui/SurfaceTextureClient.h
@@ -80,10 +80,10 @@
int dispatchSetBuffersTransform(va_list args);
int dispatchSetBuffersTimestamp(va_list args);
int dispatchSetCrop(va_list args);
+ int dispatchSetPostTransformCrop(va_list args);
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);
@@ -104,10 +104,10 @@
virtual int setBuffersTransform(int transform);
virtual int setBuffersTimestamp(int64_t timestamp);
virtual int setCrop(Rect const* rect);
+ virtual int setPostTransformCrop(Rect const* rect);
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 };
@@ -159,6 +159,13 @@
// that gets queued. It is set by calling setCrop.
Rect mCrop;
+ // mCropNeedsTransform indicates whether mCrop is in post-transform
+ // coordinates and must be transformed using the inverse of mTransform
+ // before being queued with a buffer. Otherwise the crop is passed
+ // untransformed. It is initialized to false, is set to true by
+ // setPostTransformCrop, and set to false by setCrop.
+ bool mCropNeedsTransform;
+
// mScalingMode is the scaling mode that will be used for the next
// buffers that get queued. It is set by calling setScalingMode.
int mScalingMode;
@@ -167,10 +174,6 @@
// 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;