sdm: Use sync task utility for hdr tonemapping.
- Execute all gles operations in one thread of
execution. This is to create tonemap context
in one thread per session and execute all
command in the same thread.
Change-Id: Ie9ab0e62c997e583131e3424665b98f873cb9263
CRs-Fixed: 2053738
diff --git a/sdm/libs/hwc2/hwc_tonemapper.h b/sdm/libs/hwc2/hwc_tonemapper.h
index 8367c3e..e2c8ef4 100644
--- a/sdm/libs/hwc2/hwc_tonemapper.h
+++ b/sdm/libs/hwc2/hwc_tonemapper.h
@@ -37,6 +37,7 @@
#include <core/layer_stack.h>
#include <utils/sys.h>
+#include <utils/sync_task.h>
#include <vector>
#include "hwc_buffer_sync_handler.h"
#include "hwc_buffer_allocator.h"
@@ -45,6 +46,22 @@
namespace sdm {
+enum class ToneMapTaskCode : int32_t {
+ kCodeGetInstance,
+ kCodeBlit,
+ kCodeDestroy,
+};
+
+struct ToneMapGetInstanceContext : public SyncTask<ToneMapTaskCode>::TaskContext {
+ Layer *layer = nullptr;
+};
+
+struct ToneMapBlitContext : public SyncTask<ToneMapTaskCode>::TaskContext {
+ Layer *layer = nullptr;
+ int merged_fd = -1;
+ int fence_fd = -1;
+};
+
struct ToneMapConfig {
int type = 0;
ColorPrimaries colorPrimaries = ColorPrimaries_Max;
@@ -53,7 +70,7 @@
bool secure = false;
};
-class ToneMapSession {
+class ToneMapSession : public SyncTask<ToneMapTaskCode>::TaskHandler {
public:
explicit ToneMapSession(HWCBufferAllocator *buffer_allocator);
~ToneMapSession();
@@ -64,7 +81,12 @@
void SetToneMapConfig(Layer *layer);
bool IsSameToneMapConfig(Layer *layer);
+ // TaskHandler methods implementation.
+ virtual void OnTask(const ToneMapTaskCode &task_code,
+ SyncTask<ToneMapTaskCode>::TaskContext *task_context);
+
static const uint8_t kNumIntermediateBuffers = 2;
+ SyncTask<ToneMapTaskCode> tone_map_task_;
Tonemapper *gpu_tone_mapper_ = nullptr;
HWCBufferAllocator *buffer_allocator_ = nullptr;
ToneMapConfig tone_map_config_ = {};