diff --git a/.ai/memory/architecture/activex.md b/.ai/memory/architecture/activex.md index 8980fd6..d41661c 100644 --- a/.ai/memory/architecture/activex.md +++ b/.ai/memory/architecture/activex.md @@ -67,8 +67,10 @@ The control exposes a deliberately small v6 automation API. It does not expose the broad MapWinGIS 5 map, layer, shape, event, or editing surface. The current render scene is built in source coordinates, without reprojection; backend support differs: GDI draws the original rings with an alternate fill rule, -while OpenGL fills the Core-prepared triangulated meshes and declines scenes -whose polygons lack a usable mesh so the coordinator falls back to GDI. +while OpenGL fill draws require explicitly prepared meshes. Normal Core scene +creation is mesh-free; fill operations without usable meshes fall back to +GDI, which fills the original rings. The OpenGL renderer also has an +outline mode that draws those rings without triangulation. Consult the current implementation and architecture documentation before assuming a capability or compatibility guarantee. diff --git a/.github/plans/Vector-Rendering-Performance-Improvement.md b/.github/plans/Vector-Rendering-Performance-Improvement.md index c034507..041f53a 100644 --- a/.github/plans/Vector-Rendering-Performance-Improvement.md +++ b/.github/plans/Vector-Rendering-Performance-Improvement.md @@ -9,7 +9,10 @@ Copilot: Update this checklist as each phase is implemented. Only mark a phase c - Measured the supplied 10.3 MB, 2,459-feature shapefile with all A-D configurations; results are recorded in the Phase 1 benchmark section below. - Limitation: the measured shapefile is not stored in the repository; `MWG_RENDERING_BASELINE_DATASET` can rerun it when available. - Limitation: configuration C records the current OpenGL rejection because outline-only OpenGL rendering is a Phase 2 change. -- [ ] **Phase 2 – Separate geometry loading from rendering preparation** (PR 2) +- [x] **Phase 2 – Separate geometry loading from rendering preparation** (PR 2) + - Normal scene construction now preserves source rings and bounds without triangulating polygons; fill meshes remain available through explicit preparation. + - GDI fills directly from source rings, and OpenGL can draw mesh-free polygon outlines while fill requests retain the existing mesh requirement and GDI fallback. + - Limitation: OpenGL fill meshes are prepared explicitly rather than generated lazily; lazy triangulation and cache reuse remain Phase 3 and Phase 4 work. - [ ] **Phase 3 – Implement lazy polygon triangulation** (PR 3) - [ ] **Phase 4 – Add intelligent caching and invalidation** (PR 4) - [ ] **Phase 5 – Introduce viewport-aware geometry processing** (PR 5) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 9111858..14133c7 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -323,19 +323,20 @@ Rendering consumes backend-neutral input prepared from core data; neither the coordinator nor a backend loads datasets or implements GIS rules. For each visible map layer, Core sequentially reads Polygon, MultiPolygon, CurvePolygon, and MultiSurface features into an owned vector scene, -linearizing curved geometries. Scene creation also triangulates every polygon -into an indexed, backend-neutral triangle mesh with the constrained Delaunay -triangulation of GDAL/OGR and GEOS, retained per polygon so a backend never -triangulates per frame; a polygon that cannot be triangulated keeps its rings -and has no mesh. `ViewTransform` captures the `Viewport` once +linearizing curved geometries. Scene creation preserves source rings and +rendering metadata without triangulating polygons. A caller can explicitly +request fill-mesh preparation when a fill operation needs indexed, +backend-neutral triangles; a polygon that cannot be triangulated keeps its +rings and has no mesh. `ViewTransform` captures the `Viewport` once per frame so both backends transform every vertex of every layer with the same arithmetic as `Viewport::MapToScreen`; GDI draws a screen position in the pixel that contains it (`ToPixel`). One backend draws the whole frame. The coordinator tries the OpenGL backend when every polygon of every layer -has a triangulated fill mesh. GDI checks each layer before drawing it; a -layer with non-finite or out-of-range device coordinates is skipped and -reported (`GetFailedLayers`, `RenderingStatus`) while the other layers are -still drawn. +has a triangulated fill mesh for a fill draw. OpenGL outline mode draws the +source rings without requiring fill meshes. GDI checks each layer before +drawing it; a layer with non-finite or out-of-range device coordinates is +skipped and reported (`GetFailedLayers`, `RenderingStatus`) while the other +layers are still drawn. OpenGL uses a context created on a hidden, never-presented window, draws with fixed-function calls into a framebuffer object (OpenGL 3.0 or `GL_EXT_framebuffer_object`), and reads pixels back in BGRA order into a CPU @@ -349,10 +350,10 @@ This avoids a fresh allocation for every polygon's transformed triangle vertices Rendering into a framebuffer object avoids undefined pixels from window pixel-ownership rules. Presentation still copies pixels through GDI. Interior rings and concave boundaries draw identically in both backends -because both consume the same scene; a polygon without a fill mesh (for -example a self-intersecting ring that GEOS cannot triangulate), missing -framebuffer-object support, initialization failures, and drawing failures use -the GDI backend, which draws the original rings. +because both consume the same scene. A fill request without a usable mesh, +missing framebuffer-object support, initialization failures, and drawing +failures use the GDI backend. GDI fills and outlines the original rings, so +a self-intersecting ring that GEOS cannot triangulate can still be displayed. The GDI backend draws the original rings of the whole supported polygon scene, including its interior rings and concave boundaries. Both backends draw source coordinates without reprojection, and scene preparation currently supports Polygon, MultiPolygon, CurvePolygon, @@ -486,9 +487,9 @@ and `Ring` types remain available for caller-created triangulation input. There is no tiling, paging, or clipping to the visible extent. GDI skips a layer whose device coordinates exceed its range. It clips drawing to the requested target rectangle and the host's existing clip region, then restores -the device context. Triangulation runs once per polygon when the scene is -prepared; view changes (resize, zoom, pan) and redraws reuse the retained -meshes. The opt-in +the device context. Fill triangulation runs only when scene preparation +explicitly requests it; view changes (resize, zoom, pan) and redraws reuse +the retained meshes. The opt-in rendering baseline (see [TESTING.md](TESTING.md#rendering-performance-baseline)) tracks scene preparation, mesh storage, and backend frame costs on both a convex grid and a complex mix of concave, holed multipart, and many-vertex diff --git a/docs/TESTING.md b/docs/TESTING.md index 79869c2..f21b862 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -204,10 +204,11 @@ The `RenderingBaseline` tests are opt-in. They use either a generated GeoPackage grid of convex 32-vertex polygons or the dataset named by `MWG_RENDERING_BASELINE_DATASET`. `MeasuresTriangulationDisabledCosts` builds a mesh-free scene (configuration A for GDI, which still fills the original rings, -and configuration C for OpenGL, which rejects it). -`MeasuresCoreSceneAndBackendCosts` uses the default fill-mesh preparation +and configuration C for OpenGL outline-only rendering). +`MeasuresCoreSceneAndBackendCosts` explicitly requests fill-mesh preparation (configurations B and D). Successful backends report first and steady frame -times, plus pan and zoom frames, for a 1280x720 off-screen target. +times, plus pan and zoom frames, for a 1280x720 off-screen target. Normal scene +creation does not perform triangulation. Performance diagnostics are disabled by default and aggregate process-wide timings with `std::chrono::steady_clock`. The collector records dataset @@ -223,8 +224,8 @@ GPU buffer-upload stage to measure yet. concave L-shaped polygons, holed rectangles where every feature is a two-component multipolygon, and concave 32-vertex star polygons across three layers — and additionally reports the number of triangulated polygons and the -mesh storage (vertices plus indices). Scene preparation in both tests -includes the one-time constrained Delaunay triangulation of every polygon. +mesh storage (vertices plus indices). Its scene preparation explicitly +requests the one-time constrained Delaunay triangulation of every polygon. Results are recorded as GoogleTest properties; the tests fail only when a stage fails. Use a Release build for meaningful numbers: @@ -263,12 +264,11 @@ submission took 5.3 ms. These measurements show scene triangulation is the dominant opening cost on the generated grid, without assuming it is the only cost for other datasets. -Configuration C is intentionally reported as a rejection rather than a -successful outline render: the current OpenGL backend requires a triangle -mesh for every polygon. Measuring successful triangulation-free OpenGL -outlines is a Phase 2 deliverable. Viewport culling and its skipped-feature -counter remain zero because scene construction currently processes all -features. +Configuration C records the Phase 1 rejection because that baseline predates +the mesh-free OpenGL outline mode. The baseline test now exercises that +outline mode directly when OpenGL is available. Viewport culling and its +skipped-feature counter remain zero because scene construction currently +processes all features. Previous measurements on one developer workstation, with triangulation included in scene preparation, remain useful as history: diff --git a/src/MapWinGIS.ActiveX/GdiVectorLayerRenderer.cpp b/src/MapWinGIS.ActiveX/GdiVectorLayerRenderer.cpp index 53b9887..f28a161 100644 --- a/src/MapWinGIS.ActiveX/GdiVectorLayerRenderer.cpp +++ b/src/MapWinGIS.ActiveX/GdiVectorLayerRenderer.cpp @@ -213,7 +213,8 @@ namespace mwg::activex const RECT& bounds, const rendering::MapRenderScene& scene, const Viewport& viewport, - const bool) noexcept + const bool, + const VectorRenderMode renderMode) noexcept { const diagnostics::PerformanceScope scope( diagnostics::PerformanceOperation::FrameRender); @@ -252,14 +253,18 @@ namespace mwg::activex return S_OK; } - const ScopedGdiObject brush(CreateSolidBrush(kFillColor)); + const ScopedGdiObject fillBrush( + renderMode == VectorRenderMode::Fill ? CreateSolidBrush(kFillColor) : nullptr); + const HGDIOBJ brush = renderMode == VectorRenderMode::Fill + ? fillBrush.Get() + : GetStockObject(NULL_BRUSH); const ScopedGdiObject pen(CreatePen(PS_SOLID, 1, kOutlineColor)); - if (brush.Get() == nullptr || pen.Get() == nullptr) + if (brush == nullptr || pen.Get() == nullptr) { return E_OUTOFMEMORY; } - const ScopedSelection selectedBrush(deviceContext, brush.Get()); + const ScopedSelection selectedBrush(deviceContext, brush); const ScopedSelection selectedPen(deviceContext, pen.Get()); if (!selectedBrush.IsValid() || !selectedPen.IsValid() || SetPolyFillMode(deviceContext, ALTERNATE) == 0) diff --git a/src/MapWinGIS.ActiveX/GdiVectorLayerRenderer.h b/src/MapWinGIS.ActiveX/GdiVectorLayerRenderer.h index 93d1016..dd5af7f 100644 --- a/src/MapWinGIS.ActiveX/GdiVectorLayerRenderer.h +++ b/src/MapWinGIS.ActiveX/GdiVectorLayerRenderer.h @@ -28,7 +28,8 @@ namespace mwg::activex const RECT& bounds, const rendering::MapRenderScene& scene, const Viewport& viewport, - bool retainStagingBuffer = true) noexcept override; + bool retainStagingBuffer = true, + VectorRenderMode renderMode = VectorRenderMode::Fill) noexcept override; /// Layers skipped by the last Draw call, in drawing order. [[nodiscard]] const std::vector& GetFailedLayers() const noexcept diff --git a/src/MapWinGIS.ActiveX/OpenGlVectorLayerRenderer.cpp b/src/MapWinGIS.ActiveX/OpenGlVectorLayerRenderer.cpp index df8a4db..911e1b6 100644 --- a/src/MapWinGIS.ActiveX/OpenGlVectorLayerRenderer.cpp +++ b/src/MapWinGIS.ActiveX/OpenGlVectorLayerRenderer.cpp @@ -2,16 +2,15 @@ /** * @file OpenGlVectorLayerRenderer.cpp - * @brief Renders triangulated polygon scenes with WGL and copies pixels to GDI. + * @brief Renders polygon fills or outlines with WGL and copies pixels to GDI. * * Owns one reusable OpenGL context and draws into a framebuffer object so * pixel readback is not subject to window pixel-ownership rules. Polygon - * fills use the indexed triangle meshes prepared by the Core render scene; - * outlines follow the original rings. Each polygon is filled and outlined - * before the next one is drawn, matching the GDI backend's painter order. - * Scenes with polygons that lack a - * usable mesh, or systems without framebuffer objects, return S_FALSE so - * the coordinator can use its GDI backend. + * fills use indexed triangle meshes prepared explicitly by Core; outlines + * follow the original rings and do not require meshes. Each polygon is drawn + * completely before the next one, matching the GDI backend's painter order. + * Fill scenes with polygons that lack a usable mesh, or systems without + * framebuffer objects, return S_FALSE so the coordinator can use GDI. */ #include "OpenGlVectorLayerRenderer.h" @@ -171,12 +170,11 @@ namespace mwg::activex return true; } - /// Returns true when every polygon of the scene has a usable - /// triangulated fill mesh and finite coordinates. Meshes are - /// prepared once when the Core scene is created; a polygon without - /// one cannot be filled correctly, so the whole frame is reported - /// as unsupported and the coordinator uses GDI. - [[nodiscard]] bool IsSupported(const rendering::MapRenderScene& scene) noexcept + /// Returns true when the scene has finite ring coordinates and, in + /// fill mode, one usable mesh per polygon. + [[nodiscard]] bool IsSupported( + const rendering::MapRenderScene& scene, + const VectorRenderMode renderMode) noexcept { for (const rendering::LayerRenderScene& layer : scene.layers) { @@ -185,18 +183,24 @@ namespace mwg::activex return false; } const rendering::VectorRenderScene& vectorScene = *layer.scene; - if (vectorScene.fillMeshes.size() != vectorScene.polygons.size()) + if (renderMode == VectorRenderMode::Fill && + vectorScene.fillMeshes.size() != vectorScene.polygons.size()) { return false; } - for (std::size_t index = 0; index < vectorScene.polygons.size(); ++index) + if (renderMode == VectorRenderMode::Fill) { - const std::optional& mesh = - vectorScene.fillMeshes[index]; - if (!mesh.has_value() || !IsMeshUsable(*mesh)) + for (std::size_t index = 0; + index < vectorScene.polygons.size(); + ++index) { - return false; + const std::optional& mesh = + vectorScene.fillMeshes[index]; + if (!mesh.has_value() || !IsMeshUsable(*mesh)) + { + return false; + } } } for (const rendering::Point& point : vectorScene.polygons.Coordinates()) @@ -285,33 +289,42 @@ namespace mwg::activex } } - /// Draws one layer polygon by polygon, filling each polygon from its - /// triangulated mesh and outlining its rings before advancing to the - /// next one, so overlapping polygons keep the same painter order as - /// the GDI backend. + /// Draws one layer polygon by polygon. Fill mode uses prepared meshes; + /// both modes outline the original rings. Overlapping polygons retain + /// the same painter order as the GDI backend. [[nodiscard]] HRESULT DrawLayer( const rendering::VectorRenderScene& scene, - const ViewTransform& transform) noexcept + const ViewTransform& transform, + const VectorRenderMode renderMode) noexcept { const diagnostics::PerformanceScope submissionScope( diagnostics::PerformanceOperation::OpenGlGeometrySubmission); - glEnableClientState(GL_VERTEX_ARRAY); + if (renderMode == VectorRenderMode::Fill) + { + glEnableClientState(GL_VERTEX_ARRAY); + } std::vector deviceVertices; for (std::size_t index = 0; index < scene.polygons.size(); ++index) { - glColor3ub(61, 122, 169); - const HRESULT fillResult = - DrawPolygonFill(*scene.fillMeshes[index], transform, deviceVertices); - if (FAILED(fillResult)) + if (renderMode == VectorRenderMode::Fill) { - glDisableClientState(GL_VERTEX_ARRAY); - return fillResult; + glColor3ub(61, 122, 169); + const HRESULT fillResult = + DrawPolygonFill(*scene.fillMeshes[index], transform, deviceVertices); + if (FAILED(fillResult)) + { + glDisableClientState(GL_VERTEX_ARRAY); + return fillResult; + } } glColor3ub(24, 58, 82); DrawPolygonOutlines(scene.polygons[index], transform); } - glDisableClientState(GL_VERTEX_ARRAY); + if (renderMode == VectorRenderMode::Fill) + { + glDisableClientState(GL_VERTEX_ARRAY); + } return S_OK; } @@ -329,9 +342,10 @@ namespace mwg::activex OpenGlVectorLayerRenderer::OpenGlVectorLayerRenderer() noexcept = default; bool OpenGlVectorLayerRenderer::IsSceneSupported( - const rendering::MapRenderScene& scene) noexcept + const rendering::MapRenderScene& scene, + const VectorRenderMode renderMode) noexcept { - return IsSupported(scene); + return IsSupported(scene, renderMode); } OpenGlVectorLayerRenderer::~OpenGlVectorLayerRenderer() @@ -587,7 +601,8 @@ namespace mwg::activex const HDC deviceContext, const RECT& bounds, const rendering::MapRenderScene& scene, - const Viewport& viewport) noexcept + const Viewport& viewport, + const VectorRenderMode renderMode) noexcept { if (deviceContext == nullptr) { @@ -602,11 +617,13 @@ namespace mwg::activex return {E_INVALIDARG, std::nullopt}; } - if (!IsSupported(scene)) + if (!IsSupported(scene, renderMode)) { - _lastFailureReason = - L"The OpenGL backend requires a triangulated fill mesh for " - L"every polygon; this frame was rendered with GDI."; + _lastFailureReason = renderMode == VectorRenderMode::Fill + ? L"The OpenGL backend requires a triangulated fill mesh for " + L"every polygon; this frame was rendered with GDI." + : L"The OpenGL backend requires finite polygon coordinates for " + L"outline rendering; this frame was rendered with GDI."; return {S_FALSE, std::nullopt}; } @@ -664,7 +681,8 @@ namespace mwg::activex HRESULT OpenGlVectorLayerRenderer::RenderScene( const rendering::MapRenderScene& scene, const Viewport& viewport, - const Target& target) noexcept + const Target& target, + const VectorRenderMode renderMode) noexcept { const auto transform = ViewTransform::Create(viewport); if (!transform.has_value()) @@ -722,7 +740,8 @@ namespace mwg::activex for (const rendering::LayerRenderScene& layer : scene.layers) { // IsSupported above rejected null layer scenes. - const HRESULT layerResult = DrawLayer(*layer.scene, *transform); + const HRESULT layerResult = + DrawLayer(*layer.scene, *transform, renderMode); if (FAILED(layerResult)) { _lastFailureReason = L"OpenGL could not allocate its vertex buffers."; @@ -830,7 +849,8 @@ namespace mwg::activex const RECT& bounds, const rendering::MapRenderScene& scene, const Viewport& viewport, - const bool retainStagingBuffer) noexcept + const bool retainStagingBuffer, + const VectorRenderMode renderMode) noexcept { if (!retainStagingBuffer) { @@ -844,7 +864,13 @@ namespace mwg::activex temporaryRenderer._retryTargetHeight = _retryTargetHeight; temporaryRenderer._initializationRetryDrawsRemaining = _initializationRetryDrawsRemaining; - const HRESULT result = temporaryRenderer.Draw(deviceContext, bounds, scene, viewport); + const HRESULT result = temporaryRenderer.Draw( + deviceContext, + bounds, + scene, + viewport, + true, + renderMode); _lastFailureReason = temporaryRenderer.GetLastFailureReason(); _initializationFailed = temporaryRenderer._initializationFailed; _initializationFailureReason = temporaryRenderer._initializationFailureReason; @@ -858,7 +884,7 @@ namespace mwg::activex diagnostics::PerformanceOperation::FrameRender); _lastFailureReason = L"OpenGL did not render this frame."; const TargetValidation validation = - ValidateTarget(deviceContext, bounds, scene, viewport); + ValidateTarget(deviceContext, bounds, scene, viewport, renderMode); if (!validation.target.has_value()) { return validation.result; @@ -921,7 +947,8 @@ namespace mwg::activex return S_FALSE; } - const HRESULT renderResult = RenderScene(scene, viewport, target); + const HRESULT renderResult = + RenderScene(scene, viewport, target, renderMode); if (FAILED(renderResult) || renderResult == S_FALSE) { return renderResult; diff --git a/src/MapWinGIS.ActiveX/OpenGlVectorLayerRenderer.h b/src/MapWinGIS.ActiveX/OpenGlVectorLayerRenderer.h index 177e5a2..f737eee 100644 --- a/src/MapWinGIS.ActiveX/OpenGlVectorLayerRenderer.h +++ b/src/MapWinGIS.ActiveX/OpenGlVectorLayerRenderer.h @@ -2,7 +2,7 @@ /** * @file OpenGlVectorLayerRenderer.h - * @brief Declares the WGL-backed polygon scene renderer. + * @brief Declares the WGL-backed polygon fill and outline renderer. * * The backend owns a reusable OpenGL context, created on a hidden window that * is never presented, and renders into a framebuffer object before copying @@ -52,14 +52,15 @@ namespace mwg::activex int maximumHeight) noexcept; /** - * @brief Draws a scene of triangulated polygons. + * @brief Draws polygon fills or outlines through OpenGL. * - * Fills every polygon from the Core-prepared triangle mesh and draws - * its outlines from the original rings before advancing to the next - * polygon, matching the GDI backend's painter order within a layer. + * Fill mode uses a Core-prepared triangle mesh for each polygon and + * draws boundaries from the original rings. Outline mode draws the + * original rings without requiring fill meshes. Polygons retain the + * GDI backend's painter order within a layer. * Draws all layers into one frame, bottom first. Returns S_FALSE - * without drawing when any polygon lacks a usable fill mesh or when - * no OpenGL context with framebuffer-object support is available, so + * without drawing when fill mode lacks a usable mesh or when no + * OpenGL context with framebuffer-object support is available, so * callers can fall back to another backend for the whole frame. * When retainStagingBuffer is false, a temporary renderer owns the * draw's CPU and GPU buffers, leaving the screen resources unchanged. @@ -69,7 +70,8 @@ namespace mwg::activex const RECT& bounds, const rendering::MapRenderScene& scene, const Viewport& viewport, - bool retainStagingBuffer = true) noexcept override; + bool retainStagingBuffer = true, + VectorRenderMode renderMode = VectorRenderMode::Fill) noexcept override; [[nodiscard]] std::wstring_view GetLastFailureReason() const noexcept { @@ -80,11 +82,12 @@ namespace mwg::activex friend class testing::OpenGlVectorLayerRendererTestAccess; friend class testing::MapWinGISControlTestAccess; - /// True when every polygon of the scene has a usable triangulated - /// fill mesh and finite coordinates. Exposed for tests so geometry - /// support decisions can be checked without an OpenGL context. + /// True when the scene can be drawn in the requested mode. Outline + /// mode needs finite ring coordinates; fill mode additionally needs + /// a usable mesh for every polygon. Exposed for tests. [[nodiscard]] static bool IsSceneSupported( - const rendering::MapRenderScene& scene) noexcept; + const rendering::MapRenderScene& scene, + VectorRenderMode renderMode) noexcept; void SimulateContextLoss() noexcept; @@ -110,12 +113,14 @@ namespace mwg::activex HDC deviceContext, const RECT& bounds, const rendering::MapRenderScene& scene, - const Viewport& viewport) noexcept; + const Viewport& viewport, + VectorRenderMode renderMode) noexcept; [[nodiscard]] bool EnsureStaging(std::size_t stagingBytes) noexcept; [[nodiscard]] HRESULT RenderScene( const rendering::MapRenderScene& scene, const Viewport& viewport, - const Target& target) noexcept; + const Target& target, + VectorRenderMode renderMode) noexcept; [[nodiscard]] HRESULT CopyToDeviceContext( HDC deviceContext, const RECT& bounds, diff --git a/src/MapWinGIS.ActiveX/VectorLayerRenderer.cpp b/src/MapWinGIS.ActiveX/VectorLayerRenderer.cpp index ea570bd..31217b6 100644 --- a/src/MapWinGIS.ActiveX/VectorLayerRenderer.cpp +++ b/src/MapWinGIS.ActiveX/VectorLayerRenderer.cpp @@ -16,14 +16,21 @@ namespace mwg::activex const RECT& bounds, const rendering::MapRenderScene& scene, const Viewport& viewport, - const bool retainStagingBuffer) noexcept + const bool retainStagingBuffer, + const VectorRenderMode renderMode) noexcept { _activeBackend.reset(); if (_preference != VectorRenderBackendPreference::Gdi) { const HRESULT openGlResult = - _openGlRenderer.Draw(deviceContext, bounds, scene, viewport, retainStagingBuffer); + _openGlRenderer.Draw( + deviceContext, + bounds, + scene, + viewport, + retainStagingBuffer, + renderMode); if (openGlResult == S_OK) { _activeBackend = VectorRenderBackendKind::OpenGL; @@ -43,7 +50,8 @@ namespace mwg::activex _diagnostic = L"GDI was selected by the rendering preference."; } - const HRESULT gdiResult = _gdiRenderer.Draw(deviceContext, bounds, scene, viewport); + const HRESULT gdiResult = + _gdiRenderer.Draw(deviceContext, bounds, scene, viewport, true, renderMode); if (SUCCEEDED(gdiResult)) { _activeBackend = VectorRenderBackendKind::Gdi; diff --git a/src/MapWinGIS.ActiveX/VectorLayerRenderer.h b/src/MapWinGIS.ActiveX/VectorLayerRenderer.h index 8ebafec..fcc40aa 100644 --- a/src/MapWinGIS.ActiveX/VectorLayerRenderer.h +++ b/src/MapWinGIS.ActiveX/VectorLayerRenderer.h @@ -45,7 +45,8 @@ namespace mwg::activex const RECT& bounds, const rendering::MapRenderScene& scene, const Viewport& viewport, - bool retainStagingBuffer = true) noexcept; + bool retainStagingBuffer = true, + VectorRenderMode renderMode = VectorRenderMode::Fill) noexcept; /// Layers skipped by the last Draw call; empty when every layer was /// drawn. diff --git a/src/MapWinGIS.ActiveX/VectorRenderBackend.h b/src/MapWinGIS.ActiveX/VectorRenderBackend.h index 20c27ca..6449245 100644 --- a/src/MapWinGIS.ActiveX/VectorRenderBackend.h +++ b/src/MapWinGIS.ActiveX/VectorRenderBackend.h @@ -30,6 +30,14 @@ namespace mwg::activex Gdi }; + enum class VectorRenderMode : int + { + /// Draw polygon fills and outlines. + Fill, + /// Draw only boundaries from the source polygon rings. + Outline + }; + class IVectorRenderBackend { public: @@ -46,7 +54,8 @@ namespace mwg::activex const RECT& bounds, const rendering::MapRenderScene& scene, const Viewport& viewport, - bool retainStagingBuffer = true) noexcept = 0; + bool retainStagingBuffer = true, + VectorRenderMode renderMode = VectorRenderMode::Fill) noexcept = 0; }; /// True when bounds has the viewport's size and the viewport is valid. diff --git a/src/MapWinGIS.Core/include/mapwingis/rendering/MapRenderScene.h b/src/MapWinGIS.Core/include/mapwingis/rendering/MapRenderScene.h index 97d5846..06d0cde 100644 --- a/src/MapWinGIS.Core/include/mapwingis/rendering/MapRenderScene.h +++ b/src/MapWinGIS.Core/include/mapwingis/rendering/MapRenderScene.h @@ -84,8 +84,8 @@ namespace mwg::rendering /// Creates a map scene with explicit fill-preparation behavior. /// /// Hidden, empty, and failed layers retain the same handling as the - /// default overload. When prepareFillMeshes is false, every drawable - /// scene contains rings but no fill meshes. + /// default overload. Fill preparation is disabled by default, so drawable + /// layer scenes contain source rings without triangulating polygons. [[nodiscard]] MWG_CORE_API MapRenderScene CreateMapRenderScene( const Map& map, const VectorRenderSceneOptions& options); diff --git a/src/MapWinGIS.Core/include/mapwingis/rendering/VectorRenderScene.h b/src/MapWinGIS.Core/include/mapwingis/rendering/VectorRenderScene.h index 0040577..c091f1f 100644 --- a/src/MapWinGIS.Core/include/mapwingis/rendering/VectorRenderScene.h +++ b/src/MapWinGIS.Core/include/mapwingis/rendering/VectorRenderScene.h @@ -2,10 +2,11 @@ /** * @file VectorRenderScene.h - * @brief Declares backend-neutral polygon scene data for vector rendering. + * @brief Declares source polygon geometry and optional fill data for rendering. * * Stores scene coordinates and polygon/ring ranges in flat buffers. Borrowed * polygon views let renderers read them without per-polygon allocations. + * Fill meshes are prepared only when explicitly requested. */ #pragma once @@ -131,9 +132,9 @@ namespace mwg struct VectorRenderSceneOptions { /// When false, preserves polygon rings and leaves fillMeshes empty. - /// This is useful for baseline measurements and outline-only - /// backends; OpenGL currently requires fill meshes. - bool prepareFillMeshes = true; + /// Enable this only for a rendering operation that needs triangle + /// meshes. Source geometry and bounds are prepared either way. + bool prepareFillMeshes = false; }; /// Owned polygon geometry and its source-coordinate bounds. @@ -147,8 +148,8 @@ namespace mwg /// exterior ring of at least three points. std::int64_t skippedGeometryCount = 0; PolygonBuffer polygons; - /// Fill meshes prepared once when the scene is created. This is - /// empty when scene options disable fill preparation; otherwise + /// Optional fill meshes prepared when the scene is created. This + /// is empty when scene options omit fill preparation; otherwise /// fillMeshes[i] belongs to polygons[i]. An entry is std::nullopt /// when that polygon could not be triangulated; its rings remain /// available for outline drawing and for backends such as GDI. @@ -172,8 +173,9 @@ namespace mwg /// Creates a scene with explicit fill-preparation behavior. /// - /// Disabling fill meshes measures and renders only original polygon - /// geometry; the default overload remains unchanged. + /// The default is source geometry only. Set prepareFillMeshes to true + /// when the requested fill rendering operation needs triangle meshes. + /// The default overload never invokes polygon triangulation. [[nodiscard]] MWG_CORE_API VectorRenderScene CreateVectorRenderScene( const VectorLayer& layer, const VectorRenderSceneOptions& options); diff --git a/src/MapWinGIS.Core/src/rendering/VectorRenderScene.cpp b/src/MapWinGIS.Core/src/rendering/VectorRenderScene.cpp index 52f1b83..9fe9237 100644 --- a/src/MapWinGIS.Core/src/rendering/VectorRenderScene.cpp +++ b/src/MapWinGIS.Core/src/rendering/VectorRenderScene.cpp @@ -2,12 +2,13 @@ /** * @file VectorRenderScene.cpp - * @brief Builds owned polygon scene data from vector layers. + * @brief Builds owned polygon source geometry and optional fill meshes. * * Reads vector geometries sequentially and copies supported polygon * coordinates into owned scene data before releasing each feature. - * Unsupported or degenerate parts are skipped and counted rather than - * failing the layer. + * Triangulation is a separate, opt-in preparation step after source + * geometry conversion. Unsupported or degenerate parts are skipped and + * counted rather than failing the layer. */ #include "mapwingis/rendering/VectorRenderScene.h" diff --git a/tests/MapWinGIS.ActiveX.Tests/ActiveXActivationTests.cpp b/tests/MapWinGIS.ActiveX.Tests/ActiveXActivationTests.cpp index b2d4e84..ea55f77 100644 --- a/tests/MapWinGIS.ActiveX.Tests/ActiveXActivationTests.cpp +++ b/tests/MapWinGIS.ActiveX.Tests/ActiveXActivationTests.cpp @@ -1255,6 +1255,16 @@ namespace return _control->LoadVectorDataset(ATL::CComBSTR(path.c_str())); } + void LoadRectanglesWithFillMeshes(const std::vector& rectangles) + { + const auto path = mwg::test::MakeRectanglesDataset( + _directory.Path(), "layer-" + std::to_string(_datasetCount++) + ".gpkg", rectangles); + auto dataset = mwg::VectorDataset::Open(path); + mwg::activex::testing::MapWinGISControlTestAccess::AddLayerWithFillMeshes( + mwg::activex::testing::MapWinGISControlTestAccess::Control(_control.Get()), + std::move(dataset)); + } + HRESULT LoadLine() { const auto path = _directory.Path() / "line.geojson"; @@ -2293,15 +2303,22 @@ TEST_F(ActiveXMapTest, ScaledDrawsKeepScreenBuffersAtTheClientSize) { using Access = mwg::activex::testing::MapWinGISControlTestAccess; ASSERT_EQ(Resize(120, 100), S_OK); - ASSERT_EQ(LoadRectangles({{0, 0, 10, 5}}), S_OK); + LoadRectanglesWithFillMeshes({{0, 0, 10, 5}}); ASSERT_EQ(_control->put_RenderingBackendPreference(ATL::CComBSTR(L"OpenGL")), S_OK); BitmapSurface surface(480, 401); ASSERT_TRUE(surface.IsValid()); ASSERT_EQ(Draw(surface.Get(), 120, 100), S_OK); + ATL::CComBSTR backend; + ASSERT_EQ(_control->get_RenderingBackend(&backend), S_OK); + if (backend == nullptr || std::wcscmp(backend, L"OpenGL") != 0) + { + GTEST_SKIP() << "The control selected GDI for the OpenGL preference."; + } const auto& control = Access::Control(_control.Get()); const auto frameDc = Access::Frame(control).Get(); const auto cacheDc = Access::LayerCache(control).Get(); const auto capacity = Access::StagingCapacity(control); + ASSERT_GT(capacity, 0U); ASSERT_TRUE(Access::CacheValid(control)); ASSERT_EQ(Draw(surface.Get(), 480, 401), S_OK); EXPECT_EQ(Access::Frame(control).Width(), 120); diff --git a/tests/MapWinGIS.ActiveX.Tests/MapWinGISControlTestAccess.h b/tests/MapWinGIS.ActiveX.Tests/MapWinGISControlTestAccess.h index 6aabd92..14001b4 100644 --- a/tests/MapWinGIS.ActiveX.Tests/MapWinGISControlTestAccess.h +++ b/tests/MapWinGIS.ActiveX.Tests/MapWinGISControlTestAccess.h @@ -46,6 +46,21 @@ namespace mwg::activex::testing return control._renderer._openGlRenderer._pixelBuffer.capacity(); } + static LayerId AddLayerWithFillMeshes( + CMapWinGISControl& control, + std::shared_ptr dataset) + { + auto scene = mwg::rendering::CreateVectorRenderScene( + *dataset, + mwg::rendering::VectorRenderSceneOptions{ + .prepareFillMeshes = true}); + const auto featureCount = scene.sourceFeatureCount; + const auto id = control._view.AddLayer(std::move(dataset), std::move(scene)); + control._featureCount += featureCount; + control._layerCacheValid = false; + return id; + } + [[nodiscard]] static double Resolution(const CMapWinGISControl& control) { return control._view.GetViewport().Resolution().value(); diff --git a/tests/MapWinGIS.ActiveX.Tests/OpenGlVectorLayerRendererTestAccess.h b/tests/MapWinGIS.ActiveX.Tests/OpenGlVectorLayerRendererTestAccess.h index 39677b4..64ee6a2 100644 --- a/tests/MapWinGIS.ActiveX.Tests/OpenGlVectorLayerRendererTestAccess.h +++ b/tests/MapWinGIS.ActiveX.Tests/OpenGlVectorLayerRendererTestAccess.h @@ -50,9 +50,10 @@ namespace mwg::activex::testing /// Checks scene support without activating an OpenGL context. [[nodiscard]] static bool IsSceneSupported( - const rendering::MapRenderScene& scene) noexcept + const rendering::MapRenderScene& scene, + const VectorRenderMode renderMode = VectorRenderMode::Fill) noexcept { - return OpenGlVectorLayerRenderer::IsSceneSupported(scene); + return OpenGlVectorLayerRenderer::IsSceneSupported(scene, renderMode); } }; } diff --git a/tests/MapWinGIS.ActiveX.Tests/RenderingBaselineTests.cpp b/tests/MapWinGIS.ActiveX.Tests/RenderingBaselineTests.cpp index 7c30d67..cca8ae5 100644 --- a/tests/MapWinGIS.ActiveX.Tests/RenderingBaselineTests.cpp +++ b/tests/MapWinGIS.ActiveX.Tests/RenderingBaselineTests.cpp @@ -515,10 +515,19 @@ TEST_F(RenderingBaseline, MeasuresTriangulationDisabledCosts) activex::OpenGlVectorLayerRenderer openGl; start = Clock::now(); - const HRESULT openGlResult = openGl.Draw(surface.Get(), bounds, scene, viewport); + const HRESULT openGlResult = openGl.Draw( + surface.Get(), + bounds, + scene, + viewport, + true, + activex::VectorRenderMode::Outline); const double openGlMs = ElapsedMilliseconds(start); - EXPECT_EQ(openGlResult, S_FALSE) - << "The current OpenGL backend must reject scenes without fill meshes."; + EXPECT_TRUE(openGlResult == S_OK || openGlResult == S_FALSE); + if (openGlResult == S_FALSE) + { + std::wcout << L" OpenGL unavailable: " << openGl.GetLastFailureReason() << L'\n'; + } std::cout << "Triangulation-disabled baseline: " << measuredFeatureCount << " source features (" << scene.layers.front().scene->polygons.size() @@ -532,7 +541,7 @@ TEST_F(RenderingBaseline, MeasuresTriangulationDisabledCosts) "ms"); Report("GDI pan frame", gdiPanMs, "ms"); Report("GDI zoom frame", gdiZoomMs, "ms"); - Report("OpenGL no-mesh rejection", openGlMs, "ms"); + Report("OpenGL outline-only first frame", openGlMs, "ms"); ReportPerformanceDiagnostics(); } @@ -559,7 +568,9 @@ TEST_F(RenderingBaseline, MeasuresCoreSceneAndBackendCosts) const double openMs = ElapsedMilliseconds(start); start = Clock::now(); - const rendering::MapRenderScene scene = rendering::CreateMapRenderScene(map); + const rendering::MapRenderScene scene = rendering::CreateMapRenderScene( + map, + rendering::VectorRenderSceneOptions{.prepareFillMeshes = true}); const double sceneMs = ElapsedMilliseconds(start); const std::optional memoryAfterScene = PrivateMiB(memoryError); ASSERT_TRUE(memoryAfterScene.has_value()) << "GetProcessMemoryInfo failed: " << memoryError; @@ -678,7 +689,9 @@ TEST_F(RenderingBaseline, MeasuresComplexPolygonCosts) const double openMs = ElapsedMilliseconds(start); start = Clock::now(); - const rendering::MapRenderScene scene = rendering::CreateMapRenderScene(map); + const rendering::MapRenderScene scene = rendering::CreateMapRenderScene( + map, + rendering::VectorRenderSceneOptions{.prepareFillMeshes = true}); const double sceneMs = ElapsedMilliseconds(start); const std::optional memoryAfterScene = PrivateMiB(memoryError); ASSERT_TRUE(memoryAfterScene.has_value()) << "GetProcessMemoryInfo failed: " << memoryError; diff --git a/tests/MapWinGIS.ActiveX.Tests/VectorLayerRendererTests.cpp b/tests/MapWinGIS.ActiveX.Tests/VectorLayerRendererTests.cpp index 3ac94a9..6dfac29 100644 --- a/tests/MapWinGIS.ActiveX.Tests/VectorLayerRendererTests.cpp +++ b/tests/MapWinGIS.ActiveX.Tests/VectorLayerRendererTests.cpp @@ -384,6 +384,94 @@ TEST(VectorLayerRenderer, OpenGlRejectsPolygonWithoutFillMesh) L"every polygon; this frame was rendered with GDI."); } +TEST(VectorLayerRenderer, OpenGlDrawsOutlinesWithoutFillMeshes) +{ + BitmapSurface surface(120, 100); + ASSERT_TRUE(surface.IsValid()); + const RECT bounds{0, 0, 120, 100}; + ASSERT_NE(FillRect(surface.Get(), &bounds, GetSysColorBrush(COLOR_WINDOW)), 0); + + mwg::rendering::MapRenderScene scene = MakeConvexPolygonScene(); + Edit(scene.layers.front()).fillMeshes.clear(); + const mwg::Viewport viewport = FitViewport(bounds); + + EXPECT_TRUE( + mwg::activex::testing::OpenGlVectorLayerRendererTestAccess::IsSceneSupported( + scene, + mwg::activex::VectorRenderMode::Outline)); + + BitmapSurface probeSurface(120, 100); + ASSERT_TRUE(probeSurface.IsValid()); + mwg::activex::OpenGlVectorLayerRenderer availabilityProbe; + const HRESULT probeResult = availabilityProbe.Draw( + probeSurface.Get(), + bounds, + MakeConvexPolygonScene(), + viewport); + if (probeResult == S_FALSE) + { + GTEST_SKIP() << "No OpenGL context with framebuffer objects is available."; + } + ASSERT_EQ(probeResult, S_OK); + + mwg::activex::OpenGlVectorLayerRenderer renderer; + const HRESULT result = renderer.Draw( + surface.Get(), + bounds, + scene, + viewport, + true, + mwg::activex::VectorRenderMode::Outline); + ASSERT_EQ(result, S_OK); + EXPECT_EQ(MapPixel(surface.Get(), viewport, 5.0, 5.0), GetSysColor(COLOR_WINDOW)); + + std::size_t outlinePixels = 0; + for (int y = 0; y < bounds.bottom; ++y) + { + for (int x = 0; x < bounds.right; ++x) + { + outlinePixels += + GetPixel(surface.Get(), x, y) == RGB(24, 58, 82); + } + } + EXPECT_GT(outlinePixels, 0U); +} + +TEST(VectorLayerRenderer, GdiDrawsOutlinesWithoutFillMeshes) +{ + BitmapSurface surface(120, 100); + ASSERT_TRUE(surface.IsValid()); + const RECT bounds{0, 0, 120, 100}; + ASSERT_NE(FillRect(surface.Get(), &bounds, GetSysColorBrush(COLOR_WINDOW)), 0); + + mwg::rendering::MapRenderScene scene = MakeConvexPolygonScene(); + Edit(scene.layers.front()).fillMeshes.clear(); + const mwg::Viewport viewport = FitViewport(bounds); + + mwg::activex::GdiVectorLayerRenderer renderer; + ASSERT_EQ( + renderer.Draw( + surface.Get(), + bounds, + scene, + viewport, + true, + mwg::activex::VectorRenderMode::Outline), + S_OK); + EXPECT_EQ(MapPixel(surface.Get(), viewport, 5.0, 5.0), GetSysColor(COLOR_WINDOW)); + + std::size_t outlinePixels = 0; + for (int y = 0; y < bounds.bottom; ++y) + { + for (int x = 0; x < bounds.right; ++x) + { + outlinePixels += + GetPixel(surface.Get(), x, y) == RGB(24, 58, 82); + } + } + EXPECT_GT(outlinePixels, 0U); +} + TEST(VectorLayerRenderer, OpenGlRejectsSelfIntersectingRing) { BitmapSurface surface(120, 100); @@ -582,7 +670,7 @@ TEST(VectorLayerRenderer, GdiFallbackRendersConcaveHoledPolygonFromRings) EXPECT_EQ(renderer.GetActiveBackend(), mwg::activex::VectorRenderBackendKind::OpenGL); } -TEST(VectorLayerRenderer, OpenGlSupportRequiresAMeshForEveryPolygon) +TEST(VectorLayerRenderer, OpenGlFillSupportRequiresAMeshForEveryPolygon) { const mwg::rendering::MapRenderScene scene = MakeConvexPolygonScene(); EXPECT_TRUE( @@ -594,12 +682,20 @@ TEST(VectorLayerRenderer, OpenGlSupportRequiresAMeshForEveryPolygon) EXPECT_FALSE( mwg::activex::testing::OpenGlVectorLayerRendererTestAccess::IsSceneSupported( withoutMeshes)); + EXPECT_TRUE( + mwg::activex::testing::OpenGlVectorLayerRendererTestAccess::IsSceneSupported( + withoutMeshes, + mwg::activex::VectorRenderMode::Outline)); // A triangulation failure for one polygon rejects the whole frame. mwg::rendering::MapRenderScene nullMesh = MakeConvexPolygonScene(); Edit(nullMesh.layers.front()).fillMeshes.front().reset(); EXPECT_FALSE( mwg::activex::testing::OpenGlVectorLayerRendererTestAccess::IsSceneSupported(nullMesh)); + EXPECT_TRUE( + mwg::activex::testing::OpenGlVectorLayerRendererTestAccess::IsSceneSupported( + nullMesh, + mwg::activex::VectorRenderMode::Outline)); // Non-finite coordinates stay unsupported regardless of the mesh. mwg::rendering::MapRenderScene nonFinite = MakeConvexPolygonScene(); @@ -607,6 +703,10 @@ TEST(VectorLayerRenderer, OpenGlSupportRequiresAMeshForEveryPolygon) std::numeric_limits::infinity(); EXPECT_FALSE( mwg::activex::testing::OpenGlVectorLayerRendererTestAccess::IsSceneSupported(nonFinite)); + EXPECT_FALSE( + mwg::activex::testing::OpenGlVectorLayerRendererTestAccess::IsSceneSupported( + nonFinite, + mwg::activex::VectorRenderMode::Outline)); } TEST(VectorLayerRenderer, OpenGlSupportsConcaveMultipartAndHoledScenes) @@ -633,6 +733,10 @@ TEST(VectorLayerRenderer, OpenGlSupportsConcaveMultipartAndHoledScenes) Edit(broken.layers.front()).fillMeshes.front()->indices.resize(4); EXPECT_FALSE( mwg::activex::testing::OpenGlVectorLayerRendererTestAccess::IsSceneSupported(broken)); + EXPECT_TRUE( + mwg::activex::testing::OpenGlVectorLayerRendererTestAccess::IsSceneSupported( + broken, + mwg::activex::VectorRenderMode::Outline)); } TEST(VectorLayerRenderer, OpenGlRendersLShapedPolygon) diff --git a/tests/MapWinGIS.Core.Tests/MapRenderSceneTests.cpp b/tests/MapWinGIS.Core.Tests/MapRenderSceneTests.cpp index ea1ab4b..9600f67 100644 --- a/tests/MapWinGIS.Core.Tests/MapRenderSceneTests.cpp +++ b/tests/MapWinGIS.Core.Tests/MapRenderSceneTests.cpp @@ -167,6 +167,10 @@ TEST_F(MapRenderSceneTest, ContainsEveryVisibleLayerInDrawingOrder) EXPECT_EQ(scene.layers[0].scene->polygons.size(), 1U); EXPECT_EQ(scene.layers[1].scene->polygons.size(), 2U); EXPECT_EQ(scene.layers[1].scene->sourceFeatureCount, 2); + for (const rendering::LayerRenderScene& layer : scene.layers) + { + EXPECT_TRUE(layer.scene->fillMeshes.empty()); + } } TEST_F(MapRenderSceneTest, KeepsEachLayersOwnExtentAndCoordinates) diff --git a/tests/MapWinGIS.Core.Tests/MapViewTests.cpp b/tests/MapWinGIS.Core.Tests/MapViewTests.cpp index 1bdbdcd..8c17b8f 100644 --- a/tests/MapWinGIS.Core.Tests/MapViewTests.cpp +++ b/tests/MapWinGIS.Core.Tests/MapViewTests.cpp @@ -548,7 +548,12 @@ TEST_F(MapViewTest, AllocationFailurePreservesThePublishedSceneAndAllowsRetry) TEST_F(MapViewTest, ComplexSceneMeshesSurviveViewportChanges) { - _view.AddLayer(OpenComplexPolygons()); + const std::shared_ptr dataset = OpenComplexPolygons(); + _view.AddLayer( + dataset, + rendering::CreateVectorRenderScene( + *dataset, + rendering::VectorRenderSceneOptions{.prepareFillMeshes = true})); ASSERT_TRUE(_view.Resize(300, 200)); const rendering::MapRenderScene& scene = _view.Scene(); diff --git a/tests/MapWinGIS.Core.Tests/PerformanceDiagnosticsTests.cpp b/tests/MapWinGIS.Core.Tests/PerformanceDiagnosticsTests.cpp index 26ce242..e31e49c 100644 --- a/tests/MapWinGIS.Core.Tests/PerformanceDiagnosticsTests.cpp +++ b/tests/MapWinGIS.Core.Tests/PerformanceDiagnosticsTests.cpp @@ -79,7 +79,7 @@ TEST_F(PerformanceDiagnosticsTest, AggregatesScopesAndCountersFromConcurrentThre kThreadCount * kIncrementsPerThread); } -TEST_F(PerformanceDiagnosticsTest, RecordsDatasetAndScenePipelineStages) +TEST_F(PerformanceDiagnosticsTest, RecordsRequestedFillPreparationStages) { TempDirectory directory; constexpr std::array rectangles{{{0, 0, 10, 10}}}; @@ -89,7 +89,9 @@ TEST_F(PerformanceDiagnosticsTest, RecordsDatasetAndScenePipelineStages) PerformanceDiagnostics::Reset(); const std::unique_ptr dataset = VectorDataset::Open(path); const rendering::VectorRenderScene scene = - rendering::CreateVectorRenderScene(*dataset); + rendering::CreateVectorRenderScene( + *dataset, + rendering::VectorRenderSceneOptions{.prepareFillMeshes = true}); ASSERT_EQ(scene.polygons.size(), 1U); ASSERT_EQ(scene.fillMeshes.size(), 1U); @@ -107,7 +109,7 @@ TEST_F(PerformanceDiagnosticsTest, RecordsDatasetAndScenePipelineStages) EXPECT_GT(snapshot.Counter(PerformanceCounter::TrianglesGenerated), 0); } -TEST_F(PerformanceDiagnosticsTest, CanPrepareScenesWithoutFillMeshes) +TEST_F(PerformanceDiagnosticsTest, DoesNotTriangulateScenesByDefault) { TempDirectory directory; constexpr std::array rectangles{{{0, 0, 10, 10}}}; @@ -117,9 +119,7 @@ TEST_F(PerformanceDiagnosticsTest, CanPrepareScenesWithoutFillMeshes) PerformanceDiagnostics::Reset(); const rendering::VectorRenderScene scene = - rendering::CreateVectorRenderScene( - *dataset, - rendering::VectorRenderSceneOptions{.prepareFillMeshes = false}); + rendering::CreateVectorRenderScene(*dataset); EXPECT_EQ(scene.polygons.size(), 1U); EXPECT_TRUE(scene.fillMeshes.empty()); diff --git a/tests/MapWinGIS.Core.Tests/PolygonTriangulationTests.cpp b/tests/MapWinGIS.Core.Tests/PolygonTriangulationTests.cpp index 9208c08..1d2c322 100644 --- a/tests/MapWinGIS.Core.Tests/PolygonTriangulationTests.cpp +++ b/tests/MapWinGIS.Core.Tests/PolygonTriangulationTests.cpp @@ -469,7 +469,9 @@ TEST(PolygonTriangulation, SceneMeshesAlignWithPolygons) const auto dataset = VectorDataset::Open(MakeRectanglesDataset(directory.Path(), "rects.gpkg", rectangles)); - const rendering::VectorRenderScene scene = rendering::CreateVectorRenderScene(dataset->Layer(0)); + const rendering::VectorRenderScene scene = rendering::CreateVectorRenderScene( + dataset->Layer(0), + rendering::VectorRenderSceneOptions{.prepareFillMeshes = true}); ASSERT_EQ(scene.polygons.size(), rectangles.size()); ASSERT_EQ(scene.fillMeshes.size(), scene.polygons.size()); @@ -497,7 +499,9 @@ TEST(PolygonTriangulation, SceneTriangulatesMultipartGeometryWithHole) "MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0)), " "((10 10, 14 10, 14 14, 10 14, 10 10), (11 11, 12 11, 12 12, 11 12, 11 11)))")); - const rendering::VectorRenderScene scene = rendering::CreateVectorRenderScene(dataset->Layer(0)); + const rendering::VectorRenderScene scene = rendering::CreateVectorRenderScene( + dataset->Layer(0), + rendering::VectorRenderSceneOptions{.prepareFillMeshes = true}); ASSERT_EQ(scene.polygons.size(), 2u); ASSERT_EQ(scene.fillMeshes.size(), 2u); @@ -519,7 +523,9 @@ TEST(PolygonTriangulation, FailedTriangulationKeepsOriginalRings) wkbPolygon, "POLYGON ((0 0, 2 2, 2 0, 0 2, 0 0))")); - const rendering::VectorRenderScene scene = rendering::CreateVectorRenderScene(dataset->Layer(0)); + const rendering::VectorRenderScene scene = rendering::CreateVectorRenderScene( + dataset->Layer(0), + rendering::VectorRenderSceneOptions{.prepareFillMeshes = true}); ASSERT_EQ(scene.polygons.size(), 1u); ASSERT_EQ(scene.fillMeshes.size(), 1u); diff --git a/tests/MapWinGIS.Core.Tests/VectorRenderSceneTests.cpp b/tests/MapWinGIS.Core.Tests/VectorRenderSceneTests.cpp index 262a73d..538828c 100644 --- a/tests/MapWinGIS.Core.Tests/VectorRenderSceneTests.cpp +++ b/tests/MapWinGIS.Core.Tests/VectorRenderSceneTests.cpp @@ -319,6 +319,7 @@ TEST_P(VectorRenderSceneTest, CopiesPolygonCoordinatesAndExtent) const rendering::VectorRenderScene scene = rendering::CreateVectorRenderScene(*_layer); ASSERT_EQ(scene.polygons.size(), static_cast(Provinces::kFeatureCount)); + EXPECT_TRUE(scene.fillMeshes.empty()); EXPECT_EQ(scene.sourceFeatureCount, _layer->FeatureCount()); ASSERT_EQ(scene.polygons.front().size(), 1u); ASSERT_EQ(scene.polygons.front().front().size(), 5u);