@@ -112,6 +112,16 @@ class AX_DLL RenderView : public Object
112112 friend class Director ;
113113
114114public:
115+ enum SurfaceUpdateFlag : uint8_t
116+ {
117+ WindowSizeChanged = 1 , // Indicates that window size has changed
118+ RenderSizeChanged = 1 << 1 , // Indicates that render surface size has changed
119+ SilentUpdate = 1 << 2 , // Temporary flag: suppresses event dispatch for this update only.
120+ // Should be stripped before accumulating into persistent state.
121+ AllUpdates = WindowSizeChanged | RenderSizeChanged,
122+ AllUpdatesSilently = AllUpdates | SilentUpdate
123+ };
124+
115125 /* *
116126 */
117127 RenderView ();
@@ -254,7 +264,8 @@ class AX_DLL RenderView : public Object
254264 * ratio, two areas of your game view will be cut. [3] SHOW_ALL Full screen with black border: if the design
255265 * resolution ratio of width to height is different from the screen resolution ratio, two black borders will be
256266 * shown.
257- * @remark You shoud only set once
267+ * @remark For applications with a static design resolution, this method should typically be called only once during
268+ * initialization.
258269 */
259270 virtual void setDesignResolutionSize (float width, float height, ResolutionPolicy resolutionPolicy);
260271
@@ -456,29 +467,39 @@ class AX_DLL RenderView : public Object
456467 const std::unique_ptr<IVRRenderer>& getVR () const { return _vrRenderer; }
457468#endif
458469
459- protected:
460- float transformInputX (float x) { return (x - _viewportRect.origin .x ) / _viewScale.x ; }
461- float transformInputY (float y) { return (y - _viewportRect.origin .y ) / _viewScale.y ; }
462-
463470 /* *
464- * @brief Sets the render size (framebuffer/render target size) and updates the viewport and scaling.
471+ * @brief Updates the render surface size (framebuffer/render target) and synchronizes related view parameters.
472+ *
473+ * This method performs the following actions:
474+ * - Sets `_renderSize` to the specified dimensions;
475+ * - On mobile platforms (Android/iOS), `_windowSize` is synchronized to match `_renderSize`;
476+ * - On desktop platforms, `_windowSize` is only initialized to `_renderSize` if it hasn't been set yet;
477+ * - If `_designResolutionSize` is unset (`Vec2::ZERO`), it is initialized to `_renderSize`;
478+ * - Calls `updateDesignResolution()` to recalculate `_viewScale` and `_viewportRect` based on the current
479+ * `ResolutionPolicy`, and updates the Director's logical size and projection matrix accordingly.
480+ *
481+ * @param width The target width of the render surface. Its meaning depends on `updateFlag`:
482+ * it may represent the framebuffer width, logical window width, or design resolution width.
483+ * @param height The target height of the render surface. Its meaning depends on `updateFlag`:
484+ * it may represent the framebuffer height, logical window height, or design resolution height.
485+ * @param updateFlag Optional flags to control which parts of the view should be updated.
486+ * Defaults to `SurfaceUpdateFlag::AllUpdates`.
465487 *
466- * This method will:
467- * - Overwrite `_renderSize` with the given dimensions;
468- * - If `_windowSize` has not been initialized (equals `Vec2::ZERO`), initialize it to `_renderSize`;
469- * - If `_designResolutionSize` has not been initialized (equals `Vec2::ZERO`), initialize it to `_renderSize`;
470- * - Call `updateDesignResolution()` to compute `_viewScale` and `_viewportRect` based on the current
471- * `ResolutionPolicy`, and synchronize the Director's logical size and projection.
488+ * @warning This method may initialize `_windowSize` and `_designResolutionSize` on first invocation.
489+ * @note No update will occur if the given size is (0, 0).
472490 *
473- * @param width The width of the render size .
474- * @param height The height of the render size.
491+ * @internal This method is intended for internal use by platform-specific window or surface managers .
492+ * It should be called when the native surface size changes (e.g., orientation change, resize event) .
475493 *
476- * @warning This method has side effects: on the first call, it may initialize `_windowSize`
477- * and `_designResolutionSize`.
478- * @note If the given size is (0,0), no update will be performed.
479494 * @see updateDesignResolution(), setDesignResolutionSize()
480495 */
481- void setRenderSize (float width, float height);
496+ void updateRenderSurface (float width, float height, uint8_t updateFlag);
497+
498+ protected:
499+ float transformInputX (float x) { return (x - _viewportRect.origin .x ) / _viewScale.x ; }
500+ float transformInputY (float y) { return (y - _viewportRect.origin .y ) / _viewScale.y ; }
501+
502+ void maybeDispatchResizeEvent (uint8_t updateFlag);
482503
483504 /* *
484505 * @brief Callback invoked after the RenderView size has changed and all related updates are complete.
@@ -488,7 +509,7 @@ class AX_DLL RenderView : public Object
488509 * It serves as a notification hook for any components that need to respond
489510 * to the final, settled render size.
490511 */
491- void onRenderResized ();
512+ void onSurfaceResized ();
492513
493514 void setScissorRect (float x, float y, float w, float h);
494515 const ScissorRect& getScissorRect () const ;
@@ -516,6 +537,13 @@ class AX_DLL RenderView : public Object
516537 Vec2 _viewScale;
517538 ResolutionPolicy _resolutionPolicy;
518539
540+ // Flags indicating whether the window or framebuffer size was updated.
541+ // On desktop platforms, callback order is: framebufferSize => windowSize.
542+ // On WebAssembly, the order is reversed: windowSize => framebufferSize.
543+ uint8_t _surfaceUpdateFlags{0 };
544+
545+ bool _isResolutionUpdateLocked{false };
546+
519547#ifdef AX_ENABLE_VR
520548 std::unique_ptr<IVRRenderer> _vrRenderer{nullptr };
521549#endif
0 commit comments