Loading services/surfaceflinger/CompositionEngine/include/compositionengine/RenderSurface.h +3 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,9 @@ public: // Returns the bounds of the surface virtual const ui::Size& getSize() const = 0; // Returns whether the surface is protected. virtual bool isProtected() const = 0; // Gets the latest fence to pass to the HWC to signal that the surface // buffer is done rendering virtual const sp<Fence>& getClientTargetAcquireFence() const = 0; Loading services/surfaceflinger/CompositionEngine/include/compositionengine/impl/RenderSurface.h +2 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ public: bool isValid() const override; void initialize() override; const ui::Size& getSize() const override; bool isProtected() const override { return mProtected; } const sp<Fence>& getClientTargetAcquireFence() const override; void setBufferDataspace(ui::Dataspace) override; Loading Loading @@ -78,6 +79,7 @@ private: sp<GraphicBuffer> mGraphicBuffer; const sp<DisplaySurface> mDisplaySurface; ui::Size mSize; bool mProtected{false}; std::uint32_t mPageFlipCount{0}; }; Loading services/surfaceflinger/CompositionEngine/include/compositionengine/mock/RenderSurface.h +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ public: MOCK_CONST_METHOD0(isValid, bool()); MOCK_METHOD0(initialize, void()); MOCK_CONST_METHOD0(getSize, const ui::Size&()); MOCK_CONST_METHOD0(isProtected, bool()); MOCK_CONST_METHOD0(getClientTargetAcquireFence, const sp<Fence>&()); MOCK_METHOD1(setDisplaySize, void(const ui::Size&)); MOCK_METHOD1(setProtected, void(bool)); Loading services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,9 @@ void RenderSurface::setProtected(bool useProtected) { } const int status = native_window_set_usage(mNativeWindow.get(), usageFlags); ALOGE_IF(status != NO_ERROR, "Unable to set BQ usage bits for protected content: %d", status); if (status == NO_ERROR) { mProtected = useProtected; } } status_t RenderSurface::beginFrame(bool mustRecompose) { Loading services/surfaceflinger/CompositionEngine/tests/RenderSurfaceTest.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -143,16 +143,40 @@ TEST_F(RenderSurfaceTest, setBufferDataspaceAppliesChange) { */ TEST_F(RenderSurfaceTest, setProtectedTrueEnablesProtection) { EXPECT_FALSE(mSurface.isProtected()); EXPECT_CALL(*mNativeWindow, setUsage(GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_PROTECTED)) .WillOnce(Return(NO_ERROR)); mSurface.setProtected(true); EXPECT_TRUE(mSurface.isProtected()); } TEST_F(RenderSurfaceTest, setProtectedFalseDisablesProtection) { EXPECT_FALSE(mSurface.isProtected()); EXPECT_CALL(*mNativeWindow, setUsage(GRALLOC_USAGE_HW_RENDER)).WillOnce(Return(NO_ERROR)); mSurface.setProtected(false); EXPECT_FALSE(mSurface.isProtected()); } TEST_F(RenderSurfaceTest, setProtectedEnableAndDisable) { EXPECT_FALSE(mSurface.isProtected()); EXPECT_CALL(*mNativeWindow, setUsage(GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_PROTECTED)) .WillOnce(Return(NO_ERROR)); EXPECT_CALL(*mNativeWindow, setUsage(GRALLOC_USAGE_HW_RENDER)).WillOnce(Return(NO_ERROR)); mSurface.setProtected(true); EXPECT_TRUE(mSurface.isProtected()); mSurface.setProtected(false); EXPECT_FALSE(mSurface.isProtected()); } TEST_F(RenderSurfaceTest, setProtectedEnableWithError) { EXPECT_FALSE(mSurface.isProtected()); EXPECT_CALL(*mNativeWindow, setUsage(GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_PROTECTED)) .WillOnce(Return(INVALID_OPERATION)); mSurface.setProtected(true); EXPECT_FALSE(mSurface.isProtected()); } /* ------------------------------------------------------------------------ Loading Loading
services/surfaceflinger/CompositionEngine/include/compositionengine/RenderSurface.h +3 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,9 @@ public: // Returns the bounds of the surface virtual const ui::Size& getSize() const = 0; // Returns whether the surface is protected. virtual bool isProtected() const = 0; // Gets the latest fence to pass to the HWC to signal that the surface // buffer is done rendering virtual const sp<Fence>& getClientTargetAcquireFence() const = 0; Loading
services/surfaceflinger/CompositionEngine/include/compositionengine/impl/RenderSurface.h +2 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ public: bool isValid() const override; void initialize() override; const ui::Size& getSize() const override; bool isProtected() const override { return mProtected; } const sp<Fence>& getClientTargetAcquireFence() const override; void setBufferDataspace(ui::Dataspace) override; Loading Loading @@ -78,6 +79,7 @@ private: sp<GraphicBuffer> mGraphicBuffer; const sp<DisplaySurface> mDisplaySurface; ui::Size mSize; bool mProtected{false}; std::uint32_t mPageFlipCount{0}; }; Loading
services/surfaceflinger/CompositionEngine/include/compositionengine/mock/RenderSurface.h +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ public: MOCK_CONST_METHOD0(isValid, bool()); MOCK_METHOD0(initialize, void()); MOCK_CONST_METHOD0(getSize, const ui::Size&()); MOCK_CONST_METHOD0(isProtected, bool()); MOCK_CONST_METHOD0(getClientTargetAcquireFence, const sp<Fence>&()); MOCK_METHOD1(setDisplaySize, void(const ui::Size&)); MOCK_METHOD1(setProtected, void(bool)); Loading
services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,9 @@ void RenderSurface::setProtected(bool useProtected) { } const int status = native_window_set_usage(mNativeWindow.get(), usageFlags); ALOGE_IF(status != NO_ERROR, "Unable to set BQ usage bits for protected content: %d", status); if (status == NO_ERROR) { mProtected = useProtected; } } status_t RenderSurface::beginFrame(bool mustRecompose) { Loading
services/surfaceflinger/CompositionEngine/tests/RenderSurfaceTest.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -143,16 +143,40 @@ TEST_F(RenderSurfaceTest, setBufferDataspaceAppliesChange) { */ TEST_F(RenderSurfaceTest, setProtectedTrueEnablesProtection) { EXPECT_FALSE(mSurface.isProtected()); EXPECT_CALL(*mNativeWindow, setUsage(GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_PROTECTED)) .WillOnce(Return(NO_ERROR)); mSurface.setProtected(true); EXPECT_TRUE(mSurface.isProtected()); } TEST_F(RenderSurfaceTest, setProtectedFalseDisablesProtection) { EXPECT_FALSE(mSurface.isProtected()); EXPECT_CALL(*mNativeWindow, setUsage(GRALLOC_USAGE_HW_RENDER)).WillOnce(Return(NO_ERROR)); mSurface.setProtected(false); EXPECT_FALSE(mSurface.isProtected()); } TEST_F(RenderSurfaceTest, setProtectedEnableAndDisable) { EXPECT_FALSE(mSurface.isProtected()); EXPECT_CALL(*mNativeWindow, setUsage(GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_PROTECTED)) .WillOnce(Return(NO_ERROR)); EXPECT_CALL(*mNativeWindow, setUsage(GRALLOC_USAGE_HW_RENDER)).WillOnce(Return(NO_ERROR)); mSurface.setProtected(true); EXPECT_TRUE(mSurface.isProtected()); mSurface.setProtected(false); EXPECT_FALSE(mSurface.isProtected()); } TEST_F(RenderSurfaceTest, setProtectedEnableWithError) { EXPECT_FALSE(mSurface.isProtected()); EXPECT_CALL(*mNativeWindow, setUsage(GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_PROTECTED)) .WillOnce(Return(INVALID_OPERATION)); mSurface.setProtected(true); EXPECT_FALSE(mSurface.isProtected()); } /* ------------------------------------------------------------------------ Loading