surfaceflinger: remove BufferLayerConsumer::computeTransformMatrix
Use the one from GLConsumer.
Test: boots
Change-Id: I4b5c89d384878c2b721dd77607bd7317fb1cb6ca
diff --git a/services/surfaceflinger/BufferLayerConsumer.cpp b/services/surfaceflinger/BufferLayerConsumer.cpp
index 9ade402..482de16 100644
--- a/services/surfaceflinger/BufferLayerConsumer.cpp
+++ b/services/surfaceflinger/BufferLayerConsumer.cpp
@@ -416,84 +416,10 @@
BLC_LOGD("computeCurrentTransformMatrixLocked: "
"mCurrentTextureImage is NULL");
}
- computeTransformMatrix(mCurrentTransformMatrix, buf,
- isEglImageCroppable(mCurrentCrop) ? Rect::EMPTY_RECT : mCurrentCrop,
- mCurrentTransform, mFilteringEnabled);
-}
-
-void BufferLayerConsumer::computeTransformMatrix(float outTransform[16],
- const sp<GraphicBuffer>& buf, const Rect& cropRect,
- uint32_t transform, bool filtering) {
- // Transform matrices
- static const mat4 mtxFlipH(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1);
- static const mat4 mtxFlipV(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1);
- static const mat4 mtxRot90(0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1);
-
- mat4 xform;
- if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_H) {
- xform *= mtxFlipH;
- }
- if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_V) {
- xform *= mtxFlipV;
- }
- if (transform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
- xform *= mtxRot90;
- }
-
- if (!cropRect.isEmpty()) {
- float tx = 0.0f, ty = 0.0f, sx = 1.0f, sy = 1.0f;
- float bufferWidth = buf->getWidth();
- float bufferHeight = buf->getHeight();
- float shrinkAmount = 0.0f;
- if (filtering) {
- // In order to prevent bilinear sampling beyond the edge of the
- // crop rectangle we may need to shrink it by 2 texels in each
- // dimension. Normally this would just need to take 1/2 a texel
- // off each end, but because the chroma channels of YUV420 images
- // are subsampled we may need to shrink the crop region by a whole
- // texel on each side.
- switch (buf->getPixelFormat()) {
- case PIXEL_FORMAT_RGBA_8888:
- case PIXEL_FORMAT_RGBX_8888:
- case PIXEL_FORMAT_RGBA_FP16:
- case PIXEL_FORMAT_RGBA_1010102:
- case PIXEL_FORMAT_RGB_888:
- case PIXEL_FORMAT_RGB_565:
- case PIXEL_FORMAT_BGRA_8888:
- // We know there's no subsampling of any channels, so we
- // only need to shrink by a half a pixel.
- shrinkAmount = 0.5;
- break;
-
- default:
- // If we don't recognize the format, we must assume the
- // worst case (that we care about), which is YUV420.
- shrinkAmount = 1.0;
- break;
- }
- }
-
- // Only shrink the dimensions that are not the size of the buffer.
- if (cropRect.width() < bufferWidth) {
- tx = (float(cropRect.left) + shrinkAmount) / bufferWidth;
- sx = (float(cropRect.width()) - (2.0f * shrinkAmount)) / bufferWidth;
- }
- if (cropRect.height() < bufferHeight) {
- ty = (float(bufferHeight - cropRect.bottom) + shrinkAmount) / bufferHeight;
- sy = (float(cropRect.height()) - (2.0f * shrinkAmount)) / bufferHeight;
- }
-
- mat4 crop(sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, 1, 0, tx, ty, 0, 1);
- xform = crop * xform;
- }
-
- // SurfaceFlinger expects the top of its window textures to be at a Y
- // coordinate of 0, so BufferLayerConsumer must behave the same way. We don't
- // want to expose this to applications, however, so we must add an
- // additional vertical flip to the transform after all the other transforms.
- xform = mtxFlipV * xform;
-
- memcpy(outTransform, xform.asArray(), sizeof(xform));
+ GLConsumer::computeTransformMatrix(mCurrentTransformMatrix, buf,
+ isEglImageCroppable(mCurrentCrop) ? Rect::EMPTY_RECT
+ : mCurrentCrop,
+ mCurrentTransform, mFilteringEnabled);
}
Rect BufferLayerConsumer::scaleDownCrop(const Rect& crop, uint32_t bufferWidth,