Merge "Modify SensorDevice to use ISensorsWrapper"
diff --git a/cmds/installd/otapreopt_script.sh b/cmds/installd/otapreopt_script.sh
index 0c586b6..f950276 100644
--- a/cmds/installd/otapreopt_script.sh
+++ b/cmds/installd/otapreopt_script.sh
@@ -18,9 +18,6 @@
# This script will run as a postinstall step to drive otapreopt.
-# Temporarily disable for b/115853663.
-exit 0
-
TARGET_SLOT="$1"
STATUS_FD="$2"
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index 08fbfff..f99bc53 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -104,16 +104,13 @@
virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer,
Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- int32_t minLayerZ, int32_t maxLayerZ, bool useIdentityTransform,
- ISurfaceComposer::Rotation rotation) {
+ bool useIdentityTransform, ISurfaceComposer::Rotation rotation) {
Parcel data, reply;
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
data.writeStrongBinder(display);
data.write(sourceCrop);
data.writeUint32(reqWidth);
data.writeUint32(reqHeight);
- data.writeInt32(minLayerZ);
- data.writeInt32(maxLayerZ);
data.writeInt32(static_cast<int32_t>(useIdentityTransform));
data.writeInt32(static_cast<int32_t>(rotation));
status_t result = remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
@@ -653,13 +650,11 @@
data.read(sourceCrop);
uint32_t reqWidth = data.readUint32();
uint32_t reqHeight = data.readUint32();
- int32_t minLayerZ = data.readInt32();
- int32_t maxLayerZ = data.readInt32();
bool useIdentityTransform = static_cast<bool>(data.readInt32());
int32_t rotation = data.readInt32();
status_t res = captureScreen(display, &outBuffer, sourceCrop, reqWidth, reqHeight,
- minLayerZ, maxLayerZ, useIdentityTransform,
+ useIdentityTransform,
static_cast<ISurfaceComposer::Rotation>(rotation));
reply->writeInt32(res);
if (res == NO_ERROR) {
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 4caadd1..09ea0f6 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -876,13 +876,12 @@
// ----------------------------------------------------------------------------
status_t ScreenshotClient::capture(const sp<IBinder>& display, Rect sourceCrop, uint32_t reqWidth,
- uint32_t reqHeight, int32_t minLayerZ, int32_t maxLayerZ,
- bool useIdentityTransform, uint32_t rotation,
+ uint32_t reqHeight, bool useIdentityTransform, uint32_t rotation,
sp<GraphicBuffer>* outBuffer) {
sp<ISurfaceComposer> s(ComposerService::getComposerService());
if (s == nullptr) return NO_INIT;
- status_t ret = s->captureScreen(display, outBuffer, sourceCrop, reqWidth, reqHeight, minLayerZ,
- maxLayerZ, useIdentityTransform,
+ status_t ret = s->captureScreen(display, outBuffer, sourceCrop, reqWidth, reqHeight,
+ useIdentityTransform,
static_cast<ISurfaceComposer::Rotation>(rotation));
if (ret != NO_ERROR) {
return ret;
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index 46103c4..a55cfe0 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -193,8 +193,7 @@
*/
virtual status_t captureScreen(const sp<IBinder>& display, sp<GraphicBuffer>* outBuffer,
Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- int32_t minLayerZ, int32_t maxLayerZ, bool useIdentityTransform,
- Rotation rotation = eRotateNone) = 0;
+ bool useIdentityTransform, Rotation rotation = eRotateNone) = 0;
/**
* Capture a subtree of the layer hierarchy, potentially ignoring the root node.
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 662acc9..314b118 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -326,8 +326,7 @@
// if cropping isn't required, callers may pass in a default Rect, e.g.:
// capture(display, producer, Rect(), reqWidth, ...);
static status_t capture(const sp<IBinder>& display, Rect sourceCrop, uint32_t reqWidth,
- uint32_t reqHeight, int32_t minLayerZ, int32_t maxLayerZ,
- bool useIdentityTransform, uint32_t rotation,
+ uint32_t reqHeight, bool useIdentityTransform, uint32_t rotation,
sp<GraphicBuffer>* outBuffer);
static status_t captureLayers(const sp<IBinder>& layerHandle, Rect sourceCrop, float frameScale,
sp<GraphicBuffer>* outBuffer);
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index 243f27f..bc80899 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -135,7 +135,7 @@
ISurfaceComposer::eDisplayIdMain));
sp<GraphicBuffer> outBuffer;
ASSERT_EQ(NO_ERROR, sf->captureScreen(display, &outBuffer, Rect(),
- 64, 64, 0, 0x7fffffff, false));
+ 64, 64, false));
ASSERT_EQ(NO_ERROR, native_window_api_connect(anw.get(),
NATIVE_WINDOW_API_CPU));
@@ -166,7 +166,7 @@
ASSERT_EQ(NO_ERROR, anw->queueBuffer(anw.get(), buf, -1));
}
ASSERT_EQ(NO_ERROR, sf->captureScreen(display, &outBuffer, Rect(),
- 64, 64, 0, 0x7fffffff, false));
+ 64, 64, false));
}
TEST_F(SurfaceTest, ConcreteTypeIsSurface) {
@@ -599,7 +599,6 @@
status_t captureScreen(const sp<IBinder>& /*display*/,
sp<GraphicBuffer>* /*outBuffer*/,
Rect /*sourceCrop*/, uint32_t /*reqWidth*/, uint32_t /*reqHeight*/,
- int32_t /*minLayerZ*/, int32_t /*maxLayerZ*/,
bool /*useIdentityTransform*/,
Rotation /*rotation*/) override { return NO_ERROR; }
virtual status_t captureLayers(const sp<IBinder>& /*parentHandle*/,
diff --git a/services/surfaceflinger/Android.bp b/services/surfaceflinger/Android.bp
index e72aaca..744bdba 100644
--- a/services/surfaceflinger/Android.bp
+++ b/services/surfaceflinger/Android.bp
@@ -46,6 +46,7 @@
"libhwbinder",
"liblayers_proto",
"liblog",
+ "libnativewindow",
"libpdx_default_transport",
"libprotobuf-cpp-lite",
"libsync",
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 3eb0a92..4becfab 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -543,8 +543,8 @@
ANativeWindow* const window = mNativeWindow.get();
mSurface->setNativeWindow(window);
- mDisplayWidth = mSurface->queryWidth();
- mDisplayHeight = mSurface->queryHeight();
+ mDisplayWidth = mSurface->getWidth();
+ mDisplayHeight = mSurface->getHeight();
LOG_FATAL_IF(mDisplayWidth != newWidth,
"Unable to set new width to %d", newWidth);
diff --git a/services/surfaceflinger/RenderEngine/Android.bp b/services/surfaceflinger/RenderEngine/Android.bp
index e1ab066..79145c2 100644
--- a/services/surfaceflinger/RenderEngine/Android.bp
+++ b/services/surfaceflinger/RenderEngine/Android.bp
@@ -26,6 +26,7 @@
"libGLESv2",
"libgui",
"liblog",
+ "libnativewindow",
"libui",
"libutils",
],
diff --git a/services/surfaceflinger/RenderEngine/Description.cpp b/services/surfaceflinger/RenderEngine/Description.cpp
index b7522da..9696d28 100644
--- a/services/surfaceflinger/RenderEngine/Description.cpp
+++ b/services/surfaceflinger/RenderEngine/Description.cpp
@@ -23,76 +23,33 @@
namespace android {
namespace renderengine {
-void Description::setPremultipliedAlpha(bool premultipliedAlpha) {
- mPremultipliedAlpha = premultipliedAlpha;
-}
-
-void Description::setOpaque(bool opaque) {
- mOpaque = opaque;
-}
-
-void Description::setTexture(const Texture& texture) {
- mTexture = texture;
- mTextureEnabled = true;
-}
-
-void Description::disableTexture() {
- mTextureEnabled = false;
-}
-
-void Description::setColor(const half4& color) {
- mColor = color;
-}
-
-void Description::setProjectionMatrix(const mat4& mtx) {
- mProjectionMatrix = mtx;
-}
-
-void Description::setColorMatrix(const mat4& mtx) {
- mColorMatrix = mtx;
-}
-
-void Description::setInputTransformMatrix(const mat3& matrix) {
- mInputTransformMatrix = matrix;
-}
-
-void Description::setOutputTransformMatrix(const mat4& matrix) {
- mOutputTransformMatrix = matrix;
+Description::TransferFunction Description::dataSpaceToTransferFunction(ui::Dataspace dataSpace) {
+ ui::Dataspace transfer = static_cast<ui::Dataspace>(dataSpace & ui::Dataspace::TRANSFER_MASK);
+ switch (transfer) {
+ case ui::Dataspace::TRANSFER_ST2084:
+ return Description::TransferFunction::ST2084;
+ case ui::Dataspace::TRANSFER_HLG:
+ return Description::TransferFunction::HLG;
+ case ui::Dataspace::TRANSFER_LINEAR:
+ return Description::TransferFunction::LINEAR;
+ default:
+ return Description::TransferFunction::SRGB;
+ }
}
bool Description::hasInputTransformMatrix() const {
- const mat3 identity;
- return mInputTransformMatrix != identity;
+ const mat4 identity;
+ return inputTransformMatrix != identity;
}
bool Description::hasOutputTransformMatrix() const {
const mat4 identity;
- return mOutputTransformMatrix != identity;
+ return outputTransformMatrix != identity;
}
bool Description::hasColorMatrix() const {
const mat4 identity;
- return mColorMatrix != identity;
-}
-
-const mat4& Description::getColorMatrix() const {
- return mColorMatrix;
-}
-
-void Description::setY410BT2020(bool enable) {
- mY410BT2020 = enable;
-}
-
-void Description::setInputTransferFunction(TransferFunction transferFunction) {
- mInputTransferFunction = transferFunction;
-}
-
-void Description::setOutputTransferFunction(TransferFunction transferFunction) {
- mOutputTransferFunction = transferFunction;
-}
-
-void Description::setDisplayMaxLuminance(const float maxLuminance) {
- mDisplayMaxLuminance = maxLuminance;
+ return colorMatrix != identity;
}
} // namespace renderengine
diff --git a/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.cpp b/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.cpp
index 0f0ff62..813c9e6 100644
--- a/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.cpp
@@ -398,9 +398,9 @@
mDisplayP3ToSrgb = mat4(ColorSpaceConnector(displayP3, srgb).getTransform());
// no chromatic adaptation needed since all color spaces use D65 for their white points.
- mSrgbToXyz = srgb.getRGBtoXYZ();
- mDisplayP3ToXyz = displayP3.getRGBtoXYZ();
- mBt2020ToXyz = bt2020.getRGBtoXYZ();
+ mSrgbToXyz = mat4(srgb.getRGBtoXYZ());
+ mDisplayP3ToXyz = mat4(displayP3.getRGBtoXYZ());
+ mBt2020ToXyz = mat4(bt2020.getRGBtoXYZ());
mXyzToSrgb = mat4(srgb.getXYZtoRGB());
mXyzToDisplayP3 = mat4(displayP3.getXYZtoRGB());
mXyzToBt2020 = mat4(bt2020.getXYZtoRGB());
@@ -444,12 +444,17 @@
if (success && glSurface.getAsync()) {
eglSwapInterval(mEGLDisplay, 0);
}
+ if (success) {
+ mSurfaceHeight = glSurface.getHeight();
+ }
}
+
return success;
}
void GLES20RenderEngine::resetCurrentSurface() {
eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ mSurfaceHeight = 0;
}
base::unique_fd GLES20RenderEngine::flush() {
@@ -563,8 +568,12 @@
drawMesh(mesh);
}
-void GLES20RenderEngine::setScissor(uint32_t left, uint32_t bottom, uint32_t right, uint32_t top) {
- glScissor(left, bottom, right, top);
+void GLES20RenderEngine::setScissor(const Rect& region) {
+ // Invert y-coordinate to map to GL-space.
+ int32_t canvasHeight = mRenderToFbo ? mFboHeight : mSurfaceHeight;
+ int32_t glBottom = canvasHeight - region.bottom;
+
+ glScissor(region.left, glBottom, region.getWidth(), region.getHeight());
glEnable(GL_SCISSOR_TEST);
}
@@ -592,10 +601,6 @@
}
}
-void GLES20RenderEngine::readPixels(size_t l, size_t b, size_t w, size_t h, uint32_t* pixels) {
- glReadPixels(l, b, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-}
-
status_t GLES20RenderEngine::bindFrameBuffer(Framebuffer* framebuffer) {
GLFramebuffer* glFramebuffer = static_cast<GLFramebuffer*>(framebuffer);
EGLImageKHR eglImage = glFramebuffer->getEGLImage();
@@ -612,6 +617,7 @@
GL_TEXTURE_2D, textureName, 0);
mRenderToFbo = true;
+ mFboHeight = glFramebuffer->getBufferHeight();
uint32_t glStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
@@ -623,13 +629,14 @@
void GLES20RenderEngine::unbindFrameBuffer(Framebuffer* /* framebuffer */) {
mRenderToFbo = false;
+ mFboHeight = 0;
// back to main framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Workaround for b/77935566 to force the EGL driver to release the
// screenshot buffer
- setScissor(0, 0, 0, 0);
+ setScissor(Rect::EMPTY_RECT);
clearWithColor(0.0, 0.0, 0.0, 0.0);
disableScissor();
}
@@ -673,19 +680,19 @@
}
glViewport(0, 0, vpw, vph);
- mState.setProjectionMatrix(m);
+ mState.projectionMatrix = m;
mVpWidth = vpw;
mVpHeight = vph;
}
void GLES20RenderEngine::setupLayerBlending(bool premultipliedAlpha, bool opaque,
bool disableTexture, const half4& color) {
- mState.setPremultipliedAlpha(premultipliedAlpha);
- mState.setOpaque(opaque);
- mState.setColor(color);
+ mState.isPremultipliedAlpha = premultipliedAlpha;
+ mState.isOpaque = opaque;
+ mState.color = color;
if (disableTexture) {
- mState.disableTexture();
+ mState.textureEnabled = false;
}
if (color.a < 1.0f || !opaque) {
@@ -697,7 +704,7 @@
}
void GLES20RenderEngine::setSourceY410BT2020(bool enable) {
- mState.setY410BT2020(enable);
+ mState.isY410BT2020 = enable;
}
void GLES20RenderEngine::setSourceDataSpace(Dataspace source) {
@@ -709,7 +716,7 @@
}
void GLES20RenderEngine::setDisplayMaxLuminance(const float maxLuminance) {
- mState.setDisplayMaxLuminance(maxLuminance);
+ mState.displayMaxLuminance = maxLuminance;
}
void GLES20RenderEngine::setupLayerTexturing(const Texture& texture) {
@@ -724,22 +731,24 @@
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filter);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, filter);
- mState.setTexture(texture);
+ mState.texture = texture;
+ mState.textureEnabled = true;
}
void GLES20RenderEngine::setupLayerBlackedOut() {
glBindTexture(GL_TEXTURE_2D, mProtectedTexName);
Texture texture(Texture::TEXTURE_2D, mProtectedTexName);
texture.setDimensions(1, 1); // FIXME: we should get that from somewhere
- mState.setTexture(texture);
+ mState.texture = texture;
+ mState.textureEnabled = true;
}
void GLES20RenderEngine::setupColorTransform(const mat4& colorTransform) {
- mState.setColorMatrix(colorTransform);
+ mState.colorMatrix = colorTransform;
}
void GLES20RenderEngine::disableTexturing() {
- mState.disableTexture();
+ mState.textureEnabled = false;
}
void GLES20RenderEngine::disableBlending() {
@@ -747,10 +756,10 @@
}
void GLES20RenderEngine::setupFillWithColor(float r, float g, float b, float a) {
- mState.setPremultipliedAlpha(true);
- mState.setOpaque(false);
- mState.setColor(half4(r, g, b, a));
- mState.disableTexture();
+ mState.isPremultipliedAlpha = true;
+ mState.isOpaque = false;
+ mState.color = half4(r, g, b, a);
+ mState.textureEnabled = false;
glDisable(GL_BLEND);
}
@@ -784,26 +793,26 @@
// The supported input color spaces are standard RGB, Display P3 and BT2020.
switch (inputStandard) {
case Dataspace::STANDARD_DCI_P3:
- managedState.setInputTransformMatrix(mDisplayP3ToXyz);
+ managedState.inputTransformMatrix = mDisplayP3ToXyz;
break;
case Dataspace::STANDARD_BT2020:
- managedState.setInputTransformMatrix(mBt2020ToXyz);
+ managedState.inputTransformMatrix = mBt2020ToXyz;
break;
default:
- managedState.setInputTransformMatrix(mSrgbToXyz);
+ managedState.inputTransformMatrix = mSrgbToXyz;
break;
}
// The supported output color spaces are BT2020, Display P3 and standard RGB.
switch (outputStandard) {
case Dataspace::STANDARD_BT2020:
- managedState.setOutputTransformMatrix(mXyzToBt2020);
+ managedState.outputTransformMatrix = mXyzToBt2020;
break;
case Dataspace::STANDARD_DCI_P3:
- managedState.setOutputTransformMatrix(mXyzToDisplayP3);
+ managedState.outputTransformMatrix = mXyzToDisplayP3;
break;
default:
- managedState.setOutputTransformMatrix(mXyzToSrgb);
+ managedState.outputTransformMatrix = mXyzToSrgb;
break;
}
} else if (inputStandard != outputStandard) {
@@ -818,9 +827,9 @@
// - sRGB
// - Display P3
if (outputStandard == Dataspace::STANDARD_BT709) {
- managedState.setOutputTransformMatrix(mDisplayP3ToSrgb);
+ managedState.outputTransformMatrix = mDisplayP3ToSrgb;
} else if (outputStandard == Dataspace::STANDARD_DCI_P3) {
- managedState.setOutputTransformMatrix(mSrgbToDisplayP3);
+ managedState.outputTransformMatrix = mSrgbToDisplayP3;
}
}
@@ -830,32 +839,10 @@
// - the input transfer function doesn't match the output transfer function.
if (managedState.hasColorMatrix() || managedState.hasOutputTransformMatrix() ||
inputTransfer != outputTransfer) {
- switch (inputTransfer) {
- case Dataspace::TRANSFER_ST2084:
- managedState.setInputTransferFunction(Description::TransferFunction::ST2084);
- break;
- case Dataspace::TRANSFER_HLG:
- managedState.setInputTransferFunction(Description::TransferFunction::HLG);
- break;
- case Dataspace::TRANSFER_LINEAR:
- managedState.setInputTransferFunction(Description::TransferFunction::LINEAR);
- break;
- default:
- managedState.setInputTransferFunction(Description::TransferFunction::SRGB);
- break;
- }
-
- switch (outputTransfer) {
- case Dataspace::TRANSFER_ST2084:
- managedState.setOutputTransferFunction(Description::TransferFunction::ST2084);
- break;
- case Dataspace::TRANSFER_HLG:
- managedState.setOutputTransferFunction(Description::TransferFunction::HLG);
- break;
- default:
- managedState.setOutputTransferFunction(Description::TransferFunction::SRGB);
- break;
- }
+ managedState.inputTransferFunction =
+ Description::dataSpaceToTransferFunction(inputTransfer);
+ managedState.outputTransferFunction =
+ Description::dataSpaceToTransferFunction(outputTransfer);
}
ProgramCache::getInstance().useProgram(managedState);
diff --git a/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.h b/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.h
index 1abc5ba..fa01410 100644
--- a/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.h
+++ b/services/surfaceflinger/RenderEngine/gl/GLES20RenderEngine.h
@@ -64,12 +64,11 @@
void clearWithColor(float red, float green, float blue, float alpha) override;
void fillRegionWithColor(const Region& region, float red, float green, float blue,
float alpha) override;
- void setScissor(uint32_t left, uint32_t bottom, uint32_t right, uint32_t top) override;
+ void setScissor(const Rect& region) override;
void disableScissor() override;
void genTextures(size_t count, uint32_t* names) override;
void deleteTextures(size_t count, uint32_t const* names) override;
void bindExternalTextureImage(uint32_t texName, const Image& image) override;
- void readPixels(size_t l, size_t b, size_t w, size_t h, uint32_t* pixels) override;
status_t bindFrameBuffer(Framebuffer* framebuffer) override;
void unbindFrameBuffer(Framebuffer* framebuffer) override;
void checkErrors() const override;
@@ -131,14 +130,16 @@
mat4 mSrgbToDisplayP3;
mat4 mDisplayP3ToSrgb;
- mat3 mSrgbToXyz;
- mat3 mBt2020ToXyz;
- mat3 mDisplayP3ToXyz;
+ mat4 mSrgbToXyz;
+ mat4 mBt2020ToXyz;
+ mat4 mDisplayP3ToXyz;
mat4 mXyzToSrgb;
mat4 mXyzToDisplayP3;
mat4 mXyzToBt2020;
bool mRenderToFbo = false;
+ int32_t mSurfaceHeight = 0;
+ int32_t mFboHeight = 0;
// Current dataspace of layer being rendered
ui::Dataspace mDataSpace = ui::Dataspace::UNKNOWN;
diff --git a/services/surfaceflinger/RenderEngine/gl/GLFramebuffer.cpp b/services/surfaceflinger/RenderEngine/gl/GLFramebuffer.cpp
index 6aca1c8..83d2bde 100644
--- a/services/surfaceflinger/RenderEngine/gl/GLFramebuffer.cpp
+++ b/services/surfaceflinger/RenderEngine/gl/GLFramebuffer.cpp
@@ -20,6 +20,7 @@
#include <GLES/glext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
+#include <nativebase/nativebase.h>
#include "GLES20RenderEngine.h"
namespace android {
@@ -43,6 +44,8 @@
if (mEGLImage != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(mEGLDisplay, mEGLImage);
mEGLImage = EGL_NO_IMAGE_KHR;
+ mBufferWidth = 0;
+ mBufferHeight = 0;
}
if (nativeBuffer) {
@@ -52,6 +55,8 @@
if (mEGLImage == EGL_NO_IMAGE_KHR) {
return false;
}
+ mBufferWidth = nativeBuffer->width;
+ mBufferHeight = nativeBuffer->height;
}
return true;
}
diff --git a/services/surfaceflinger/RenderEngine/gl/GLFramebuffer.h b/services/surfaceflinger/RenderEngine/gl/GLFramebuffer.h
index 90b2248..193cbdc 100644
--- a/services/surfaceflinger/RenderEngine/gl/GLFramebuffer.h
+++ b/services/surfaceflinger/RenderEngine/gl/GLFramebuffer.h
@@ -39,11 +39,16 @@
EGLImageKHR getEGLImage() const { return mEGLImage; }
uint32_t getTextureName() const { return mTextureName; }
uint32_t getFramebufferName() const { return mFramebufferName; }
+ int32_t getBufferHeight() const { return mBufferHeight; }
+ int32_t getBufferWidth() const { return mBufferWidth; }
private:
EGLDisplay mEGLDisplay;
EGLImageKHR mEGLImage;
uint32_t mTextureName, mFramebufferName;
+
+ int32_t mBufferHeight = 0;
+ int32_t mBufferWidth = 0;
};
} // namespace gl
diff --git a/services/surfaceflinger/RenderEngine/gl/GLSurface.cpp b/services/surfaceflinger/RenderEngine/gl/GLSurface.cpp
index ff9a252..104af56 100644
--- a/services/surfaceflinger/RenderEngine/gl/GLSurface.cpp
+++ b/services/surfaceflinger/RenderEngine/gl/GLSurface.cpp
@@ -16,6 +16,7 @@
#include "GLSurface.h"
+#include <android/native_window.h>
#include <log/log.h>
#include <ui/PixelFormat.h>
#include "GLES20RenderEngine.h"
@@ -41,11 +42,15 @@
if (mEGLSurface != EGL_NO_SURFACE) {
eglDestroySurface(mEGLDisplay, mEGLSurface);
mEGLSurface = EGL_NO_SURFACE;
+ mSurfaceWidth = 0;
+ mSurfaceHeight = 0;
}
mWindow = window;
if (mWindow) {
mEGLSurface = eglCreateWindowSurface(mEGLDisplay, mEGLConfig, mWindow, nullptr);
+ mSurfaceWidth = ANativeWindow_getWidth(window);
+ mSurfaceHeight = ANativeWindow_getHeight(window);
}
}
@@ -71,15 +76,6 @@
return value;
}
-EGLint GLSurface::querySurface(EGLint attrib) const {
- EGLint value;
- if (!eglQuerySurface(mEGLDisplay, mEGLSurface, attrib, &value)) {
- value = 0;
- }
-
- return value;
-}
-
int32_t GLSurface::queryRedSize() const {
return queryConfig(EGL_RED_SIZE);
}
@@ -96,12 +92,12 @@
return queryConfig(EGL_ALPHA_SIZE);
}
-int32_t GLSurface::queryWidth() const {
- return querySurface(EGL_WIDTH);
+int32_t GLSurface::getWidth() const {
+ return mSurfaceWidth;
}
-int32_t GLSurface::queryHeight() const {
- return querySurface(EGL_HEIGHT);
+int32_t GLSurface::getHeight() const {
+ return mSurfaceHeight;
}
} // namespace gl
diff --git a/services/surfaceflinger/RenderEngine/gl/GLSurface.h b/services/surfaceflinger/RenderEngine/gl/GLSurface.h
index 0b89c70..8aa223a 100644
--- a/services/surfaceflinger/RenderEngine/gl/GLSurface.h
+++ b/services/surfaceflinger/RenderEngine/gl/GLSurface.h
@@ -47,15 +47,14 @@
int32_t queryBlueSize() const override;
int32_t queryAlphaSize() const override;
- int32_t queryWidth() const override;
- int32_t queryHeight() const override;
-
bool getAsync() const { return mAsync; }
EGLSurface getEGLSurface() const { return mEGLSurface; }
+ int32_t getWidth() const override;
+ int32_t getHeight() const override;
+
private:
EGLint queryConfig(EGLint attrib) const;
- EGLint querySurface(EGLint attrib) const;
EGLDisplay mEGLDisplay;
EGLConfig mEGLConfig;
@@ -63,6 +62,9 @@
bool mCritical = false;
bool mAsync = false;
+ int32_t mSurfaceWidth = 0;
+ int32_t mSurfaceHeight = 0;
+
ANativeWindow* mWindow = nullptr;
EGLSurface mEGLSurface = EGL_NO_SURFACE;
diff --git a/services/surfaceflinger/RenderEngine/gl/Program.cpp b/services/surfaceflinger/RenderEngine/gl/Program.cpp
index c8d6cf9..da67f92 100644
--- a/services/surfaceflinger/RenderEngine/gl/Program.cpp
+++ b/services/surfaceflinger/RenderEngine/gl/Program.cpp
@@ -129,28 +129,28 @@
if (mSamplerLoc >= 0) {
glUniform1i(mSamplerLoc, 0);
- glUniformMatrix4fv(mTextureMatrixLoc, 1, GL_FALSE, desc.mTexture.getMatrix().asArray());
+ glUniformMatrix4fv(mTextureMatrixLoc, 1, GL_FALSE, desc.texture.getMatrix().asArray());
}
if (mColorLoc >= 0) {
- const float color[4] = {desc.mColor.r, desc.mColor.g, desc.mColor.b, desc.mColor.a};
+ const float color[4] = {desc.color.r, desc.color.g, desc.color.b, desc.color.a};
glUniform4fv(mColorLoc, 1, color);
}
if (mInputTransformMatrixLoc >= 0) {
- mat4 inputTransformMatrix = mat4(desc.mInputTransformMatrix);
+ mat4 inputTransformMatrix = desc.inputTransformMatrix;
glUniformMatrix4fv(mInputTransformMatrixLoc, 1, GL_FALSE, inputTransformMatrix.asArray());
}
if (mOutputTransformMatrixLoc >= 0) {
// The output transform matrix and color matrix can be combined as one matrix
// that is applied right before applying OETF.
- mat4 outputTransformMatrix = desc.mColorMatrix * desc.mOutputTransformMatrix;
+ mat4 outputTransformMatrix = desc.colorMatrix * desc.outputTransformMatrix;
glUniformMatrix4fv(mOutputTransformMatrixLoc, 1, GL_FALSE,
outputTransformMatrix.asArray());
}
if (mDisplayMaxLuminanceLoc >= 0) {
- glUniform1f(mDisplayMaxLuminanceLoc, desc.mDisplayMaxLuminance);
+ glUniform1f(mDisplayMaxLuminanceLoc, desc.displayMaxLuminance) ;
}
// these uniforms are always present
- glUniformMatrix4fv(mProjectionMatrixLoc, 1, GL_FALSE, desc.mProjectionMatrix.asArray());
+ glUniformMatrix4fv(mProjectionMatrixLoc, 1, GL_FALSE, desc.projectionMatrix.asArray());
}
} // namespace gl
diff --git a/services/surfaceflinger/RenderEngine/gl/ProgramCache.cpp b/services/surfaceflinger/RenderEngine/gl/ProgramCache.cpp
index a19c1f1..9254aa0 100644
--- a/services/surfaceflinger/RenderEngine/gl/ProgramCache.cpp
+++ b/services/surfaceflinger/RenderEngine/gl/ProgramCache.cpp
@@ -130,19 +130,19 @@
ProgramCache::Key ProgramCache::computeKey(const Description& description) {
Key needs;
needs.set(Key::TEXTURE_MASK,
- !description.mTextureEnabled
+ !description.textureEnabled
? Key::TEXTURE_OFF
- : description.mTexture.getTextureTarget() == GL_TEXTURE_EXTERNAL_OES
+ : description.texture.getTextureTarget() == GL_TEXTURE_EXTERNAL_OES
? Key::TEXTURE_EXT
- : description.mTexture.getTextureTarget() == GL_TEXTURE_2D
+ : description.texture.getTextureTarget() == GL_TEXTURE_2D
? Key::TEXTURE_2D
: Key::TEXTURE_OFF)
.set(Key::ALPHA_MASK,
- (description.mColor.a < 1) ? Key::ALPHA_LT_ONE : Key::ALPHA_EQ_ONE)
+ (description.color.a < 1) ? Key::ALPHA_LT_ONE : Key::ALPHA_EQ_ONE)
.set(Key::BLEND_MASK,
- description.mPremultipliedAlpha ? Key::BLEND_PREMULT : Key::BLEND_NORMAL)
+ description.isPremultipliedAlpha ? Key::BLEND_PREMULT : Key::BLEND_NORMAL)
.set(Key::OPACITY_MASK,
- description.mOpaque ? Key::OPACITY_OPAQUE : Key::OPACITY_TRANSLUCENT)
+ description.isOpaque ? Key::OPACITY_OPAQUE : Key::OPACITY_TRANSLUCENT)
.set(Key::Key::INPUT_TRANSFORM_MATRIX_MASK,
description.hasInputTransformMatrix() ?
Key::INPUT_TRANSFORM_MATRIX_ON : Key::INPUT_TRANSFORM_MATRIX_OFF)
@@ -151,10 +151,10 @@
Key::OUTPUT_TRANSFORM_MATRIX_ON : Key::OUTPUT_TRANSFORM_MATRIX_OFF);
needs.set(Key::Y410_BT2020_MASK,
- description.mY410BT2020 ? Key::Y410_BT2020_ON : Key::Y410_BT2020_OFF);
+ description.isY410BT2020 ? Key::Y410_BT2020_ON : Key::Y410_BT2020_OFF);
if (needs.hasTransformMatrix() || (needs.getInputTF() != needs.getOutputTF())) {
- switch (description.mInputTransferFunction) {
+ switch (description.inputTransferFunction) {
case Description::TransferFunction::LINEAR:
default:
needs.set(Key::INPUT_TF_MASK, Key::INPUT_TF_LINEAR);
@@ -170,7 +170,7 @@
break;
}
- switch (description.mOutputTransferFunction) {
+ switch (description.outputTransferFunction) {
case Description::TransferFunction::LINEAR:
default:
needs.set(Key::OUTPUT_TF_MASK, Key::OUTPUT_TF_LINEAR);
diff --git a/services/surfaceflinger/RenderEngine/gl/ProgramCache.h b/services/surfaceflinger/RenderEngine/gl/ProgramCache.h
index ea77a2d..47963eb 100644
--- a/services/surfaceflinger/RenderEngine/gl/ProgramCache.h
+++ b/services/surfaceflinger/RenderEngine/gl/ProgramCache.h
@@ -29,7 +29,7 @@
namespace renderengine {
-class Description;
+struct Description;
namespace gl {
diff --git a/services/surfaceflinger/RenderEngine/include/renderengine/RenderEngine.h b/services/surfaceflinger/RenderEngine/include/renderengine/RenderEngine.h
index 17d8782..05668f8 100644
--- a/services/surfaceflinger/RenderEngine/include/renderengine/RenderEngine.h
+++ b/services/surfaceflinger/RenderEngine/include/renderengine/RenderEngine.h
@@ -96,12 +96,11 @@
virtual void fillRegionWithColor(const Region& region, float red, float green,
float blue, float alpha) = 0;
- virtual void setScissor(uint32_t left, uint32_t bottom, uint32_t right, uint32_t top) = 0;
+ virtual void setScissor(const Rect& region) = 0;
virtual void disableScissor() = 0;
virtual void genTextures(size_t count, uint32_t* names) = 0;
virtual void deleteTextures(size_t count, uint32_t const* names) = 0;
virtual void bindExternalTextureImage(uint32_t texName, const Image& image) = 0;
- virtual void readPixels(size_t l, size_t b, size_t w, size_t h, uint32_t* pixels) = 0;
// When binding a native buffer, it must be done before setViewportAndProjection
// Returns NO_ERROR when binds successfully, NO_MEMORY when there's no memory for allocation.
virtual status_t bindFrameBuffer(Framebuffer* framebuffer) = 0;
diff --git a/services/surfaceflinger/RenderEngine/include/renderengine/Surface.h b/services/surfaceflinger/RenderEngine/include/renderengine/Surface.h
index 3343e1f..3999ddc 100644
--- a/services/surfaceflinger/RenderEngine/include/renderengine/Surface.h
+++ b/services/surfaceflinger/RenderEngine/include/renderengine/Surface.h
@@ -38,8 +38,8 @@
virtual int32_t queryBlueSize() const = 0;
virtual int32_t queryAlphaSize() const = 0;
- virtual int32_t queryWidth() const = 0;
- virtual int32_t queryHeight() const = 0;
+ virtual int32_t getWidth() const = 0;
+ virtual int32_t getHeight() const = 0;
};
} // namespace renderengine
diff --git a/services/surfaceflinger/RenderEngine/include/renderengine/private/Description.h b/services/surfaceflinger/RenderEngine/include/renderengine/private/Description.h
index a6301ae..efab8ff 100644
--- a/services/surfaceflinger/RenderEngine/include/renderengine/private/Description.h
+++ b/services/surfaceflinger/RenderEngine/include/renderengine/private/Description.h
@@ -17,84 +17,60 @@
#ifndef SF_RENDER_ENGINE_DESCRIPTION_H_
#define SF_RENDER_ENGINE_DESCRIPTION_H_
+#include <ui/GraphicTypes.h>
#include <renderengine/Texture.h>
namespace android {
namespace renderengine {
-namespace gl {
-class Program;
-class ProgramCache;
-}
-
/*
- * This holds the state of the rendering engine. This class is used
- * to generate a corresponding GLSL program and set the appropriate
- * uniform.
- *
- * Program and ProgramCache are friends and access the state directly
+ * This is the structure that holds the state of the rendering engine.
+ * This class is used to generate a corresponding GLSL program and set the
+ * appropriate uniform.
*/
-class Description {
-public:
- Description() = default;
- ~Description() = default;
-
- void setPremultipliedAlpha(bool premultipliedAlpha);
- void setOpaque(bool opaque);
- void setTexture(const Texture& texture);
- void disableTexture();
- void setColor(const half4& color);
- void setProjectionMatrix(const mat4& mtx);
- void setColorMatrix(const mat4& mtx);
- void setInputTransformMatrix(const mat3& matrix);
- void setOutputTransformMatrix(const mat4& matrix);
- bool hasInputTransformMatrix() const;
- bool hasOutputTransformMatrix() const;
- bool hasColorMatrix() const;
- const mat4& getColorMatrix() const;
-
- void setY410BT2020(bool enable);
-
+struct Description {
enum class TransferFunction : int {
LINEAR,
SRGB,
ST2084,
HLG, // Hybrid Log-Gamma for HDR.
};
- void setInputTransferFunction(TransferFunction transferFunction);
- void setOutputTransferFunction(TransferFunction transferFunction);
- void setDisplayMaxLuminance(const float maxLuminance);
-private:
- friend class gl::Program;
- friend class gl::ProgramCache;
+ static TransferFunction dataSpaceToTransferFunction(ui::Dataspace dataSpace);
+
+ Description() = default;
+ ~Description() = default;
+
+ bool hasInputTransformMatrix() const;
+ bool hasOutputTransformMatrix() const;
+ bool hasColorMatrix() const;
// whether textures are premultiplied
- bool mPremultipliedAlpha = false;
+ bool isPremultipliedAlpha = false;
// whether this layer is marked as opaque
- bool mOpaque = true;
+ bool isOpaque = true;
// Texture this layer uses
- Texture mTexture;
- bool mTextureEnabled = false;
+ Texture texture;
+ bool textureEnabled = false;
// color used when texturing is disabled or when setting alpha.
- half4 mColor;
+ half4 color;
// true if the sampled pixel values are in Y410/BT2020 rather than RGBA
- bool mY410BT2020 = false;
+ bool isY410BT2020 = false;
// transfer functions for the input/output
- TransferFunction mInputTransferFunction = TransferFunction::LINEAR;
- TransferFunction mOutputTransferFunction = TransferFunction::LINEAR;
+ TransferFunction inputTransferFunction = TransferFunction::LINEAR;
+ TransferFunction outputTransferFunction = TransferFunction::LINEAR;
- float mDisplayMaxLuminance;
+ float displayMaxLuminance;
// projection matrix
- mat4 mProjectionMatrix;
- mat4 mColorMatrix;
- mat3 mInputTransformMatrix;
- mat4 mOutputTransformMatrix;
+ mat4 projectionMatrix;
+ mat4 colorMatrix;
+ mat4 inputTransformMatrix;
+ mat4 outputTransformMatrix;
};
} // namespace renderengine
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index f17710e..fa9cc79 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -103,12 +103,6 @@
#define DISPLAY_COUNT 1
-/*
- * DEBUG_SCREENSHOTS: set to true to check that screenshots are not all
- * black pixels.
- */
-#define DEBUG_SCREENSHOTS false
-
namespace android {
using namespace android::hardware::configstore;
@@ -2493,8 +2487,8 @@
renderSurface->setCritical(state.type == DisplayDevice::DISPLAY_PRIMARY);
renderSurface->setAsync(state.isVirtual());
renderSurface->setNativeWindow(nativeWindow.get());
- const int displayWidth = renderSurface->queryWidth();
- const int displayHeight = renderSurface->queryHeight();
+ const int displayWidth = renderSurface->getWidth();
+ const int displayHeight = renderSurface->getHeight();
// Make sure that composition can never be stalled by a virtual display
// consumer that isn't processing buffers fast enough. We have to do this
@@ -3205,9 +3199,7 @@
// the GL scissor so we don't draw anything where we shouldn't
// enable scissor for this frame
- const uint32_t height = display->getHeight();
- getBE().mRenderEngine->setScissor(scissor.left, height - scissor.bottom,
- scissor.getWidth(), scissor.getHeight());
+ getBE().mRenderEngine->setScissor(scissor);
}
}
@@ -4695,6 +4687,12 @@
result.append("\n");
/*
+ * Tracing state
+ */
+ mTracing.dump(result);
+ result.append("\n");
+
+ /*
* HWC layer minidump
*/
for (const auto& [token, display] : mDisplays) {
@@ -5083,12 +5081,12 @@
case 1025: { // Set layer tracing
n = data.readInt32();
if (n) {
- ALOGV("LayerTracing enabled");
+ ALOGD("LayerTracing enabled");
mTracing.enable();
doTracing("tracing.enable");
reply->writeInt32(NO_ERROR);
} else {
- ALOGV("LayerTracing disabled");
+ ALOGD("LayerTracing disabled");
status_t err = mTracing.disable();
reply->writeInt32(err);
}
@@ -5199,8 +5197,8 @@
status_t SurfaceFlinger::captureScreen(const sp<IBinder>& displayToken,
sp<GraphicBuffer>* outBuffer, Rect sourceCrop,
- uint32_t reqWidth, uint32_t reqHeight, int32_t minLayerZ,
- int32_t maxLayerZ, bool useIdentityTransform,
+ uint32_t reqWidth, uint32_t reqHeight,
+ bool useIdentityTransform,
ISurfaceComposer::Rotation rotation) {
ATRACE_CALL();
@@ -5230,7 +5228,7 @@
DisplayRenderArea renderArea(display, sourceCrop, reqWidth, reqHeight, renderAreaRotation);
auto traverseLayers = std::bind(std::mem_fn(&SurfaceFlinger::traverseLayersInDisplay), this,
- display, minLayerZ, maxLayerZ, std::placeholders::_1);
+ display, std::placeholders::_1);
return captureScreenCommon(renderArea, traverseLayers, outBuffer, useIdentityTransform);
}
@@ -5506,51 +5504,15 @@
// dependent on the context's EGLConfig.
renderScreenImplLocked(renderArea, traverseLayers, useIdentityTransform);
- if (DEBUG_SCREENSHOTS) {
+ base::unique_fd syncFd = getRenderEngine().flush();
+ if (syncFd < 0) {
getRenderEngine().finish();
- *outSyncFd = -1;
-
- const auto reqWidth = renderArea.getReqWidth();
- const auto reqHeight = renderArea.getReqHeight();
-
- uint32_t* pixels = new uint32_t[reqWidth*reqHeight];
- getRenderEngine().readPixels(0, 0, reqWidth, reqHeight, pixels);
- checkScreenshot(reqWidth, reqHeight, reqWidth, pixels, traverseLayers);
- delete [] pixels;
- } else {
- base::unique_fd syncFd = getRenderEngine().flush();
- if (syncFd < 0) {
- getRenderEngine().finish();
- }
- *outSyncFd = syncFd.release();
}
+ *outSyncFd = syncFd.release();
return NO_ERROR;
}
-void SurfaceFlinger::checkScreenshot(size_t w, size_t s, size_t h, void const* vaddr,
- TraverseLayersFunction traverseLayers) {
- if (DEBUG_SCREENSHOTS) {
- for (size_t y = 0; y < h; y++) {
- uint32_t const* p = (uint32_t const*)vaddr + y * s;
- for (size_t x = 0; x < w; x++) {
- if (p[x] != 0xFF000000) return;
- }
- }
- ALOGE("*** we just took a black screenshot ***");
-
- size_t i = 0;
- traverseLayers([&](Layer* layer) {
- const Layer::State& state(layer->getDrawingState());
- ALOGE("%c index=%zu, name=%s, layerStack=%d, z=%d, visible=%d, flags=%x, alpha=%.3f",
- layer->isVisible() ? '+' : '-', i, layer->getName().string(),
- layer->getLayerStack(), state.z, layer->isVisible(), state.flags,
- static_cast<float>(state.color.a));
- i++;
- });
- }
-}
-
// ---------------------------------------------------------------------------
void SurfaceFlinger::State::traverseInZOrder(const LayerVector::Visitor& visitor) const {
@@ -5562,19 +5524,14 @@
}
void SurfaceFlinger::traverseLayersInDisplay(const sp<const DisplayDevice>& display,
- int32_t minLayerZ, int32_t maxLayerZ,
const LayerVector::Visitor& visitor) {
// We loop through the first level of layers without traversing,
- // as we need to interpret min/max layer Z in the top level Z space.
+ // as we need to determine which layers belong to the requested display.
for (const auto& layer : mDrawingState.layersSortedByZ) {
if (!layer->belongsToDisplay(display->getLayerStack(), false)) {
continue;
}
- const Layer::State& state(layer->getDrawingState());
// relative layers are traversed in Layer::traverseInZOrder
- if (state.zOrderRelativeOf != nullptr || state.z < minLayerZ || state.z > maxLayerZ) {
- continue;
- }
layer->traverseInZOrder(LayerVector::StateSet::Drawing, [&](Layer* layer) {
if (!layer->belongsToDisplay(display->getLayerStack(), false)) {
return;
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 00ee2c4..01d18d9 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -439,8 +439,7 @@
ISurfaceComposer::VsyncSource vsyncSource = eVsyncSourceApp);
virtual status_t captureScreen(const sp<IBinder>& displayToken, sp<GraphicBuffer>* outBuffer,
Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- int32_t minLayerZ, int32_t maxLayerZ, bool useIdentityTransform,
- ISurfaceComposer::Rotation rotation);
+ bool useIdentityTransform, ISurfaceComposer::Rotation rotation);
virtual status_t captureLayers(const sp<IBinder>& parentHandle, sp<GraphicBuffer>* outBuffer,
const Rect& sourceCrop, float frameScale, bool childrenOnly);
virtual status_t getDisplayStats(const sp<IBinder>& displayToken, DisplayStatInfo* stats);
@@ -599,8 +598,8 @@
TraverseLayersFunction traverseLayers,
ANativeWindowBuffer* buffer, bool useIdentityTransform,
bool forSystem, int* outSyncFd);
- void traverseLayersInDisplay(const sp<const DisplayDevice>& display, int32_t minLayerZ,
- int32_t maxLayerZ, const LayerVector::Visitor& visitor);
+ void traverseLayersInDisplay(const sp<const DisplayDevice>& display,
+ const LayerVector::Visitor& visitor);
sp<StartPropertySetThread> mStartPropertySetThread = nullptr;
@@ -756,8 +755,6 @@
void dumpAllLocked(const Vector<String16>& args, size_t& index, String8& result) const;
bool startDdmConnection();
void appendSfConfigString(String8& result) const;
- void checkScreenshot(size_t w, size_t s, size_t h, void const* vaddr,
- TraverseLayersFunction traverseLayers);
void logFrameStats();
diff --git a/services/surfaceflinger/SurfaceTracing.cpp b/services/surfaceflinger/SurfaceTracing.cpp
index 0e9b04e..370b3b8 100644
--- a/services/surfaceflinger/SurfaceTracing.cpp
+++ b/services/surfaceflinger/SurfaceTracing.cpp
@@ -52,7 +52,7 @@
return err;
}
-bool SurfaceTracing::isEnabled() {
+bool SurfaceTracing::isEnabled() const {
return mEnabled;
}
@@ -65,6 +65,15 @@
entry->set_elapsed_realtime_nanos(elapsedRealtimeNano());
entry->set_where(where);
entry->mutable_layers()->Swap(&layers);
+
+ constexpr int maxBufferedEntryCount = 3600;
+ if (mTrace.entry_size() >= maxBufferedEntryCount) {
+ // TODO: flush buffered entries without disabling tracing
+ ALOGE("too many buffered frames; force disable tracing");
+ mEnabled = false;
+ writeProtoFileLocked();
+ mTrace.Clear();
+ }
}
status_t SurfaceTracing::writeProtoFileLocked() {
@@ -84,4 +93,11 @@
return NO_ERROR;
}
+void SurfaceTracing::dump(String8& result) const {
+ std::lock_guard<std::mutex> protoGuard(mTraceMutex);
+
+ result.appendFormat("Tracing state: %s\n", mEnabled ? "enabled" : "disabled");
+ result.appendFormat(" number of entries: %d\n", mTrace.entry_size());
+}
+
} // namespace android
diff --git a/services/surfaceflinger/SurfaceTracing.h b/services/surfaceflinger/SurfaceTracing.h
index 590ab96..27e2c9e 100644
--- a/services/surfaceflinger/SurfaceTracing.h
+++ b/services/surfaceflinger/SurfaceTracing.h
@@ -18,6 +18,7 @@
#include <layerproto/LayerProtoHeader.h>
#include <utils/Errors.h>
+#include <utils/String8.h>
#include <mutex>
@@ -32,9 +33,10 @@
public:
void enable();
status_t disable();
- bool isEnabled();
+ bool isEnabled() const;
void traceLayers(const char* where, LayersProto);
+ void dump(String8& result) const;
private:
static constexpr auto DEFAULT_FILENAME = "/data/misc/wmtrace/layers_trace.pb";
@@ -43,7 +45,7 @@
bool mEnabled = false;
std::string mOutputFileName = DEFAULT_FILENAME;
- std::mutex mTraceMutex;
+ mutable std::mutex mTraceMutex;
LayersTraceFileProto mTrace;
};
diff --git a/services/surfaceflinger/tests/Credentials_test.cpp b/services/surfaceflinger/tests/Credentials_test.cpp
index 8e23eb8e..9e762f0 100644
--- a/services/surfaceflinger/tests/Credentials_test.cpp
+++ b/services/surfaceflinger/tests/Credentials_test.cpp
@@ -23,8 +23,6 @@
namespace {
const String8 DISPLAY_NAME("Credentials Display Test");
const String8 SURFACE_NAME("Test Surface Name");
-const int32_t MIN_LAYER_Z = 0;
-const int32_t MAX_LAYER_Z = std::numeric_limits<int32_t>::max();
const uint32_t ROTATION = 0;
const float FRAME_SCALE = 1.0f;
} // namespace
@@ -269,8 +267,8 @@
sp<IBinder> display(SurfaceComposerClient::getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
std::function<status_t()> condition = [=]() {
sp<GraphicBuffer> outBuffer;
- return ScreenshotClient::capture(display, Rect(), 0 /*reqWidth*/, 0 /*reqHeight*/,
- MIN_LAYER_Z, MAX_LAYER_Z, false, ROTATION, &outBuffer);
+ return ScreenshotClient::capture(display, Rect(), 0 /*reqWidth*/, 0 /*reqHeight*/, false,
+ ROTATION, &outBuffer);
};
ASSERT_NO_FATAL_FAILURE(checkWithPrivileges<status_t>(condition, NO_ERROR, PERMISSION_DENIED));
}
diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp
index ed1529b..3af98e5 100644
--- a/services/surfaceflinger/tests/Transaction_test.cpp
+++ b/services/surfaceflinger/tests/Transaction_test.cpp
@@ -186,17 +186,15 @@
// individual pixel values for testing purposes.
class ScreenCapture : public RefBase {
public:
- static void captureScreen(sp<ScreenCapture>* sc, int32_t minLayerZ = 0,
- int32_t maxLayerZ = std::numeric_limits<int32_t>::max()) {
+ static void captureScreen(std::unique_ptr<ScreenCapture>* sc) {
sp<ISurfaceComposer> sf(ComposerService::getComposerService());
sp<IBinder> display(sf->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
SurfaceComposerClient::Transaction().apply(true);
sp<GraphicBuffer> outBuffer;
ASSERT_EQ(NO_ERROR,
- sf->captureScreen(display, &outBuffer, Rect(), 0, 0, minLayerZ, maxLayerZ,
- false));
- *sc = new ScreenCapture(outBuffer);
+ sf->captureScreen(display, &outBuffer, Rect(), 0, 0, false));
+ *sc = std::make_unique<ScreenCapture>(outBuffer);
}
static void captureLayers(std::unique_ptr<ScreenCapture>* sc, sp<IBinder>& parentHandle,
@@ -318,6 +316,12 @@
ASSERT_NO_FATAL_FAILURE(SetUpDisplay());
}
+ virtual void TearDown() {
+ mBlackBgSurface = 0;
+ mClient->dispose();
+ mClient = 0;
+ }
+
virtual sp<SurfaceControl> createLayer(const char* name, uint32_t width, uint32_t height,
uint32_t flags = 0) {
auto layer =
@@ -445,9 +449,9 @@
Transaction().setBuffer(layer, buffer).setSize(layer, bufferWidth, bufferHeight).apply();
}
- sp<ScreenCapture> screenshot() {
- sp<ScreenCapture> screenshot;
- ScreenCapture::captureScreen(&screenshot, mLayerZBase);
+ std::unique_ptr<ScreenCapture> screenshot() {
+ std::unique_ptr<ScreenCapture> screenshot;
+ ScreenCapture::captureScreen(&screenshot);
return screenshot;
}
@@ -465,6 +469,7 @@
void setSizeBasicHelper(uint32_t layerType);
void setMatrixWithResizeHelper(uint32_t layerType);
+ sp<SurfaceControl> mBlackBgSurface;
private:
void SetUpDisplay() {
mDisplay = mClient->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain);
@@ -482,13 +487,26 @@
mBufferPostDelay = int32_t(1e6 / info.fps) * 3;
mDisplayLayerStack = 0;
+
+ mBlackBgSurface = mClient->createSurface(String8("BaseSurface"), mDisplayWidth,
+ mDisplayHeight, PIXEL_FORMAT_RGBA_8888,
+ ISurfaceComposerClient::eFXSurfaceColor);
+
// set layer stack (b/68888219)
Transaction t;
t.setDisplayLayerStack(mDisplay, mDisplayLayerStack);
+ t.setLayerStack(mBlackBgSurface, mDisplayLayerStack);
+ t.setColor(mBlackBgSurface, half3{0, 0, 0});
+ t.setLayer(mBlackBgSurface, mLayerZBase);
t.apply();
}
- void waitForLayerBuffers() { usleep(mBufferPostDelay); }
+ void waitForLayerBuffers() {
+ // Request an empty transaction to get applied synchronously to ensure the buffer is
+ // latched.
+ Transaction().apply(true);
+ usleep(mBufferPostDelay);
+ }
int32_t mBufferPostDelay;
};
@@ -793,6 +811,9 @@
}
TEST_P(LayerTypeTransactionTest, SetZNegative) {
+ sp<SurfaceControl> parent =
+ LayerTransactionTest::createLayer("Parent", mDisplayWidth, mDisplayHeight,
+ ISurfaceComposerClient::eFXSurfaceContainer);
sp<SurfaceControl> layerR;
sp<SurfaceControl> layerG;
ASSERT_NO_FATAL_FAILURE(layerR = createLayer("test R", 32, 32));
@@ -800,20 +821,22 @@
ASSERT_NO_FATAL_FAILURE(layerG = createLayer("test G", 32, 32));
ASSERT_NO_FATAL_FAILURE(fillLayerColor(layerG, Color::GREEN, 32, 32));
+ Transaction()
+ .reparent(layerR, parent->getHandle())
+ .reparent(layerG, parent->getHandle())
+ .apply();
Transaction().setLayer(layerR, -1).setLayer(layerG, -2).apply();
{
SCOPED_TRACE("layerR");
- sp<ScreenCapture> screenshot;
- ScreenCapture::captureScreen(&screenshot, -2, -1);
- screenshot->expectColor(Rect(0, 0, 32, 32), Color::RED);
+ auto shot = screenshot();
+ shot->expectColor(Rect(0, 0, 32, 32), Color::RED);
}
Transaction().setLayer(layerR, -3).apply();
{
SCOPED_TRACE("layerG");
- sp<ScreenCapture> screenshot;
- ScreenCapture::captureScreen(&screenshot, -3, -1);
- screenshot->expectColor(Rect(0, 0, 32, 32), Color::GREEN);
+ auto shot = screenshot();
+ shot->expectColor(Rect(0, 0, 32, 32), Color::GREEN);
}
}
@@ -846,6 +869,9 @@
}
TEST_P(LayerTypeTransactionTest, SetRelativeZNegative) {
+ sp<SurfaceControl> parent =
+ LayerTransactionTest::createLayer("Parent", mDisplayWidth, mDisplayHeight,
+ ISurfaceComposerClient::eFXSurfaceContainer);
sp<SurfaceControl> layerR;
sp<SurfaceControl> layerG;
sp<SurfaceControl> layerB;
@@ -856,12 +882,17 @@
ASSERT_NO_FATAL_FAILURE(layerB = createLayer("test B", 32, 32));
ASSERT_NO_FATAL_FAILURE(fillLayerColor(layerB, Color::BLUE, 32, 32));
+ Transaction()
+ .reparent(layerB, parent->getHandle())
+ .apply();
+
// layerR = mLayerZBase, layerG = layerR - 1, layerB = -2
Transaction().setRelativeLayer(layerG, layerR->getHandle(), -1).setLayer(layerB, -2).apply();
- sp<ScreenCapture> screenshot;
+ std::unique_ptr<ScreenCapture> screenshot;
// only layerB is in this range
- ScreenCapture::captureScreen(&screenshot, -2, -1);
+ sp<IBinder> parentHandle = parent->getHandle();
+ ScreenCapture::captureLayers(&screenshot, parentHandle);
screenshot->expectColor(Rect(0, 0, 32, 32), Color::BLUE);
}
@@ -1006,13 +1037,11 @@
.setFlags(layer, layer_state_t::eLayerSecure, layer_state_t::eLayerSecure)
.apply(true);
ASSERT_EQ(PERMISSION_DENIED,
- composer->captureScreen(mDisplay, &outBuffer, Rect(), 0, 0, mLayerZBase, mLayerZBase,
- false));
+ composer->captureScreen(mDisplay, &outBuffer, Rect(), 0, 0, false));
Transaction().setFlags(layer, 0, layer_state_t::eLayerSecure).apply(true);
ASSERT_EQ(NO_ERROR,
- composer->captureScreen(mDisplay, &outBuffer, Rect(), 0, 0, mLayerZBase, mLayerZBase,
- false));
+ composer->captureScreen(mDisplay, &outBuffer, Rect(), 0, 0, false));
}
TEST_F(LayerTransactionTest, SetTransparentRegionHintBasic_BufferQueue) {
@@ -2038,8 +2067,8 @@
class LayerUpdateTest : public LayerTransactionTest {
protected:
virtual void SetUp() {
- mComposerClient = new SurfaceComposerClient;
- ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
+ LayerTransactionTest::SetUp();
+ ASSERT_EQ(NO_ERROR, mClient->initCheck());
sp<IBinder> display(
SurfaceComposerClient::getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
@@ -2050,24 +2079,22 @@
ssize_t displayHeight = info.h;
// Background surface
- mBGSurfaceControl =
- mComposerClient->createSurface(String8("BG Test Surface"), displayWidth,
- displayHeight, PIXEL_FORMAT_RGBA_8888, 0);
+ mBGSurfaceControl = createLayer(String8("BG Test Surface"), displayWidth,
+ displayHeight, 0);
ASSERT_TRUE(mBGSurfaceControl != nullptr);
ASSERT_TRUE(mBGSurfaceControl->isValid());
fillSurfaceRGBA8(mBGSurfaceControl, 63, 63, 195);
// Foreground surface
- mFGSurfaceControl = mComposerClient->createSurface(String8("FG Test Surface"), 64, 64,
- PIXEL_FORMAT_RGBA_8888, 0);
+ mFGSurfaceControl = createLayer(String8("FG Test Surface"), 64, 64, 0);
+
ASSERT_TRUE(mFGSurfaceControl != nullptr);
ASSERT_TRUE(mFGSurfaceControl->isValid());
fillSurfaceRGBA8(mFGSurfaceControl, 195, 63, 63);
// Synchronization surface
- mSyncSurfaceControl = mComposerClient->createSurface(String8("Sync Test Surface"), 1, 1,
- PIXEL_FORMAT_RGBA_8888, 0);
+ mSyncSurfaceControl = createLayer(String8("Sync Test Surface"), 1, 1, 0);
ASSERT_TRUE(mSyncSurfaceControl != nullptr);
ASSERT_TRUE(mSyncSurfaceControl->isValid());
@@ -2089,11 +2116,10 @@
}
virtual void TearDown() {
- mComposerClient->dispose();
+ LayerTransactionTest::TearDown();
mBGSurfaceControl = 0;
mFGSurfaceControl = 0;
mSyncSurfaceControl = 0;
- mComposerClient = 0;
}
void waitForPostedBuffers() {
@@ -2112,7 +2138,6 @@
t.apply(true);
}
- sp<SurfaceComposerClient> mComposerClient;
sp<SurfaceControl> mBGSurfaceControl;
sp<SurfaceControl> mFGSurfaceControl;
@@ -2122,10 +2147,10 @@
};
TEST_F(LayerUpdateTest, RelativesAreNotDetached) {
- sp<ScreenCapture> sc;
- sp<SurfaceControl> relative = mComposerClient->createSurface(String8("relativeTestSurface"), 10,
- 10, PIXEL_FORMAT_RGBA_8888, 0);
+ std::unique_ptr<ScreenCapture> sc;
+
+ sp<SurfaceControl> relative = createLayer(String8("relativeTestSurface"), 10, 10, 0);
fillSurfaceRGBA8(relative, 10, 10, 10);
waitForPostedBuffers();
@@ -2188,7 +2213,7 @@
EXPECT_INITIAL_STATE("After restoring initial state");
}
- sp<ScreenCapture> sc;
+ std::unique_ptr<ScreenCapture> sc;
};
class CropLatchingTest : public GeometryLatchingTest {
@@ -2213,7 +2238,7 @@
};
TEST_F(LayerUpdateTest, DeferredTransactionTest) {
- sp<ScreenCapture> sc;
+ std::unique_ptr<ScreenCapture> sc;
{
SCOPED_TRACE("before anything");
ScreenCapture::captureScreen(&sc);
@@ -2268,13 +2293,13 @@
}
TEST_F(LayerUpdateTest, LayerWithNoBuffersResizesImmediately) {
- sp<ScreenCapture> sc;
+ std::unique_ptr<ScreenCapture> sc;
sp<SurfaceControl> childNoBuffer =
- mComposerClient->createSurface(String8("Bufferless child"), 10, 10,
+ mClient->createSurface(String8("Bufferless child"), 10, 10,
PIXEL_FORMAT_RGBA_8888, 0, mFGSurfaceControl.get());
sp<SurfaceControl> childBuffer =
- mComposerClient->createSurface(String8("Buffered child"), 20, 20,
+ mClient->createSurface(String8("Buffered child"), 20, 20,
PIXEL_FORMAT_RGBA_8888, 0, childNoBuffer.get());
fillSurfaceRGBA8(childBuffer, 200, 200, 200);
@@ -2296,7 +2321,7 @@
}
TEST_F(LayerUpdateTest, MergingTransactions) {
- sp<ScreenCapture> sc;
+ std::unique_ptr<ScreenCapture> sc;
{
SCOPED_TRACE("before move");
ScreenCapture::captureScreen(&sc);
@@ -2323,13 +2348,13 @@
protected:
void SetUp() override {
LayerUpdateTest::SetUp();
- mChild = mComposerClient->createSurface(String8("Child surface"), 10, 10,
+ mChild = mClient->createSurface(String8("Child surface"), 10, 10,
PIXEL_FORMAT_RGBA_8888, 0, mFGSurfaceControl.get());
fillSurfaceRGBA8(mChild, 200, 200, 200);
{
SCOPED_TRACE("before anything");
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
mCapture->expectChildColor(64, 64);
}
}
@@ -2339,7 +2364,7 @@
}
sp<SurfaceControl> mChild;
- sp<ScreenCapture> mCapture;
+ std::unique_ptr<ScreenCapture> mCapture;
};
TEST_F(ChildLayerTest, ChildLayerPositioning) {
@@ -2350,7 +2375,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Top left of foreground must now be visible
mCapture->expectFGColor(64, 64);
// But 10 pixels in we should see the child surface
@@ -2362,7 +2387,7 @@
asTransaction([&](Transaction& t) { t.setPosition(mFGSurfaceControl, 0, 0); });
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Top left of foreground should now be at 0, 0
mCapture->expectFGColor(0, 0);
// But 10 pixels in we should see the child surface
@@ -2381,7 +2406,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
mCapture->expectChildColor(0, 0);
mCapture->expectChildColor(4, 4);
mCapture->expectBGColor(5, 5);
@@ -2396,7 +2421,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
mCapture->expectFGColor(0, 0);
// Last pixel in foreground should now be the child.
mCapture->expectChildColor(63, 63);
@@ -2411,7 +2436,7 @@
// Find the boundary between the parent and child
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
mCapture->expectChildColor(9, 9);
mCapture->expectFGColor(10, 10);
}
@@ -2421,7 +2446,7 @@
// The boundary should be twice as far from the origin now.
// The pixels from the last test should all be child now
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
mCapture->expectChildColor(9, 9);
mCapture->expectChildColor(10, 10);
mCapture->expectChildColor(19, 19);
@@ -2442,7 +2467,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Unblended child color
mCapture->checkPixel(0, 0, 0, 254, 0);
}
@@ -2450,7 +2475,7 @@
asTransaction([&](Transaction& t) { t.setAlpha(mChild, 0.5); });
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Child and BG blended.
mCapture->checkPixel(0, 0, 127, 127, 0);
}
@@ -2458,7 +2483,7 @@
asTransaction([&](Transaction& t) { t.setAlpha(mFGSurfaceControl, 0.5); });
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Child and BG blended.
mCapture->checkPixel(0, 0, 95, 64, 95);
}
@@ -2472,7 +2497,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Top left of foreground must now be visible
mCapture->expectFGColor(64, 64);
// But 10 pixels in we should see the child surface
@@ -2486,7 +2511,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
mCapture->expectFGColor(64, 64);
// In reparenting we should have exposed the entire foreground surface.
mCapture->expectFGColor(74, 74);
@@ -2505,7 +2530,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Top left of foreground must now be visible
mCapture->expectFGColor(64, 64);
// But 10 pixels in we should see the child surface
@@ -2514,6 +2539,7 @@
mCapture->expectFGColor(84, 84);
}
+
asTransaction([&](Transaction& t) { t.detachChildren(mFGSurfaceControl); });
asTransaction([&](Transaction& t) { t.hide(mChild); });
@@ -2521,7 +2547,7 @@
// Since the child has the same client as the parent, it will not get
// detached and will be hidden.
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
mCapture->expectFGColor(64, 64);
mCapture->expectFGColor(74, 74);
mCapture->expectFGColor(84, 84);
@@ -2547,7 +2573,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Top left of foreground must now be visible
mCapture->expectFGColor(64, 64);
// But 10 pixels in we should see the child surface
@@ -2562,7 +2588,7 @@
// Nothing should have changed.
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
mCapture->expectFGColor(64, 64);
mCapture->expectChildColor(74, 74);
mCapture->expectFGColor(84, 84);
@@ -2577,7 +2603,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// We've positioned the child in the top left.
mCapture->expectChildColor(0, 0);
// But it's only 10x10.
@@ -2591,7 +2617,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// We've positioned the child in the top left.
mCapture->expectChildColor(0, 0);
mCapture->expectChildColor(10, 10);
@@ -2610,7 +2636,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// We've positioned the child in the top left.
mCapture->expectChildColor(0, 0);
// But it's only 10x10.
@@ -2629,7 +2655,7 @@
{
// The child should still be in the same place and not have any strange scaling as in
// b/37673612.
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
mCapture->expectChildColor(0, 0);
mCapture->expectFGColor(10, 10);
}
@@ -2640,7 +2666,7 @@
mChild.clear();
// Now recreate it as hidden
- mChild = mComposerClient->createSurface(String8("Child surface"), 10, 10,
+ mChild = mClient->createSurface(String8("Child surface"), 10, 10,
PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eHidden,
mFGSurfaceControl.get());
@@ -2674,7 +2700,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Top left of foreground must now be visible
mCapture->expectFGColor(64, 64);
// But 10 pixels in we should see the child surface
@@ -2686,7 +2712,7 @@
asTransaction([&](Transaction& t) { t.reparent(mChild, mBGSurfaceControl->getHandle()); });
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
mCapture->expectFGColor(64, 64);
// In reparenting we should have exposed the entire foreground surface.
mCapture->expectFGColor(74, 74);
@@ -2705,7 +2731,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Top left of foreground must now be visible
mCapture->expectFGColor(64, 64);
// But 10 pixels in we should see the child surface
@@ -2715,7 +2741,7 @@
}
asTransaction([&](Transaction& t) { t.reparent(mChild, nullptr); });
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Nothing should have changed.
mCapture->expectFGColor(64, 64);
mCapture->expectChildColor(74, 74);
@@ -2724,8 +2750,7 @@
}
TEST_F(ChildLayerTest, ReparentFromNoParent) {
- sp<SurfaceControl> newSurface = mComposerClient->createSurface(String8("New Surface"), 10, 10,
- PIXEL_FORMAT_RGBA_8888, 0);
+ sp<SurfaceControl> newSurface = createLayer(String8("New Surface"), 10, 10, 0);
ASSERT_TRUE(newSurface != nullptr);
ASSERT_TRUE(newSurface->isValid());
@@ -2739,7 +2764,7 @@
});
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Top left of foreground must now be visible
mCapture->expectFGColor(64, 64);
// At 10, 10 we should see the new surface
@@ -2749,7 +2774,7 @@
asTransaction([&](Transaction& t) { t.reparent(newSurface, mFGSurfaceControl->getHandle()); });
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// newSurface will now be a child of mFGSurface so it will be 10, 10 offset from
// mFGSurface, putting it at 74, 74.
mCapture->expectFGColor(64, 64);
@@ -2760,12 +2785,12 @@
TEST_F(ChildLayerTest, NestedChildren) {
sp<SurfaceControl> grandchild =
- mComposerClient->createSurface(String8("Grandchild surface"), 10, 10,
+ mClient->createSurface(String8("Grandchild surface"), 10, 10,
PIXEL_FORMAT_RGBA_8888, 0, mChild.get());
fillSurfaceRGBA8(grandchild, 50, 50, 50);
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
// Expect the grandchild to begin at 64, 64 because it's a child of mChild layer
// which begins at 64, 64
mCapture->checkPixel(64, 64, 50, 50, 50);
@@ -2773,8 +2798,7 @@
}
TEST_F(ChildLayerTest, ChildLayerRelativeLayer) {
- sp<SurfaceControl> relative = mComposerClient->createSurface(String8("Relative surface"), 128,
- 128, PIXEL_FORMAT_RGBA_8888, 0);
+ sp<SurfaceControl> relative = createLayer(String8("Relative surface"), 128, 128, 0);
fillSurfaceRGBA8(relative, 255, 255, 255);
Transaction t;
@@ -2786,7 +2810,7 @@
// We expect that the child should have been elevated above our
// INT_MAX layer even though it's not a child of it.
{
- ScreenCapture::captureScreen(&mCapture);
+ mCapture = screenshot();
mCapture->expectChildColor(0, 0);
mCapture->expectChildColor(9, 9);
mCapture->checkPixel(10, 10, 255, 255, 255);
@@ -2810,7 +2834,7 @@
auto fgHandle = mFGSurfaceControl->getHandle();
sp<SurfaceControl> child =
- mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
+ mClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
0, mFGSurfaceControl.get());
fillSurfaceRGBA8(child, 200, 200, 200);
@@ -2826,7 +2850,7 @@
auto fgHandle = mFGSurfaceControl->getHandle();
sp<SurfaceControl> child =
- mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
+ mClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
0, mFGSurfaceControl.get());
fillSurfaceRGBA8(child, 200, 200, 200);
@@ -2840,7 +2864,7 @@
TEST_F(ScreenCaptureTest, CaptureTransparent) {
sp<SurfaceControl> child =
- mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
+ mClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
0, mFGSurfaceControl.get());
fillSurfaceRGBA8(child, 200, 200, 200);
@@ -2860,10 +2884,9 @@
auto fgHandle = mFGSurfaceControl->getHandle();
sp<SurfaceControl> child =
- mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
+ mClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
0, mFGSurfaceControl.get());
- sp<SurfaceControl> relative = mComposerClient->createSurface(String8("Relative surface"), 10,
- 10, PIXEL_FORMAT_RGBA_8888, 0);
+ sp<SurfaceControl> relative = createLayer(String8("Relative surface"), 10, 10, 0);
fillSurfaceRGBA8(child, 200, 200, 200);
fillSurfaceRGBA8(relative, 100, 100, 100);
@@ -2884,10 +2907,10 @@
auto fgHandle = mFGSurfaceControl->getHandle();
sp<SurfaceControl> child =
- mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
+ mClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
0, mFGSurfaceControl.get());
sp<SurfaceControl> relative =
- mComposerClient->createSurface(String8("Relative surface"), 10, 10,
+ mClient->createSurface(String8("Relative surface"), 10, 10,
PIXEL_FORMAT_RGBA_8888, 0, mFGSurfaceControl.get());
fillSurfaceRGBA8(child, 200, 200, 200);
fillSurfaceRGBA8(relative, 100, 100, 100);
@@ -2918,7 +2941,7 @@
LayerUpdateTest::SetUp();
mChild =
- mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
+ mClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
0, mFGSurfaceControl.get());
fillSurfaceRGBA8(mChild, 200, 200, 200);
@@ -2976,12 +2999,12 @@
auto fgHandle = mFGSurfaceControl->getHandle();
sp<SurfaceControl> child =
- mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
+ mClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
0, mFGSurfaceControl.get());
fillSurfaceRGBA8(child, 200, 200, 200);
sp<SurfaceControl> grandchild =
- mComposerClient->createSurface(String8("Grandchild surface"), 5, 5,
+ mClient->createSurface(String8("Grandchild surface"), 5, 5,
PIXEL_FORMAT_RGBA_8888, 0, child.get());
fillSurfaceRGBA8(grandchild, 50, 50, 50);
@@ -3000,7 +3023,7 @@
TEST_F(ScreenCaptureTest, CaptureChildOnly) {
sp<SurfaceControl> child =
- mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
+ mClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
0, mFGSurfaceControl.get());
fillSurfaceRGBA8(child, 200, 200, 200);
auto childHandle = child->getHandle();
@@ -3015,13 +3038,13 @@
TEST_F(ScreenCaptureTest, CaptureGrandchildOnly) {
sp<SurfaceControl> child =
- mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
+ mClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888,
0, mFGSurfaceControl.get());
fillSurfaceRGBA8(child, 200, 200, 200);
auto childHandle = child->getHandle();
sp<SurfaceControl> grandchild =
- mComposerClient->createSurface(String8("Grandchild surface"), 5, 5,
+ mClient->createSurface(String8("Grandchild surface"), 5, 5,
PIXEL_FORMAT_RGBA_8888, 0, child.get());
fillSurfaceRGBA8(grandchild, 50, 50, 50);
@@ -3040,10 +3063,9 @@
}
TEST_F(ScreenCaptureTest, CaptureCrop) {
- sp<SurfaceControl> redLayer = mComposerClient->createSurface(String8("Red surface"), 60, 60,
- PIXEL_FORMAT_RGBA_8888, 0);
+ sp<SurfaceControl> redLayer = createLayer(String8("Red surface"), 60, 60, 0);
sp<SurfaceControl> blueLayer =
- mComposerClient->createSurface(String8("Blue surface"), 30, 30, PIXEL_FORMAT_RGBA_8888,
+ mClient->createSurface(String8("Blue surface"), 30, 30, PIXEL_FORMAT_RGBA_8888,
0, redLayer.get());
ASSERT_NO_FATAL_FAILURE(fillBufferQueueLayerColor(redLayer, Color::RED, 60, 60));
@@ -3074,10 +3096,9 @@
}
TEST_F(ScreenCaptureTest, CaptureSize) {
- sp<SurfaceControl> redLayer = mComposerClient->createSurface(String8("Red surface"), 60, 60,
- PIXEL_FORMAT_RGBA_8888, 0);
+ sp<SurfaceControl> redLayer = createLayer(String8("Red surface"), 60, 60, 0);
sp<SurfaceControl> blueLayer =
- mComposerClient->createSurface(String8("Blue surface"), 30, 30, PIXEL_FORMAT_RGBA_8888,
+ mClient->createSurface(String8("Blue surface"), 30, 30, PIXEL_FORMAT_RGBA_8888,
0, redLayer.get());
ASSERT_NO_FATAL_FAILURE(fillBufferQueueLayerColor(redLayer, Color::RED, 60, 60));
@@ -3110,13 +3131,12 @@
}
TEST_F(ScreenCaptureTest, CaptureInvalidLayer) {
- sp<SurfaceControl> redLayer = mComposerClient->createSurface(String8("Red surface"), 60, 60,
- PIXEL_FORMAT_RGBA_8888, 0);
+ sp<SurfaceControl> redLayer = createLayer(String8("Red surface"), 60, 60, 0);
ASSERT_NO_FATAL_FAILURE(fillBufferQueueLayerColor(redLayer, Color::RED, 60, 60));
auto redLayerHandle = redLayer->getHandle();
- mComposerClient->destroySurface(redLayerHandle);
+ mClient->destroySurface(redLayerHandle);
SurfaceComposerClient::Transaction().apply(true);
sp<GraphicBuffer> outBuffer;
diff --git a/services/surfaceflinger/tests/unittests/CompositionTest.cpp b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
index 5aa6e27..d52f0d8 100644
--- a/services/surfaceflinger/tests/unittests/CompositionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
@@ -185,8 +185,6 @@
LayerCase::setupForScreenCapture(this);
const Rect sourceCrop(0, 0, DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT);
- constexpr int32_t minLayerZ = -1;
- constexpr int32_t maxLayerZ = 1000;
constexpr bool useIdentityTransform = true;
constexpr bool forSystem = true;
@@ -194,7 +192,7 @@
DEFAULT_DISPLAY_HEIGHT, ui::Transform::ROT_0);
auto traverseLayers = [this](const LayerVector::Visitor& visitor) {
- return mFlinger.traverseLayersInDisplay(mDisplay, minLayerZ, maxLayerZ, visitor);
+ return mFlinger.traverseLayersInDisplay(mDisplay, visitor);
};
// TODO: Eliminate expensive/real allocation if possible.
diff --git a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
index aa377af..cc46043 100644
--- a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
@@ -284,8 +284,8 @@
EXPECT_CALL(*test->mRenderSurface, setAsync(static_cast<bool>(ASYNC))).Times(1);
EXPECT_CALL(*test->mRenderSurface, setCritical(static_cast<bool>(CRITICAL))).Times(1);
EXPECT_CALL(*test->mRenderSurface, setNativeWindow(test->mNativeWindow.get())).Times(1);
- EXPECT_CALL(*test->mRenderSurface, queryWidth()).WillOnce(Return(WIDTH));
- EXPECT_CALL(*test->mRenderSurface, queryHeight()).WillOnce(Return(HEIGHT));
+ EXPECT_CALL(*test->mRenderSurface, getWidth()).WillOnce(Return(WIDTH));
+ EXPECT_CALL(*test->mRenderSurface, getHeight()).WillOnce(Return(HEIGHT));
}
static void setupFramebufferConsumerBufferQueueCallExpectations(DisplayTransactionTest* test) {
@@ -1757,8 +1757,8 @@
EXPECT_CALL(*renderSurface, setNativeWindow(nullptr)).Times(1);
EXPECT_CALL(*displaySurface, resizeBuffers(newWidth, oldHeight)).Times(1);
EXPECT_CALL(*renderSurface, setNativeWindow(nativeWindow)).Times(1);
- EXPECT_CALL(*renderSurface, queryWidth()).WillOnce(Return(newWidth));
- EXPECT_CALL(*renderSurface, queryHeight()).WillOnce(Return(oldHeight));
+ EXPECT_CALL(*renderSurface, getWidth()).WillOnce(Return(newWidth));
+ EXPECT_CALL(*renderSurface, getHeight()).WillOnce(Return(oldHeight));
// --------------------------------------------------------------------
// Invocation
@@ -1798,8 +1798,8 @@
EXPECT_CALL(*renderSurface, setNativeWindow(nullptr)).Times(1);
EXPECT_CALL(*displaySurface, resizeBuffers(oldWidth, newHeight)).Times(1);
EXPECT_CALL(*renderSurface, setNativeWindow(nativeWindow)).Times(1);
- EXPECT_CALL(*renderSurface, queryWidth()).WillOnce(Return(oldWidth));
- EXPECT_CALL(*renderSurface, queryHeight()).WillOnce(Return(newHeight));
+ EXPECT_CALL(*renderSurface, getWidth()).WillOnce(Return(oldWidth));
+ EXPECT_CALL(*renderSurface, getHeight()).WillOnce(Return(newHeight));
// --------------------------------------------------------------------
// Invocation
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index 341734c..f367275 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -121,10 +121,9 @@
useIdentityTransform, forSystem, outSyncFd);
}
- auto traverseLayersInDisplay(const sp<const DisplayDevice>& display, int32_t minLayerZ,
- int32_t maxLayerZ, const LayerVector::Visitor& visitor) {
- return mFlinger->SurfaceFlinger::traverseLayersInDisplay(display, minLayerZ, maxLayerZ,
- visitor);
+ auto traverseLayersInDisplay(const sp<const DisplayDevice>& display,
+ const LayerVector::Visitor& visitor) {
+ return mFlinger->SurfaceFlinger::traverseLayersInDisplay(display, visitor);
}
/* ------------------------------------------------------------------------
diff --git a/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h b/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h
index 39ed622..c29452c 100644
--- a/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h
+++ b/services/surfaceflinger/tests/unittests/mock/RenderEngine/MockRenderEngine.h
@@ -50,12 +50,11 @@
bool waitFence(base::unique_fd fd) override { return waitFence(&fd); };
MOCK_METHOD4(clearWithColor, void(float, float, float, float));
MOCK_METHOD5(fillRegionWithColor, void(const Region&, float, float, float, float));
- MOCK_METHOD4(setScissor, void(uint32_t, uint32_t, uint32_t, uint32_t));
+ MOCK_METHOD1(setScissor, void(const Rect&));
MOCK_METHOD0(disableScissor, void());
MOCK_METHOD2(genTextures, void(size_t, uint32_t*));
MOCK_METHOD2(deleteTextures, void(size_t, uint32_t const*));
MOCK_METHOD2(bindExternalTextureImage, void(uint32_t, const renderengine::Image&));
- MOCK_METHOD5(readPixels, void(size_t, size_t, size_t, size_t, uint32_t*));
MOCK_CONST_METHOD0(checkErrors, void());
MOCK_METHOD4(setViewportAndProjection,
void(size_t, size_t, Rect, ui::Transform::orientation_flags));
@@ -91,8 +90,8 @@
MOCK_CONST_METHOD0(queryGreenSize, int32_t());
MOCK_CONST_METHOD0(queryBlueSize, int32_t());
MOCK_CONST_METHOD0(queryAlphaSize, int32_t());
- MOCK_CONST_METHOD0(queryWidth, int32_t());
- MOCK_CONST_METHOD0(queryHeight, int32_t());
+ MOCK_CONST_METHOD0(getWidth, int32_t());
+ MOCK_CONST_METHOD0(getHeight, int32_t());
};
class Image : public renderengine::Image {
diff --git a/services/vr/performanced/task.cpp b/services/vr/performanced/task.cpp
index c2f078e..bda1682 100644
--- a/services/vr/performanced/task.cpp
+++ b/services/vr/performanced/task.cpp
@@ -115,7 +115,7 @@
std::istream file_stream(&filebuf);
for (std::string line; std::getline(file_stream, line);) {
- auto offset = line.find(":");
+ auto offset = line.find(':');
if (offset == std::string::npos) {
ALOGW("ReadStatusFields: Failed to find delimiter \":\" in line=\"%s\"",
line.c_str());