+struct GraphicsStencilOp
+{
+ constexpr explicit GraphicsStencilOp(StencilOperation::Type stencilOp)
+ {
+ switch(stencilOp)
+ {
+ case Dali::StencilOperation::KEEP:
+ op = Graphics::StencilOp::KEEP;
+ break;
+ case Dali::StencilOperation::ZERO:
+ op = Graphics::StencilOp::ZERO;
+ break;
+ case Dali::StencilOperation::REPLACE:
+ op = Graphics::StencilOp::REPLACE;
+ break;
+ case Dali::StencilOperation::INCREMENT:
+ op = Graphics::StencilOp::INCREMENT_AND_CLAMP;
+ break;
+ case Dali::StencilOperation::DECREMENT:
+ op = Graphics::StencilOp::DECREMENT_AND_CLAMP;
+ break;
+ case Dali::StencilOperation::INVERT:
+ op = Graphics::StencilOp::INVERT;
+ break;
+ case Dali::StencilOperation::INCREMENT_WRAP:
+ op = Graphics::StencilOp::INCREMENT_AND_WRAP;
+ break;
+ case Dali::StencilOperation::DECREMENT_WRAP:
+ op = Graphics::StencilOp::DECREMENT_AND_WRAP;
+ break;
+ }
+ }
+ Graphics::StencilOp op{Graphics::StencilOp::KEEP};
+};
+
+inline Graphics::Viewport ViewportFromClippingBox(const Uint16Pair& sceneSize, ClippingBox clippingBox, int orientation)
+{
+ Graphics::Viewport viewport{static_cast<float>(clippingBox.x), static_cast<float>(clippingBox.y), static_cast<float>(clippingBox.width), static_cast<float>(clippingBox.height), 0.0f, 0.0f};
+
+ if(orientation == 90 || orientation == 270)
+ {
+ if(orientation == 90)
+ {
+ viewport.x = sceneSize.GetY() - (clippingBox.y + clippingBox.height);
+ viewport.y = clippingBox.x;
+ }
+ else // orientation == 270
+ {
+ viewport.x = clippingBox.y;
+ viewport.y = sceneSize.GetX() - (clippingBox.x + clippingBox.width);
+ }
+ viewport.width = static_cast<float>(clippingBox.height);
+ viewport.height = static_cast<float>(clippingBox.width);
+ }
+ else if(orientation == 180)
+ {
+ viewport.x = sceneSize.GetX() - (clippingBox.x + clippingBox.width);
+ viewport.y = sceneSize.GetY() - (clippingBox.y + clippingBox.height);
+ }
+ return viewport;
+}
+
+inline Graphics::Rect2D RecalculateRect(Graphics::Rect2D rect, int orientation, Graphics::Viewport viewport)
+{
+ Graphics::Rect2D newRect;
+
+ // scissor's value should be set based on the default system coordinates.
+ // when the surface is rotated, the input valus already were set with the rotated angle.
+ // So, re-calculation is needed.
+ if(orientation == 90)
+ {
+ newRect.x = viewport.height - (rect.y + rect.height);
+ newRect.y = rect.x;
+ newRect.width = rect.height;
+ newRect.height = rect.width;
+ }
+ else if(orientation == 180)
+ {
+ newRect.x = viewport.width - (rect.x + rect.width);
+ newRect.y = viewport.height - (rect.y + rect.height);
+ newRect.width = rect.width;
+ newRect.height = rect.height;
+ }
+ else if(orientation == 270)
+ {
+ newRect.x = rect.y;
+ newRect.y = viewport.width - (rect.x + rect.width);
+ newRect.width = rect.height;
+ newRect.height = rect.width;
+ }
+ else
+ {
+ newRect.x = rect.x;
+ newRect.y = rect.y;
+ newRect.width = rect.width;
+ newRect.height = rect.height;
+ }
+ return newRect;
+}