Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor: Make GetImageHandle() Evas GL-only
  • Loading branch information
swift-kim committed Apr 23, 2021
commit 66fcc5fec5a7b44ea87d496c469c3fa3b642803d
4 changes: 0 additions & 4 deletions shell/platform/tizen/tizen_embedder_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ TizenEmbedderEngine::TizenEmbedderEngine(
tizen_renderer = std::make_unique<TizenRendererEvasGL>(
*this, window_properties.x, window_properties.y, window_properties.width,
window_properties.height);
// clear once to remove noise
tizen_renderer->OnMakeCurrent();
tizen_renderer->ClearColor(0, 0, 0, 0);
tizen_renderer->OnPresent();
#else
tizen_renderer = std::make_unique<TizenRendererEcoreWl2>(
*this, window_properties.x, window_properties.y, window_properties.width,
Expand Down
18 changes: 10 additions & 8 deletions shell/platform/tizen/tizen_event_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
#include <atomic>
#include <utility>

#ifdef TIZEN_RENDERER_EVAS_GL
#include <Evas_GL.h>
#endif

#include "flutter/shell/platform/tizen/tizen_log.h"
#include "flutter/shell/platform/tizen/tizen_renderer.h"
#ifdef TIZEN_RENDERER_EVAS_GL
#include "flutter/shell/platform/tizen/tizen_renderer_evas_gl.h"
#endif

TizenEventLoop::TizenEventLoop(std::thread::id main_thread_id,
TaskExpiredCallback on_task_expired)
Expand Down Expand Up @@ -120,8 +119,9 @@ TizenRenderEventLoop::TizenRenderEventLoop(std::thread::id main_thread_id,
: TizenEventLoop(main_thread_id, on_task_expired),
tizen_renderer_(tizen_renderer) {
evas_object_image_pixels_get_callback_set(
(Evas_Object*)tizen_renderer_->GetImageHandle(),
[](void* data, Evas_Object* o) { // Render call back
(Evas_Object*)static_cast<TizenRendererEvasGL*>(tizen_renderer_)
->GetImageHandle(),
[](void* data, Evas_Object* o) { // Render callback
TizenRenderEventLoop* self = (TizenRenderEventLoop*)data;
{
std::lock_guard<std::mutex> lock(self->expired_tasks_mutex_);
Expand All @@ -141,9 +141,11 @@ void TizenRenderEventLoop::OnTaskExpired() {
size_t expired_tasks_count = 0;
std::lock_guard<std::mutex> lock(expired_tasks_mutex_);
expired_tasks_count = expired_tasks_.size();
if (has_pending_renderer_callback_ == false && expired_tasks_count) {
if (!has_pending_renderer_callback_ && expired_tasks_count) {
evas_object_image_pixels_dirty_set(
(Evas_Object*)tizen_renderer_->GetImageHandle(), EINA_TRUE);
(Evas_Object*)static_cast<TizenRendererEvasGL*>(tizen_renderer_)
->GetImageHandle(),
EINA_TRUE);
has_pending_renderer_callback_ = true;
} else {
// Do nothing
Expand Down
4 changes: 0 additions & 4 deletions shell/platform/tizen/tizen_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ class TizenRenderer {
virtual TizenWindowGeometry GetGeometry() = 0;
virtual uintptr_t GetWindowId() = 0;

// TODO: For Evas GL only.
virtual void* GetImageHandle() { return nullptr; };
virtual void ClearColor(float r, float g, float b, float a){};

virtual void SetRotate(int angle) = 0;
virtual void ResizeWithRotation(int32_t x, int32_t y, int32_t width,
int32_t height, int32_t degree) = 0;
Expand Down
15 changes: 10 additions & 5 deletions shell/platform/tizen/tizen_renderer_evas_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@ TizenRendererEvasGL::TizenRendererEvasGL(TizenRenderer::Delegate& delegate,
int32_t h)
: TizenRenderer(delegate) {
InitializeRenderer(x, y, w, h);

// Clear once to remove noise.
OnMakeCurrent();
ClearColor(0, 0, 0, 0);
OnPresent();
}

TizenRendererEvasGL::~TizenRendererEvasGL() { DestroyRenderer(); }

void TizenRendererEvasGL::ClearColor(float r, float g, float b, float a) {
glClearColor(r, g, b, a);
glClear(GL_COLOR_BUFFER_BIT);
}

bool TizenRendererEvasGL::OnMakeCurrent() {
if (!IsValid()) {
FT_LOGE("Invalid TizenRenderer");
Expand Down Expand Up @@ -545,11 +555,6 @@ uintptr_t TizenRendererEvasGL::GetWindowId() {

void* TizenRendererEvasGL::GetImageHandle() { return (void*)graphics_adapter_; }

void TizenRendererEvasGL::ClearColor(float r, float g, float b, float a) {
glClearColor(r, g, b, a);
glClear(GL_COLOR_BUFFER_BIT);
}

bool TizenRendererEvasGL::InitializeRenderer(int32_t x, int32_t y, int32_t w,
int32_t h) {
if (!SetupEvasGL(x, y, w, h)) {
Expand Down
7 changes: 4 additions & 3 deletions shell/platform/tizen/tizen_renderer_evas_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ class TizenRendererEvasGL : public TizenRenderer {
void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height,
int32_t angle) override;
void SetRotate(int angle) override;

void* GetImageHandle() override;
void ClearColor(float r, float g, float b, float a) override;

void* GetImageHandle();

protected:
bool InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h) override;
Expand All @@ -43,6 +42,8 @@ class TizenRendererEvasGL : public TizenRenderer {
void SendRotationChangeDone() override;

private:
void ClearColor(float r, float g, float b, float a);

bool SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h);
void* SetupEvasWindow(int32_t x, int32_t y, int32_t w, int32_t h);
void DestroyEvasGL();
Expand Down