Merge branch 'devel/master' into devel/graphics 94/258794/2
authorDavid Steele <david.steele@samsung.com>
Tue, 25 May 2021 23:27:07 +0000 (00:27 +0100)
committerDavid Steele <david.steele@samsung.com>
Wed, 26 May 2021 10:34:43 +0000 (11:34 +0100)
Change-Id: I074c2bb0fbb1d6775cfbadcf4f1271e177bc12c2

1  2 
dali/devel-api/adaptor-framework/accessibility-impl.cpp
dali/internal/accessibility/bridge/bridge-base.h
dali/internal/accessibility/bridge/bridge-impl.cpp
dali/internal/accessibility/bridge/dummy-atspi.cpp
dali/internal/imaging/common/image-loader.cpp
dali/internal/window-system/common/window-render-surface.cpp

@@@ -596,7 -596,7 +596,7 @@@ class NonControlAccessible : public vir
  {
  protected:
    Dali::WeakHandle<Dali::Actor> self;
--  bool        root = false;
++  bool                          root = false;
  
    Dali::Actor Self()
    {
@@@ -618,12 -618,12 +618,12 @@@ public
  
    Dali::Rect<> GetExtents(Dali::Accessibility::CoordType ctype) override
    {
--    Dali::Actor actor = Self();
--    Vector2 screenPosition          = actor.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
--    Vector3 size                    = actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE);
--    bool    positionUsesAnchorPoint = actor.GetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT).Get<bool>();
--    Vector3 anchorPointOffSet       = size * (positionUsesAnchorPoint ? actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
--    Vector2 position                = Vector2(screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y);
++    Dali::Actor actor                   = Self();
++    Vector2     screenPosition          = actor.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
++    Vector3     size                    = actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE);
++    bool        positionUsesAnchorPoint = actor.GetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT).Get<bool>();
++    Vector3     anchorPointOffSet       = size * (positionUsesAnchorPoint ? actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
++    Vector2     position                = Vector2(screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y);
  
      return {position.x, position.y, size.x, size.y};
    }
      Dali::TypeInfo type;
      Self().GetTypeInfo(type);
      return {
-       {"t", type.GetName()},
+       {"class", type.GetName()},
      };
    }
  
@@@ -143,17 -143,17 +143,18 @@@ public
      DBus::DBusInterfaceDescription& desc, const std::string& funcName, DBus::ValueOrError<RET...> (SELF::*funcPtr)(ARGS...))
    {
      if(auto self = dynamic_cast<SELF*>(this))
--      desc.addMethod<DBus::ValueOrError<RET...>(ARGS...)>(funcName,
--                                                          [=](ARGS... args) -> DBus::ValueOrError<RET...> {
--                                                            try
--                                                            {
--                                                              return (self->*funcPtr)(std::move(args)...);
--                                                            }
--                                                            catch(std::domain_error& e)
--                                                            {
--                                                              return DBus::Error{e.what()};
--                                                            }
--                                                          });
++      desc.addMethod<DBus::ValueOrError<RET...>(ARGS...)>(
++        funcName,
++        [=](ARGS... args) -> DBus::ValueOrError<RET...> {
++          try
++          {
++            return (self->*funcPtr)(std::move(args)...);
++          }
++          catch(std::domain_error& e)
++          {
++            return DBus::Error{e.what()};
++          }
++        });
    }
  
    template<typename T, typename SELF>
@@@ -301,7 -301,7 +302,7 @@@ protected
    DBusWrapper::ConnectionPtr con;
    int                        id = 0;
    DBus::DBusClient           registry;
-   bool                       allowObjectBoundsChangedEvent;
+   bool                       allowObjectBoundsChangedEvent{false};
  };
  
  #endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_BASE_H
  // CLASS HEADER
  
  // EXTERNAL INCLUDES
 -#include <dali/public-api/actors/layer.h>
+ #include <dali/devel-api/common/stage.h>
  #include <dali/integration-api/debug.h>
++#include <dali/public-api/actors/layer.h>
  #include <iostream>
  #include <unordered_map>
  
  // INTERNAL INCLUDES
 +#include <dali/devel-api/adaptor-framework/environment-variable.h>
++#include <dali/devel-api/adaptor-framework/window-devel.h>
  #include <dali/internal/accessibility/bridge/bridge-accessible.h>
  #include <dali/internal/accessibility/bridge/bridge-action.h>
  #include <dali/internal/accessibility/bridge/bridge-collection.h>
  #include <dali/internal/accessibility/bridge/bridge-text.h>
  #include <dali/internal/accessibility/bridge/bridge-value.h>
  #include <dali/internal/accessibility/bridge/dummy-atspi.h>
+ #include <dali/internal/adaptor/common/adaptor-impl.h>
  #include <dali/internal/system/common/environment-variables.h>
 -#include <dali/devel-api/adaptor-framework/environment-variable.h>
 -#include <dali/devel-api/adaptor-framework/window-devel.h>
  
  using namespace Dali::Accessibility;
  
@@@ -344,15 -348,15 +348,15 @@@ static Bridge* CreateBridge(
    try
    {
      /* check environment variable first */
 -    const char *envAtspiDisabled = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_DISABLE_ATSPI);
 -    if (envAtspiDisabled && std::atoi(envAtspiDisabled) != 0)
 +    const charenvAtspiDisabled = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_DISABLE_ATSPI);
 +    if(envAtspiDisabled && std::atoi(envAtspiDisabled) != 0)
      {
        return Dali::Accessibility::DummyBridge::GetInstance();
      }
  
      return new BridgeImpl;
    }
 -  catch (const std::exception&)
 +  catch(const std::exception&)
    {
      DALI_LOG_ERROR("Failed to initialize AT-SPI bridge");
      return Dali::Accessibility::DummyBridge::GetInstance();
@@@ -363,17 -367,17 +367,17 @@@ Bridge* Bridge::GetCurrentBridge(
  {
    static Bridge* bridge;
  
 -  if (bridge)
 +  if(bridge)
    {
      return bridge;
    }
 -  else if (autoInitState == AutoInitState::ENABLED)
 +  else if(autoInitState == AutoInitState::ENABLED)
    {
      bridge = CreateBridge();
  
      /* check environment variable for suppressing screen-reader */
 -    const char *envSuppressScreenReader = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_SUPPRESS_SCREEN_READER);
 -    if (envSuppressScreenReader && std::atoi(envSuppressScreenReader) != 0)
 +    const charenvSuppressScreenReader = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_SUPPRESS_SCREEN_READER);
 +    if(envSuppressScreenReader && std::atoi(envSuppressScreenReader) != 0)
      {
        bridge->SuppressScreenReader(true);
      }
  
  void Bridge::DisableAutoInit()
  {
 -  if (bridgeInitialized)
 +  if(bridgeInitialized)
    {
      DALI_LOG_ERROR("Bridge::DisableAutoInit() called after bridge auto-initialization");
    }
    autoInitState = AutoInitState::DISABLED;
  }
  
- void Bridge::EnableAutoInit(Accessible* topLevelWindow, const std::string& applicationName)
+ void Bridge::EnableAutoInit()
  {
    autoInitState = AutoInitState::ENABLED;
  
 -  if (bridgeInitialized)
 +  if(bridgeInitialized)
    {
      return;
    }
  
 -  auto rootLayer = Dali::Stage::GetCurrent().GetRootLayer();
 -  auto window = Dali::DevelWindow::Get(rootLayer);
++  auto rootLayer       = Dali::Stage::GetCurrent().GetRootLayer();
++  auto window          = Dali::DevelWindow::Get(rootLayer);
+   auto applicationName = Dali::Internal::Adaptor::Adaptor::GetApplicationPackageName();
    auto* bridge = Bridge::GetCurrentBridge();
-   bridge->AddTopLevelWindow(topLevelWindow);
+   bridge->AddTopLevelWindow(Dali::Accessibility::Accessible::Get(rootLayer, true));
    bridge->SetApplicationName(applicationName);
    bridge->Initialize();
+   if(window && window.IsVisible())
+   {
+     bridge->ApplicationShown();
+   }
  }
@@@ -21,6 -21,7 +21,6 @@@
  
  namespace Dali
  {
 -
  Accessibility::Accessible::Accessible()
  {
  }
@@@ -78,7 -79,7 +78,7 @@@ void Accessibility::Bridge::DisableAuto
  {
  }
  
- void Accessibility::Bridge::EnableAutoInit(Accessible*, const std::string&)
+ void Accessibility::Bridge::EnableAutoInit()
  {
  }
  
  #include <dali/internal/imaging/common/loader-astc.h>
  #include <dali/internal/imaging/common/loader-bmp.h>
  #include <dali/internal/imaging/common/loader-gif.h>
 -#include <dali/internal/imaging/common/loader-webp.h>
  #include <dali/internal/imaging/common/loader-ico.h>
  #include <dali/internal/imaging/common/loader-jpeg.h>
  #include <dali/internal/imaging/common/loader-ktx.h>
  #include <dali/internal/imaging/common/loader-png.h>
  #include <dali/internal/imaging/common/loader-wbmp.h>
++#include <dali/internal/imaging/common/loader-webp.h>
  #include <dali/internal/system/common/file-reader.h>
  
  using namespace Dali::Integration;
@@@ -61,6 -62,7 +62,7 @@@ enum FileFormat
    FORMAT_JPEG,
    FORMAT_BMP,
    FORMAT_GIF,
+   FORMAT_WEBP,
    FORMAT_KTX,
    FORMAT_ASTC,
    FORMAT_ICO,
@@@ -82,6 -84,7 +84,7 @@@ const Dali::ImageLoader::BitmapLoader B
      {Jpeg::MAGIC_BYTE_1, Jpeg::MAGIC_BYTE_2, LoadBitmapFromJpeg, LoadJpegHeader, Bitmap::BITMAP_2D_PACKED_PIXELS},
      {Bmp::MAGIC_BYTE_1,  Bmp::MAGIC_BYTE_2,  LoadBitmapFromBmp,  LoadBmpHeader,  Bitmap::BITMAP_2D_PACKED_PIXELS},
      {Gif::MAGIC_BYTE_1,  Gif::MAGIC_BYTE_2,  LoadBitmapFromGif,  LoadGifHeader,  Bitmap::BITMAP_2D_PACKED_PIXELS},
+     {Webp::MAGIC_BYTE_1, Webp::MAGIC_BYTE_2, LoadBitmapFromWebp, LoadWebpHeader, Bitmap::BITMAP_2D_PACKED_PIXELS},
      {Ktx::MAGIC_BYTE_1,  Ktx::MAGIC_BYTE_2,  LoadBitmapFromKtx,  LoadKtxHeader,  Bitmap::BITMAP_COMPRESSED      },
      {Astc::MAGIC_BYTE_1, Astc::MAGIC_BYTE_2, LoadBitmapFromAstc, LoadAstcHeader, Bitmap::BITMAP_COMPRESSED      },
      {Ico::MAGIC_BYTE_1,  Ico::MAGIC_BYTE_2,  LoadBitmapFromIco,  LoadIcoHeader,  Bitmap::BITMAP_2D_PACKED_PIXELS},
@@@ -107,6 -110,7 +110,7 @@@ const FormatExtension FORMAT_EXTENSIONS
      {".jpg",  FORMAT_JPEG},
      {".bmp",  FORMAT_BMP },
      {".gif",  FORMAT_GIF },
+     {".webp", FORMAT_WEBP },
      {".ktx",  FORMAT_KTX },
      {".astc", FORMAT_ASTC},
      {".ico",  FORMAT_ICO },
@@@ -79,6 -79,45 +79,45 @@@ void InsertRects(WindowRenderSurface::D
    }
  }
  
+ Rect<int32_t> RecalculateRect0(Rect<int32_t>& rect, const Rect<int32_t>& surfaceSize)
+ {
+   return rect;
+ }
+ Rect<int32_t> RecalculateRect90(Rect<int32_t>& rect, const Rect<int32_t>& surfaceSize)
+ {
+   Rect<int32_t> newRect;
+   newRect.x      = surfaceSize.height - (rect.y + rect.height);
+   newRect.y      = rect.x;
+   newRect.width  = rect.height;
+   newRect.height = rect.width;
+   return newRect;
+ }
+ Rect<int32_t> RecalculateRect180(Rect<int32_t>& rect, const Rect<int32_t>& surfaceSize)
+ {
+   Rect<int32_t> newRect;
+   newRect.x      = surfaceSize.width - (rect.x + rect.width);
+   newRect.y      = surfaceSize.height - (rect.y + rect.height);
+   newRect.width  = rect.width;
+   newRect.height = rect.height;
+   return newRect;
+ }
+ Rect<int32_t> RecalculateRect270(Rect<int32_t>& rect, const Rect<int32_t>& surfaceSize)
+ {
+   Rect<int32_t> newRect;
+   newRect.x      = rect.y;
+   newRect.y      = surfaceSize.width - (rect.x + rect.width);
+   newRect.width  = rect.height;
+   newRect.height = rect.width;
+   return newRect;
+ }
+ using RecalculateRectFunction = Rect<int32_t> (*)(Rect<int32_t>&, const Rect<int32_t>&);
+ RecalculateRectFunction RecalculateRect[4] = {RecalculateRect0, RecalculateRect90, RecalculateRect180, RecalculateRect270};
  } // unnamed namespace
  
  WindowRenderSurface::WindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent)
@@@ -390,8 -429,6 +429,8 @@@ void WindowRenderSurface::StartRender(
  
  bool WindowRenderSurface::PreRender(bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect)
  {
 +  mDamagedRects.assign(damagedRects.begin(), damagedRects.end());
 +
    Dali::Integration::Scene::FrameCallbackContainer callbacks;
  
    Dali::Integration::Scene scene = mScene.GetHandle();
      }
    }
  
 -  MakeContextCurrent();
 -
    /**
      * wl_egl_window_tizen_set_rotation(SetEglWindowRotation)                -> PreRotation
      * wl_egl_window_tizen_set_buffer_transform(SetEglWindowBufferTransform) -> Screen Rotation
      *          because output transform event should be occured before egl window is not created.
      */
  
 -  if(resizingSurface || mDefaultScreenRotationAvailable)
 +  if(mIsResizing || mDefaultScreenRotationAvailable)
    {
      int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
  
      mDefaultScreenRotationAvailable = false;
    }
  
 -  SetBufferDamagedRects(damagedRects, clippingRect);
 +  SetBufferDamagedRects(mDamagedRects, clippingRect);
 +
 +  if(clippingRect.IsEmpty())
 +  {
 +    mDamagedRects.clear();
 +  }
 +
 +  // This is now done when the render pass for the render surface begins
 +  //  MakeContextCurrent();
  
    return true;
  }
  
 -void WindowRenderSurface::PostRender(bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects)
 +void WindowRenderSurface::PostRender()
  {
    // Inform the gl implementation that rendering has finished before informing the surface
    auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
      GlImplementation& mGLES = eglGraphics->GetGlesInterface();
      mGLES.PostRender();
  
 -    if(renderToFbo)
 +    if(mIsResizing)
      {
 -      mGLES.Flush();
 -      mGLES.Finish();
 -    }
 -    else
 -    {
 -      if(resizingSurface)
 +      if(!mWindowRotationFinished)
        {
 -        if(!mWindowRotationFinished)
 +        if(mThreadSynchronization)
          {
 -          if(mThreadSynchronization)
 -          {
 -            // Enable PostRender flag
 -            mThreadSynchronization->PostRenderStarted();
 -          }
 +          // Enable PostRender flag
 +          mThreadSynchronization->PostRenderStarted();
 +        }
  
 -          DALI_LOG_RELEASE_INFO("WindowRenderSurface::PostRender: Trigger rotation event\n");
 +        DALI_LOG_RELEASE_INFO("WindowRenderSurface::PostRender: Trigger rotation event\n");
  
 -          mRotationTrigger->Trigger();
 +        mRotationTrigger->Trigger();
  
 -          if(mThreadSynchronization)
 -          {
 -            // Wait until the event-thread complete the rotation event processing
 -            mThreadSynchronization->PostRenderWaitForCompletion();
 -          }
 +        if(mThreadSynchronization)
 +        {
 +          // Wait until the event-thread complete the rotation event processing
 +          mThreadSynchronization->PostRenderWaitForCompletion();
          }
        }
      }
  
 -    SwapBuffers(damagedRects);
 +    SwapBuffers(mDamagedRects);
  
      if(mRenderNotification)
      {
@@@ -738,8 -777,16 +777,16 @@@ void WindowRenderSurface::SetBufferDama
        return;
      }
  
-     std::vector<Rect<int>> damagedRegion;
-     damagedRegion.push_back(clippingRect);
+     std::vector<Rect<int>>   damagedRegion;
+     Dali::Integration::Scene scene = mScene.GetHandle();
+     if(scene)
+     {
+       damagedRegion.push_back(RecalculateRect[std::min(scene.GetCurrentSurfaceOrientation() / 90, 3)](clippingRect, scene.GetCurrentSurfaceRect()));
+     }
+     else
+     {
+       damagedRegion.push_back(clippingRect);
+     }
  
      eglImpl.SetDamageRegion(mEGLSurface, damagedRegion);
    }
@@@ -750,7 -797,15 +797,15 @@@ void WindowRenderSurface::SwapBuffers(c
    auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
    if(eglGraphics)
    {
-     Rect<int> surfaceRect(0, 0, mPositionSize.width, mPositionSize.height);
+     Rect<int32_t> surfaceRect;
+     int32_t       orientation = 0;
+     Dali::Integration::Scene scene = mScene.GetHandle();
+     if(scene)
+     {
+       surfaceRect = scene.GetCurrentSurfaceRect();
+       orientation = std::min(scene.GetCurrentSurfaceOrientation() / 90, 3);
+     }
  
      Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
  
      {
        if(!mergedRects[i].IsEmpty())
        {
-         mergedRects[j++] = mergedRects[i];
+         mergedRects[j++] = RecalculateRect[orientation](mergedRects[i], surfaceRect);
        }
      }