예제 #1
0
 private void Reset()
 {
     FDocumentSizeIsValid = false;
     FDomIsValid          = false;
     FErrorText           = string.Empty;
     if (IsAutoSize)
     {
         FBrowserHost.WasResized();
     }
 }
예제 #2
0
 protected virtual void OnResized(Vector2I oldSize, Vector2I newSize)
 {
     if (newSize.X > 0 && newSize.Y > 0)
     {
         // If the window has already been created, just resize it
         browserHost?.WasResized();
     }
 }
예제 #3
0
        //调整其子界面的大小
        public void ResizeWindow(uint width, uint height)
        {
            lock (BitmapLock)
            {
                //触发host的resize
                _windowsHeight = height;
                _windowsWidth  = width;
                if (_host != null)
                {
                    _host.WasResized();
                }
                //同时重建渲染管线
                if (_screenPipeline != null)
                {
                    _screenPipeline.Dispose();
                }
                if (_textureView != null)
                {
                    _textureView.Dispose();
                }
                if (_texture != null)
                {
                    _texture.Dispose();
                }
                if (_screenResourceSet != null)
                {
                    _screenResourceSet.Dispose();
                }


                _texture     = _gd.ResourceFactory.CreateTexture(TextureDescription.Texture2D((uint)_windowsWidth, (uint)_windowsHeight, 1, 1, PixelFormat.B8_G8_R8_A8_UNorm, TextureUsage.Sampled));
                _textureView = _gd.ResourceFactory.CreateTextureView(_texture);

                //重建resourceSet
                _screenResourceSet = _gd.ResourceFactory.CreateResourceSet(new ResourceSetDescription(
                                                                               _screenResourceLayout,
                                                                               _textureView,
                                                                               _gd.Aniso4xSampler
                                                                               ));

                var rasterizer = RasterizerStateDescription.Default;
                rasterizer.FillMode  = PolygonFillMode.Solid;
                rasterizer.FrontFace = FrontFace.CounterClockwise;
                rasterizer.CullMode  = FaceCullMode.Front;
                _screenPipeline      = _gd.ResourceFactory.CreateGraphicsPipeline(new GraphicsPipelineDescription(
                                                                                      BlendStateDescription.SingleOverrideBlend,
                                                                                      DepthStencilStateDescription.DepthOnlyLessEqual,
                                                                                      rasterizer,
                                                                                      PrimitiveTopology.TriangleList,
                                                                                      _shaderset,
                                                                                      //共享View和prj的buffer
                                                                                      new ResourceLayout[] { _screenResourceLayout },
                                                                                      _gd.MainSwapchain.Framebuffer.OutputDescription));
            }
        }
예제 #4
0
        protected virtual void OnResized(Vec2I oldSize, Vec2I newSize)
        {
            //_logger.Debug("BrowserResize. Old H{0}xW{1}; New H{2}xW{3}.", _browserHeight, _browserWidth, newHeight, newWidth);

            if (newSize.X > 0 && newSize.Y > 0)
            {
                // If the window has already been created, just resize it
                if (browserHost != null)
                {
                    //_logger.Trace("CefBrowserHost::WasResized to {0}x{1}.", newWidth, newHeight);
                    browserHost.WasResized();
                }
            }
        }
예제 #5
0
        protected override Size ArrangeOverride(Size arrangeBounds)
        {
            var size = base.ArrangeOverride(arrangeBounds);

            if (_browserPageImage != null)
            {
                var newWidth  = (int)size.Width;
                var newHeight = (int)size.Height;

                _logger.Debug("BrowserResize. Old H{0}xW{1}; New H{2}xW{3}.", _browserHeight, _browserWidth, newHeight, newWidth);

                if (newWidth > 0 && newHeight > 0)
                {
                    if (!_created)
                    {
                        AttachEventHandlers(this); // TODO: ?

                        // Create the bitmap that holds the rendered website bitmap
                        _browserWidth       = newWidth;
                        _browserHeight      = newHeight;
                        _browserSizeChanged = true;

                        // Find the window that's hosting us
                        Window parentWnd = FindParentOfType <Window>(this);
                        if (parentWnd != null)
                        {
                            IntPtr hParentWnd = new WindowInteropHelper(parentWnd).Handle;

                            var windowInfo = CefWindowInfo.Create();
                            windowInfo.SetAsWindowless(hParentWnd, false);

                            var settings = new CefBrowserSettings();
                            _cefClient = new WpfCefClient(this);

                            // This is the first time the window is being rendered, so create it.
                            CefBrowserHost.CreateBrowser(windowInfo, _cefClient, settings, !string.IsNullOrEmpty(StartUrl) ? StartUrl : "about:blank");

                            _created = true;
                        }
                    }
                    else
                    {
                        // Only update the bitmap if the size has changed
                        if (_browserPageBitmap == null || (_browserPageBitmap.Width != newWidth || _browserPageBitmap.Height != newHeight))
                        {
                            _browserWidth       = newWidth;
                            _browserHeight      = newHeight;
                            _browserSizeChanged = true;

                            // If the window has already been created, just resize it
                            if (_browserHost != null)
                            {
                                _logger.Trace("CefBrowserHost::WasResized to {0}x{1}.", newWidth, newHeight);
                                _browserHost.WasResized();
                            }
                        }
                    }
                }
            }

            return(size);
        }