Loading services/surfaceflinger/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ LOCAL_SRC_FILES := \ DisplayHardware/FramebufferSurface.cpp \ DisplayHardware/HWC2.cpp \ DisplayHardware/HWC2On1Adapter.cpp \ DisplayHardware/MiniFence.cpp \ DisplayHardware/PowerHAL.cpp \ DisplayHardware/VirtualDisplaySurface.cpp \ Effects/Daltonizer.cpp \ Loading services/surfaceflinger/DisplayHardware/HWC2On1Adapter.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -724,7 +724,7 @@ Error HWC2On1Adapter::Display::getReleaseFences(uint32_t* outNumElements, } auto releaseFence = layer->getReleaseFence(); if (releaseFence != Fence::NO_FENCE) { if (releaseFence != MiniFence::NO_FENCE) { if (outputsNonNull) { outLayers[numWritten] = layer->getId(); outFences[numWritten] = releaseFence->dup(); Loading Loading @@ -2003,7 +2003,7 @@ void HWC2On1Adapter::Layer::addReleaseFence(int fenceFd) { mReleaseFence.add(fenceFd); } const sp<Fence>& HWC2On1Adapter::Layer::getReleaseFence() const { const sp<MiniFence>& HWC2On1Adapter::Layer::getReleaseFence() const { return mReleaseFence.get(); } Loading services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h +9 −9 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ #undef HWC2_INCLUDE_STRINGIFICATION #undef HWC2_USE_CPP11 #include <ui/Fence.h> #include "MiniFence.h" #include <atomic> #include <map> Loading Loading @@ -155,35 +155,35 @@ private: class DeferredFence { public: DeferredFence() : mFences({Fence::NO_FENCE, Fence::NO_FENCE}) {} : mFences({MiniFence::NO_FENCE, MiniFence::NO_FENCE}) {} void add(int32_t fenceFd) { mFences.emplace(new Fence(fenceFd)); mFences.emplace(new MiniFence(fenceFd)); mFences.pop(); } const sp<Fence>& get() const { const sp<MiniFence>& get() const { return mFences.front(); } private: // There are always two fences in this queue. std::queue<sp<Fence>> mFences; std::queue<sp<MiniFence>> mFences; }; class FencedBuffer { public: FencedBuffer() : mBuffer(nullptr), mFence(Fence::NO_FENCE) {} FencedBuffer() : mBuffer(nullptr), mFence(MiniFence::NO_FENCE) {} void setBuffer(buffer_handle_t buffer) { mBuffer = buffer; } void setFence(int fenceFd) { mFence = new Fence(fenceFd); } void setFence(int fenceFd) { mFence = new MiniFence(fenceFd); } buffer_handle_t getBuffer() const { return mBuffer; } int getFence() const { return mFence->dup(); } private: buffer_handle_t mBuffer; sp<Fence> mFence; sp<MiniFence> mFence; }; class Display { Loading Loading @@ -552,7 +552,7 @@ private: uint32_t getZ() const { return mZ; } void addReleaseFence(int fenceFd); const sp<Fence>& getReleaseFence() const; const sp<MiniFence>& getReleaseFence() const; void setHwc1Id(size_t id) { mHwc1Id = id; } size_t getHwc1Id() const { return mHwc1Id; } Loading services/surfaceflinger/DisplayHardware/MiniFence.cpp 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "MiniFence.h" #include <unistd.h> namespace android { const sp<MiniFence> MiniFence::NO_FENCE = sp<MiniFence>(new MiniFence); MiniFence::MiniFence() : mFenceFd(-1) { } MiniFence::MiniFence(int fenceFd) : mFenceFd(fenceFd) { } MiniFence::~MiniFence() { if (mFenceFd != -1) { close(mFenceFd); } } int MiniFence::dup() const { return ::dup(mFenceFd); } } services/surfaceflinger/DisplayHardware/MiniFence.h 0 → 100644 +59 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MINIFENCE_H #define MINIFENCE_H #include <utils/RefBase.h> namespace android { /* MiniFence is a minimal re-implementation of Fence from libui. It exists to * avoid linking the HWC2on1Adapter to libui and satisfy Treble requirements. */ class MiniFence : public LightRefBase<MiniFence> { public: static const sp<MiniFence> NO_FENCE; // Construct a new MiniFence object with an invalid file descriptor. MiniFence(); // Construct a new MiniFence object to manage a given fence file descriptor. // When the new MiniFence object is destructed the file descriptor will be // closed. explicit MiniFence(int fenceFd); // Not copyable or movable. MiniFence(const MiniFence& rhs) = delete; MiniFence& operator=(const MiniFence& rhs) = delete; MiniFence(MiniFence&& rhs) = delete; MiniFence& operator=(MiniFence&& rhs) = delete; // Return a duplicate of the fence file descriptor. The caller is // responsible for closing the returned file descriptor. On error, -1 will // be returned and errno will indicate the problem. int dup() const; private: // Only allow instantiation using ref counting. friend class LightRefBase<MiniFence>; ~MiniFence(); int mFenceFd; }; } #endif //MINIFENCE_H Loading
services/surfaceflinger/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ LOCAL_SRC_FILES := \ DisplayHardware/FramebufferSurface.cpp \ DisplayHardware/HWC2.cpp \ DisplayHardware/HWC2On1Adapter.cpp \ DisplayHardware/MiniFence.cpp \ DisplayHardware/PowerHAL.cpp \ DisplayHardware/VirtualDisplaySurface.cpp \ Effects/Daltonizer.cpp \ Loading
services/surfaceflinger/DisplayHardware/HWC2On1Adapter.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -724,7 +724,7 @@ Error HWC2On1Adapter::Display::getReleaseFences(uint32_t* outNumElements, } auto releaseFence = layer->getReleaseFence(); if (releaseFence != Fence::NO_FENCE) { if (releaseFence != MiniFence::NO_FENCE) { if (outputsNonNull) { outLayers[numWritten] = layer->getId(); outFences[numWritten] = releaseFence->dup(); Loading Loading @@ -2003,7 +2003,7 @@ void HWC2On1Adapter::Layer::addReleaseFence(int fenceFd) { mReleaseFence.add(fenceFd); } const sp<Fence>& HWC2On1Adapter::Layer::getReleaseFence() const { const sp<MiniFence>& HWC2On1Adapter::Layer::getReleaseFence() const { return mReleaseFence.get(); } Loading
services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h +9 −9 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ #undef HWC2_INCLUDE_STRINGIFICATION #undef HWC2_USE_CPP11 #include <ui/Fence.h> #include "MiniFence.h" #include <atomic> #include <map> Loading Loading @@ -155,35 +155,35 @@ private: class DeferredFence { public: DeferredFence() : mFences({Fence::NO_FENCE, Fence::NO_FENCE}) {} : mFences({MiniFence::NO_FENCE, MiniFence::NO_FENCE}) {} void add(int32_t fenceFd) { mFences.emplace(new Fence(fenceFd)); mFences.emplace(new MiniFence(fenceFd)); mFences.pop(); } const sp<Fence>& get() const { const sp<MiniFence>& get() const { return mFences.front(); } private: // There are always two fences in this queue. std::queue<sp<Fence>> mFences; std::queue<sp<MiniFence>> mFences; }; class FencedBuffer { public: FencedBuffer() : mBuffer(nullptr), mFence(Fence::NO_FENCE) {} FencedBuffer() : mBuffer(nullptr), mFence(MiniFence::NO_FENCE) {} void setBuffer(buffer_handle_t buffer) { mBuffer = buffer; } void setFence(int fenceFd) { mFence = new Fence(fenceFd); } void setFence(int fenceFd) { mFence = new MiniFence(fenceFd); } buffer_handle_t getBuffer() const { return mBuffer; } int getFence() const { return mFence->dup(); } private: buffer_handle_t mBuffer; sp<Fence> mFence; sp<MiniFence> mFence; }; class Display { Loading Loading @@ -552,7 +552,7 @@ private: uint32_t getZ() const { return mZ; } void addReleaseFence(int fenceFd); const sp<Fence>& getReleaseFence() const; const sp<MiniFence>& getReleaseFence() const; void setHwc1Id(size_t id) { mHwc1Id = id; } size_t getHwc1Id() const { return mHwc1Id; } Loading
services/surfaceflinger/DisplayHardware/MiniFence.cpp 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "MiniFence.h" #include <unistd.h> namespace android { const sp<MiniFence> MiniFence::NO_FENCE = sp<MiniFence>(new MiniFence); MiniFence::MiniFence() : mFenceFd(-1) { } MiniFence::MiniFence(int fenceFd) : mFenceFd(fenceFd) { } MiniFence::~MiniFence() { if (mFenceFd != -1) { close(mFenceFd); } } int MiniFence::dup() const { return ::dup(mFenceFd); } }
services/surfaceflinger/DisplayHardware/MiniFence.h 0 → 100644 +59 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MINIFENCE_H #define MINIFENCE_H #include <utils/RefBase.h> namespace android { /* MiniFence is a minimal re-implementation of Fence from libui. It exists to * avoid linking the HWC2on1Adapter to libui and satisfy Treble requirements. */ class MiniFence : public LightRefBase<MiniFence> { public: static const sp<MiniFence> NO_FENCE; // Construct a new MiniFence object with an invalid file descriptor. MiniFence(); // Construct a new MiniFence object to manage a given fence file descriptor. // When the new MiniFence object is destructed the file descriptor will be // closed. explicit MiniFence(int fenceFd); // Not copyable or movable. MiniFence(const MiniFence& rhs) = delete; MiniFence& operator=(const MiniFence& rhs) = delete; MiniFence(MiniFence&& rhs) = delete; MiniFence& operator=(MiniFence&& rhs) = delete; // Return a duplicate of the fence file descriptor. The caller is // responsible for closing the returned file descriptor. On error, -1 will // be returned and errno will indicate the problem. int dup() const; private: // Only allow instantiation using ref counting. friend class LightRefBase<MiniFence>; ~MiniFence(); int mFenceFd; }; } #endif //MINIFENCE_H