------------------------------------------------------------------------------
| 2077 | |
| 2078 | //------------------------------------------------------------------------------ |
| 2079 | void vtkOpenGLContextDevice2D::SetClipping(int* dim) |
| 2080 | { |
| 2081 | // If the window is using tile scaling, we need to update the clip coordinates |
| 2082 | // relative to the tile being rendered. |
| 2083 | // (see paraview/paraview#17308) |
| 2084 | double tileViewPort[4]; |
| 2085 | this->Renderer->GetVTKWindow()->GetTileViewport(tileViewPort); |
| 2086 | this->Renderer->NormalizedDisplayToDisplay(tileViewPort[0], tileViewPort[1]); |
| 2087 | this->Renderer->NormalizedDisplayToDisplay(tileViewPort[2], tileViewPort[3]); |
| 2088 | |
| 2089 | vtkRecti tileRect{ vtkContext2D::FloatToInt(tileViewPort[0]), |
| 2090 | vtkContext2D::FloatToInt(tileViewPort[1]), 0, 0 }; |
| 2091 | tileRect.AddPoint( |
| 2092 | vtkContext2D::FloatToInt(tileViewPort[2]), vtkContext2D::FloatToInt(tileViewPort[3])); |
| 2093 | // tileRect is the tile being rendered in the current RenderWindow in pixels. |
| 2094 | |
| 2095 | double viewport[4]; |
| 2096 | this->Renderer->GetViewport(viewport); |
| 2097 | this->Renderer->NormalizedDisplayToDisplay(viewport[0], viewport[1]); |
| 2098 | this->Renderer->NormalizedDisplayToDisplay(viewport[2], viewport[3]); |
| 2099 | vtkRecti rendererRect{ vtkContext2D::FloatToInt(viewport[0]), |
| 2100 | vtkContext2D::FloatToInt(viewport[1]), 0, 0 }; |
| 2101 | rendererRect.AddPoint( |
| 2102 | vtkContext2D::FloatToInt(viewport[2]), vtkContext2D::FloatToInt(viewport[3])); |
| 2103 | // rendererRect is the viewport in pixels. |
| 2104 | |
| 2105 | // `dim` is specified as (x,y,width,height) relative to the viewport that this |
| 2106 | // prop is rendering in. So let's fit it in the viewport rect i.e. |
| 2107 | // rendererRect |
| 2108 | vtkRecti clipRect{ dim[0], dim[1], dim[2], dim[3] }; |
| 2109 | clipRect.MoveTo(clipRect.GetX() + rendererRect.GetX(), clipRect.GetY() + rendererRect.GetY()); |
| 2110 | clipRect.Intersect(rendererRect); |
| 2111 | |
| 2112 | // Now, clamp the clipRect to the region being shown on the current tile. This |
| 2113 | // generally has no effect since clipRect is wholly contained in tileRect |
| 2114 | // unless tile scaling was being used. In either case, this method will return |
| 2115 | // true as long as the rectangle intersection will produce a valid rectangle. |
| 2116 | if (clipRect.Intersect(tileRect)) |
| 2117 | { |
| 2118 | // offset clipRect relative to current tile i.e. window. |
| 2119 | clipRect.MoveTo(clipRect.GetX() - tileRect.GetX(), clipRect.GetY() - tileRect.GetY()); |
| 2120 | } |
| 2121 | else |
| 2122 | { |
| 2123 | // clipping region results in empty region, just set to empty. |
| 2124 | clipRect = vtkRecti{ 0, 0, 0, 0 }; |
| 2125 | } |
| 2126 | |
| 2127 | assert(clipRect.GetWidth() >= 0 && clipRect.GetHeight() >= 0); |
| 2128 | |
| 2129 | this->RenderWindow->GetState()->vtkglScissor( |
| 2130 | clipRect.GetX(), clipRect.GetY(), clipRect.GetWidth(), clipRect.GetHeight()); |
| 2131 | } |
| 2132 | |
| 2133 | //------------------------------------------------------------------------------ |
| 2134 | void vtkOpenGLContextDevice2D::EnableClipping(bool enable) |
nothing calls this directly
no test coverage detected