Commit dd92f8258f6114f19525530d32b01eec6d896529

Authored by David Steele
1 parent 458c4703

Adding back/touch to quit in direct-rendering demo

Change-Id: I8432ac95eb5ea56bee110c13137ee4da2f90827f
examples/direct-rendering/direct-rendering-example.cpp
1 1 /*
2   - * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  2 + * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3 3 *
4 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 5 * you may not use this file except in compliance with the License.
... ... @@ -46,32 +46,32 @@ const uint32_t DR_THREAD_ENABLED = GetEnvInt("DR_THREAD_ENABLED", 0);
46 46 */
47 47 const Toolkit::GlView::BackendMode BACKEND_MODE =
48 48 Toolkit::GlView::BackendMode(GetEnvInt("EGL_ENABLED", 0));
49   -}
  49 +} // namespace
50 50  
51 51 /**
52 52 * RenderView encapsulates single GLView callback and its parameters.
53 53 */
54 54 struct RenderView
55 55 {
56   - explicit RenderView( const Dali::Window& window )
  56 + explicit RenderView(const Dali::Window& window)
57 57 {
58 58 mWindow = window;
59 59 }
60 60  
61   - int Create(const Vector2& pos, Toolkit::GlView::BackendMode mode )
  61 + int Create(const Vector2& pos, Toolkit::GlView::BackendMode mode)
62 62 {
63 63 auto w = mWindow.GetSize().GetWidth();
64 64 auto h = mWindow.GetSize().GetHeight();
65 65  
66 66 NativeRenderer::CreateInfo info{};
67 67 info.clearColor = {0, 0, 0, 0};
68   - info.name = "DR";
69   - info.offscreen = (mode == Toolkit::GlView::BackendMode::EGL_IMAGE_OFFSCREEN_RENDERING || DR_THREAD_ENABLED);
70   - info.viewportX = 0;
71   - info.viewportY = 0;
72   - info.width = w;
73   - info.height = h;
74   - info.threaded = (mode != Toolkit::GlView::BackendMode::EGL_IMAGE_OFFSCREEN_RENDERING) && (DR_THREAD_ENABLED);
  68 + info.name = "DR";
  69 + info.offscreen = (mode == Toolkit::GlView::BackendMode::EGL_IMAGE_OFFSCREEN_RENDERING || DR_THREAD_ENABLED);
  70 + info.viewportX = 0;
  71 + info.viewportY = 0;
  72 + info.width = w;
  73 + info.height = h;
  74 + info.threaded = (mode != Toolkit::GlView::BackendMode::EGL_IMAGE_OFFSCREEN_RENDERING) && (DR_THREAD_ENABLED);
75 75  
76 76 // Enable threaded rendering
77 77 if(info.threaded && mode == Dali::Toolkit::GlView::BackendMode::DIRECT_RENDERING)
... ... @@ -103,9 +103,8 @@ struct RenderView
103 103 return 0;
104 104 }
105 105  
106   -
107   - Dali::Window mWindow;
108   - Toolkit::GlView mGlView;
  106 + Dali::Window mWindow;
  107 + Toolkit::GlView mGlView;
109 108 std::unique_ptr<NativeRenderer> mRenderer{};
110 109  
111 110 CallbackBase* mGlInitCallback{};
... ... @@ -119,9 +118,8 @@ struct RenderView
119 118 class DirectRenderingExampleController : public ConnectionTracker
120 119 {
121 120 public:
122   -
123 121 explicit DirectRenderingExampleController(Application& application)
124   - : mApplication(application)
  122 + : mApplication(application)
125 123 {
126 124 // Connect to the Application's Init signal
127 125 mApplication.InitSignal().Connect(this, &DirectRenderingExampleController::Create);
... ... @@ -135,8 +133,11 @@ public:
135 133 Dali::Window window = application.GetWindow();
136 134 window.SetBackgroundColor(Color::WHITE);
137 135  
  136 + window.KeyEventSignal().Connect(this, &DirectRenderingExampleController::OnKeyEvent);
  137 + window.GetRootLayer().TouchedSignal().Connect(this, &DirectRenderingExampleController::OnTouch);
  138 +
138 139 mDRView = std::make_unique<RenderView>(window);
139   - mDRView->Create( Vector2::ZERO, BACKEND_MODE );
  140 + mDRView->Create(Vector2::ZERO, BACKEND_MODE);
140 141 }
141 142  
142 143 bool OnTouch(Actor actor, const TouchEvent& touch)
... ... @@ -158,13 +159,13 @@ public:
158 159 }
159 160  
160 161 private:
161   - Application& mApplication;
  162 + Application& mApplication;
162 163 std::unique_ptr<RenderView> mDRView;
163 164 };
164 165  
165 166 int DALI_EXPORT_API main(int argc, char** argv)
166 167 {
167   - Application application = Application::New(&argc, &argv);
  168 + Application application = Application::New(&argc, &argv);
168 169 DirectRenderingExampleController test(application);
169 170 application.MainLoop();
170 171 return 0;
... ...