airsdk / Adobe-Runtime-Support

Report, track and discuss issues in Adobe AIR. Monitored by Adobe - and HARMAN - and maintained by the AIR community.
201 stars 11 forks source link

[Windows][macOS] Stage::fullscreenSourceRect incorrect work with Stage3D #528

Open itlancer opened 3 years ago

itlancer commented 3 years ago

Problem Description

Stage::fullscreenSourceRect property doesn't work properly with Stage3D content in fullscreen mode for Windows and macOS. So hardware scaling for fullscreen cannot be used. You can see content deformations if you use Stage::fullscreenSourceRect.

It has been tested multiple AIR versions from 13.0.0.76 till latests AIR 32.0.0.89 and AIR 33.1.1.300 with different Windows and macOS devices with different OS versions. It works fine only when Stage3D uses Context3DRenderMode.SOFTWARE. Also it works fine with Android and iOS. Use StageDisplayState.FULL_SCREEN or StageDisplayState.FULL_SCREEN_INTERACTIVE didn't change anything. Using requestedDisplayResolution didn't change anything.

Tracker link: https://tracker.adobe.com/#/view/AIR-3737959

Steps to Reproduce

Launch code below with Windows or macOS device and click anywhere on stage. Application goes to fullscreen with Stage::fullscreenSourceRect property set up. Application just display red square via Stage3D.

Application example with sources attached. stage3d_fullscreen_sourcerect_bug.zip

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.display3D.Context3D;
    import flash.display.StageDisplayState;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.geom.Rectangle;
    import flash.events.MouseEvent;

    public class Stage3DFullscreenSourceRectBug extends Sprite {
        var context:Context3D;

        public function Stage3DFullscreenSourceRectBug() {
            addEventListener(Event.ADDED_TO_STAGE, addedToStage);
        }

        private function addedToStage(e:Event):void {
            removeEventListener(Event.ADDED_TO_STAGE, addedToStage);

            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.fullScreenSourceRect = new Rectangle(0, 0, stage.fullScreenWidth, stage.fullScreenHeight);//This line cause bug

            stage.stage3Ds[0].addEventListener(Event.CONTEXT3D_CREATE, contextCreated);
            stage.stage3Ds[0].requestContext3D();
        }

        function contextCreated(event:Event):void {
            context = stage.stage3Ds[0].context3D;
            context.configureBackBuffer(100, 100, 4, false);

            addEventListener(Event.ENTER_FRAME, render);
            stage.addEventListener(MouseEvent.CLICK, click);
        }

        function click(e:MouseEvent):void {
            stage.displayState = StageDisplayState.FULL_SCREEN;
        }

        function render(event:Event):void {
            context.clear(1, 0, 0, 1);
            context.present();
        }
    }
}

Actual Result: In fullscreen mode application display rectangle instead of square. Deformation occurs.

With Windows it looks like red rectangle: Windows

With macOS it looks like red rectangle with Y offset (about 10 pixels from the top):

macOS

Expected Result: In fullscreen mode application should display red square without deformations. It should look like: expected

Known Workarounds

none *do not use Stage::fullscreenSourceRect for Windows and macOS platforms

itlancer commented 4 months ago

Issue still exists with latest AIR 51.0.1.1.