mirror of
https://github.com/openharmony/graphic_graphic_surface.git
synced 2026-08-24 21:51:35 -04:00
a6e4d368dd
Signed-off-by: zhangyifan <zhangyifan140@h-partners.com> Change-Id: Id5bba2297abc3f1c0dcfa36a5f8e7debd7a26cba
123 lines
5.3 KiB
C++
123 lines
5.3 KiB
C++
/*
|
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
|
* 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 FRAMEWORKS_SURFACE_INCLUDE_BUFFER_QUEUE_CONSUMER_H
|
|
#define FRAMEWORKS_SURFACE_INCLUDE_BUFFER_QUEUE_CONSUMER_H
|
|
|
|
#include <refbase.h>
|
|
|
|
#include "surface_type.h"
|
|
#include "surface_buffer.h"
|
|
#include "buffer_queue.h"
|
|
|
|
namespace OHOS {
|
|
class SURFACE_HIDDEN BufferQueueConsumer : public RefBase {
|
|
public:
|
|
BufferQueueConsumer(sptr<BufferQueue>& bufferQueue);
|
|
virtual ~BufferQueueConsumer();
|
|
|
|
GSError AcquireBuffer(sptr<SurfaceBuffer> &buffer, sptr<SyncFence> &fence,
|
|
int64_t ×tamp, std::vector<Rect> &damages, bool isLppMode = false);
|
|
GSError AcquireBuffer(IConsumerSurface::AcquireBufferReturnValue &returnValue, int64_t expectPresentTimestamp,
|
|
bool isUsingAutoTimestamp);
|
|
GSError ReleaseBuffer(sptr<SurfaceBuffer>& buffer, const sptr<SyncFence>& fence);
|
|
|
|
GSError AttachBuffer(sptr<SurfaceBuffer>& buffer);
|
|
GSError AttachBuffer(sptr<SurfaceBuffer>& buffer, int32_t timeOut);
|
|
|
|
GSError DetachBuffer(sptr<SurfaceBuffer>& buffer);
|
|
GSError RegisterSurfaceDelegator(sptr<IRemoteObject> client, sptr<Surface> cSurface);
|
|
GSError UnregisterSurfaceDelegator();
|
|
|
|
bool QueryIfBufferAvailable();
|
|
|
|
GSError RegisterConsumerListener(sptr<IBufferConsumerListener>& listener);
|
|
GSError RegisterConsumerListener(IBufferConsumerListenerClazz *listener);
|
|
GSError RegisterReleaseListener(OnReleaseFunc func);
|
|
GSError RegisterDeleteBufferListener(OnDeleteBufferFunc func, bool isForUniRedraw = false);
|
|
GSError UnregisterConsumerListener();
|
|
|
|
GSError SetDefaultWidthAndHeight(int32_t width, int32_t height);
|
|
GSError SetDefaultUsage(uint64_t usage);
|
|
void Dump(std::string &result) const;
|
|
void DumpCurrentFrameLayer() const;
|
|
GraphicTransformType GetTransform() const;
|
|
GSError GetScalingMode(uint32_t sequence, ScalingMode &scalingMode) const;
|
|
GSError GetVideoDimensionType(uint32_t sequence, VideoDimType &videoDimType) const;
|
|
GSError QueryMetaDataType(uint32_t sequence, HDRMetaDataType &type) const;
|
|
GSError GetMetaData(uint32_t sequence, std::vector<GraphicHDRMetaData> &metaData) const;
|
|
GSError GetMetaDataSet(uint32_t sequence, GraphicHDRMetadataKey &key, std::vector<uint8_t> &metaData) const;
|
|
GSError GetGlobalAlpha(int32_t &alpha);
|
|
sptr<SurfaceTunnelHandle> GetTunnelHandle() const;
|
|
GSError GetTunnelLayerInfo(TunnelLayerState& info) const;
|
|
GSError NotifyLayerStateChanged(LayerStateChange state);
|
|
GSError SetPresentTimestamp(uint32_t sequence, const GraphicPresentTimestamp ×tamp);
|
|
|
|
bool GetStatus() const;
|
|
void SetStatus(bool status);
|
|
GSError OnConsumerDied();
|
|
GSError GoBackground();
|
|
void ConsumerRequestCpuAccess(bool on)
|
|
{
|
|
if (bufferQueue_ == nullptr) {
|
|
return;
|
|
}
|
|
bufferQueue_->ConsumerRequestCpuAccess(on);
|
|
}
|
|
|
|
GSError AttachBufferToQueue(sptr<SurfaceBuffer> buffer);
|
|
GSError DetachBufferFromQueue(sptr<SurfaceBuffer> buffer, bool isReserveSlot);
|
|
void SetBufferHold(bool hold);
|
|
inline bool IsBufferHold()
|
|
{
|
|
if (bufferQueue_ == nullptr) {
|
|
return false;
|
|
}
|
|
return bufferQueue_->IsBufferHold();
|
|
}
|
|
float GetHdrWhitePointBrightness() const;
|
|
float GetSdrWhitePointBrightness() const;
|
|
GSError IsSurfaceBufferInCache(uint32_t seqNum, bool &isInCache);
|
|
uint32_t GetAvailableBufferCount() const;
|
|
GSError GetBufferCacheConfig(const sptr<SurfaceBuffer>& buffer, BufferRequestConfig& config);
|
|
GSError GetLastFlushedDesiredPresentTimeStamp(int64_t &lastFlushedDesiredPresentTimeStamp) const;
|
|
GSError GetFrontDesiredPresentTimeStamp(int64_t &desiredPresentTimeStamp, bool &isAutoTimeStamp) const;
|
|
GSError GetBufferSupportFastCompose(bool &bufferSupportFastCompose) const;
|
|
GSError GetCycleBuffersNumber(uint32_t& cycleBuffersNumber);
|
|
GSError GetFrameGravity(int32_t &frameGravity);
|
|
GSError GetFixedRotation(int32_t &fixedRotation);
|
|
GSError GetLastConsumeTime(int64_t &lastConsumeTime) const;
|
|
GSError SetMaxQueueSize(uint32_t queueSize);
|
|
GSError GetMaxQueueSize(uint32_t &queueSize) const;
|
|
GSError SetLppDrawSource(bool isShbSource, bool isRsSource);
|
|
GSError GetAlphaType(GraphicAlphaType &alphaType);
|
|
GSError SetIsPriorityAlloc(bool isPriorityAlloc);
|
|
bool IsCached(uint32_t bufferSeqNum) const;
|
|
|
|
/**
|
|
* @brief Set the Drop Frame Level for the buffer queue.
|
|
* @param level The drop frame level (0 means no drop, >0 means keep latest N frames)
|
|
* @return {@link GSERROR_OK} 0 - Success.
|
|
*/
|
|
GSError SetDropFrameLevel(int32_t level);
|
|
SingleBufferMode GetAndResetSingleBufferMode();
|
|
private:
|
|
sptr<BufferQueue> bufferQueue_ = nullptr;
|
|
std::string name_ = "not init";
|
|
};
|
|
} // namespace OHOS
|
|
|
|
#endif // FRAMEWORKS_SURFACE_INCLUDE_BUFFER_QUEUE_CONSUMER_H
|