private void on_ime_composition_range_changed(cef_render_handler_t *self, cef_browser_t *browser, cef_range_t *selected_range, UIntPtr character_boundsCount, cef_rect_t *character_bounds) { CheckSelf(self); // TODO: reuse array/special list for rectange - this method called only from one thread and can be reused var m_browser = CefBrowser.FromNative(browser); var m_selectedRange = new CefRange(selected_range->from, selected_range->to); CefRectangle[] m_characterBounds; if (character_boundsCount == UIntPtr.Zero) { m_characterBounds = s_emptyRectangleArray; } else { var m_characterBoundsCount = checked ((int)character_boundsCount); m_characterBounds = new CefRectangle[m_characterBoundsCount]; for (var i = 0; i < m_characterBoundsCount; i++) { m_characterBounds[i] = new CefRectangle( character_bounds[i].x, character_bounds[i].y, character_bounds[i].width, character_bounds[i].height ); } } OnImeCompositionRangeChanged(m_browser, m_selectedRange, m_characterBounds); }
public RenderEventArgs(IntPtr buffer, int width, int height, CefRectangle[] dirtyRects) { this.Buffer = buffer; this.Width = width; this.Height = height; this.DirtyRects = dirtyRects; }
protected override bool GetRootScreenRect(CefBrowser browser, ref CefRectangle rect) { rect.X = 0; rect.Y = 0; rect.Width = this.screenWidth; rect.Height = this.screenHeight; return true; }
private void on_popup_size(cef_render_handler_t *self, cef_browser_t *browser, cef_rect_t *rect) { CheckSelf(self); var m_browser = CefBrowser.FromNative(browser); var m_rect = new CefRectangle(rect->x, rect->y, rect->width, rect->height); OnPopupSize(m_browser, m_rect); }
private void on_find_result(cef_find_handler_t *self, cef_browser_t *browser, int identifier, int count, cef_rect_t *selectionRect, int activeMatchOrdinal, int finalUpdate) { CheckSelf(self); var mBrowser = CefBrowser.FromNative(browser); var mSelectionRect = new CefRectangle(selectionRect->x, selectionRect->y, selectionRect->width, selectionRect->height); OnFindResult(mBrowser, identifier, count, mSelectionRect, activeMatchOrdinal, finalUpdate != 0); }
private unsafe CefDraggableRegion(cef_draggable_region_t *ptr) { _bounds = new CefRectangle( ptr->bounds.x, ptr->bounds.y, ptr->bounds.width, ptr->bounds.height ); _draggable = ptr->draggable != 0; }
protected override void OnPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, IntPtr buffer, int width, int height) { if (type != CefPaintElementType.View) { // Only want to paint the view return; } this.core.OnPaint(buffer); }
public void SetAsChild(IntPtr parentHandle, CefRectangle bounds) { ThrowIfDisposed(); Style = WindowStyle.WS_CHILD | WindowStyle.WS_CLIPCHILDREN | WindowStyle.WS_CLIPSIBLINGS | WindowStyle.WS_TABSTOP | WindowStyle.WS_VISIBLE; ParentHandle = parentHandle; Bounds = bounds; }
public void SetAsWindow(IntPtr parentHandle, CefRectangle rect, string _name) { ThrowIfDisposed(); Style = WindowStyle.WS_DEVWINDOW; Handle = (IntPtr)ToNative(); ParentHandle = parentHandle; // CW_USEDEFAULT X = rect.X; Y = rect.Y; Width = rect.Width; Height = rect.Height; Name = _name; }
protected override void OnPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, IntPtr buffer, int width, int height) { _logger.Debug("Type: {0} Buffer: {1:X8} Width: {2} Height: {3}", type, buffer, width, height); foreach (var rect in dirtyRects) { _logger.Debug(" DirtyRect: X={0} Y={1} W={2} H={3}", rect.X, rect.Y, rect.Width, rect.Height); } if (type == CefPaintElementType.View) { _owner.HandleViewPaint(browser, type, dirtyRects, buffer, width, height); } else if (type == CefPaintElementType.Popup) { _owner.HandlePopupPaint(width, height, dirtyRects, buffer); } }
public void SetAsChild(IntPtr parentHandle, CefRectangle rect) { ThrowIfDisposed(); Style = WindowStyle.WS_CHILD | WindowStyle.WS_CLIPCHILDREN | WindowStyle.WS_CLIPSIBLINGS | WindowStyle.WS_TABSTOP | WindowStyle.WS_VISIBLE; ParentHandle = parentHandle; X = rect.X; Y = rect.Y; Width = rect.Width; Height = rect.Height; }
private int get_view_rect(cef_render_handler_t* self, cef_browser_t* browser, cef_rect_t* rect) { CheckSelf(self); var m_browser = CefBrowser.FromNative(browser); var m_rect = new CefRectangle(); var result = GetViewRect(m_browser, ref m_rect); if (result) { rect->x = m_rect.X; rect->y = m_rect.Y; rect->width = m_rect.Width; rect->height = m_rect.Height; return 1; } else return 0; }
public void SetAsPopup(IntPtr parentHandle, string name) { ThrowIfDisposed(); Style = WindowStyle.WS_OVERLAPPEDWINDOW | WindowStyle.WS_CLIPCHILDREN | WindowStyle.WS_CLIPSIBLINGS | WindowStyle.WS_VISIBLE; ParentHandle = parentHandle; Bounds = new CefRectangle( int.MinValue, // CW_USEDEFAULT, int.MinValue, int.MinValue, int.MinValue ); Name = name; }
/// <summary> /// Set the printer printable area in device units. /// Some platforms already provide flipped area. Set |landscape_needs_flip| /// to false on those platforms to avoid double flipping. /// </summary> public void SetPrinterPrintableArea(CefSize physicalSizeDeviceUnits, CefRectangle printableAreaDeviceUnits, bool landscapeNeedsFlip) { var n_physicalSizeDeviceUnits = new cef_size_t( physicalSizeDeviceUnits.Width, physicalSizeDeviceUnits.Height ); var n_printableAreaDeviceUnits = new cef_rect_t( printableAreaDeviceUnits.X, printableAreaDeviceUnits.Y, printableAreaDeviceUnits.Width, printableAreaDeviceUnits.Height ); cef_print_settings_t.set_printer_printable_area( _self, &n_physicalSizeDeviceUnits, &n_printableAreaDeviceUnits, landscapeNeedsFlip ? 1 : 0 ); }
private int get_root_screen_rect(cef_render_handler_t *self, cef_browser_t *browser, cef_rect_t *rect) { CheckSelf(self); var m_browser = CefBrowser.FromNative(browser); var m_rect = new CefRectangle(); var result = GetRootScreenRect(m_browser, ref m_rect); if (result) { rect->x = m_rect.X; rect->y = m_rect.Y; rect->width = m_rect.Width; rect->height = m_rect.Height; return(1); } else { return(0); } }
private void on_accelerated_paint(cef_render_handler_t *self, cef_browser_t *browser, CefPaintElementType type, UIntPtr dirtyRectsCount, cef_rect_t *dirtyRects, void *shared_handle) { CheckSelf(self); var m_browser = CefBrowser.FromNative(browser); // TODO: reuse arrays? var m_dirtyRects = new CefRectangle[(int)dirtyRectsCount]; var count = (int)dirtyRectsCount; var rect = dirtyRects; for (var i = 0; i < count; i++) { m_dirtyRects[i].X = rect->x; m_dirtyRects[i].Y = rect->y; m_dirtyRects[i].Width = rect->width; m_dirtyRects[i].Height = rect->height; rect++; } OnAcceleratedPaint(m_browser, type, m_dirtyRects, (IntPtr)shared_handle); }
/// <summary> /// Called when the browser wants to move or resize the popup widget. |rect| /// contains the new location and size in view coordinates. /// </summary> protected abstract void OnPopupSize(CefBrowser browser, CefRectangle rect);
protected override bool GetRootScreenRect(CefBrowser browser, ref CefRectangle rect) { return GetViewRect(browser, ref rect); }
protected override void OnPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, IntPtr buffer, int width, int height) { if (CreateTextureEvent != null) { lock (texturesLock) { SharedTexture textureToRender; if (textures.Count <= currentTextureIndex) { IntPtr sharedTextureHandle; CreateTextureEvent((UInt32)width, (UInt32)height, out sharedTextureHandle); if (sharedTextureHandle == IntPtr.Zero) { API.Instance.Log("BrowserRenderHandler::OnPaint failed to create texture"); return; } // TODO : eventually switch to shared textures //Texture texture = GraphicsSystem.Instance.CreateTextureFromSharedHandle((UInt32)width, (UInt32)height, sharedTextureHandle); Texture texture = new Texture(sharedTextureHandle); textureToRender = new SharedTexture { Texture = texture, Handle = sharedTextureHandle }; textures.Add(textureToRender); } else { textureToRender = textures[currentTextureIndex]; } textureToRender.Texture.SetImage(buffer, GSImageFormat.GS_IMAGEFORMAT_BGRA, (UInt32)(width * 4)); // loop the current texture index currentTextureIndex = ++currentTextureIndex % textureCount; PaintEvent(textureToRender.Handle); } } }
internal void HandlePopupPaint( int width, int height, CefRectangle[] dirtyRects, IntPtr sourceBuffer ) { // }
/// <summary> /// Called when the browser wants to move or resize the popup widget. |rect| /// contains the new location and size. /// </summary> protected abstract void OnPopupSize(CefBrowser browser, CefRectangle rect);
/// <summary> /// Called when an element should be painted. |type| indicates whether the /// element is the view or the popup widget. |buffer| contains the pixel data /// for the whole image. |dirtyRects| contains the set of rectangles that need /// to be repainted. On Windows |buffer| will be |width|*|height|*4 bytes /// in size and represents a BGRA image with an upper-left origin. /// </summary> protected abstract void OnPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, IntPtr buffer, int width, int height);
/// <summary> /// Called to retrieve the root window rectangle in screen coordinates. Return /// true if the rectangle was provided. If this method returns false the /// rectangle from GetViewRect will be used. /// </summary> protected virtual bool GetRootScreenRect(CefBrowser browser, ref CefRectangle rect) { // TODO: return CefRectangle? (Nullable<CefRectangle>) instead of returning bool? return(false); }
/// <summary> /// Invalidate the |dirtyRect| region of the view. The browser will call /// CefRenderHandler::OnPaint asynchronously with the updated regions. This /// method is only used when window rendering is disabled. /// </summary> public void Invalidate(CefRectangle dirtyRect, CefPaintElementType type) { var n_dirtyRect = new cef_rect_t(dirtyRect.X, dirtyRect.Y, dirtyRect.Width, dirtyRect.Height); cef_browser_host_t.invalidate(_self, &n_dirtyRect, type); }
internal bool GetViewRect( ref CefRectangle rect ) { bool rectProvided = false; CefRectangle browserRect = new CefRectangle(); // TODO: simplify this //_mainUiDispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate //{ try { // The simulated screen and view rectangle are the same. This is necessary // for popup menus to be located and sized inside the view. browserRect.X = browserRect.Y = 0; browserRect.Width = ViewSize.X; browserRect.Height = ViewSize.Y; rectProvided = true; } catch( Exception ex ) { Log.Error( "WebBrowserControl: Caught exception in GetViewRect(): " + ex.Message ); rectProvided = false; } //})); if( rectProvided ) { rect = browserRect; } //_logger.Debug("GetViewRect result provided:{0} Rect: X{1} Y{2} H{3} W{4}", rectProvided, browserRect.X, browserRect.Y, browserRect.Height, browserRect.Width); return rectProvided; }
protected override void OnPopupSize(CefBrowser browser, CefRectangle rect) { }
protected override void OnPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, IntPtr buffer, int width, int height) { renderer.OnPaint(browser, buffer, width, height, dirtyRects); }
protected override bool GetViewRect(CefBrowser browser, ref CefRectangle rect) { rect.X = 0; rect.Y = 0; rect.Width = Width; rect.Height = Height; return true; }
/// <summary> /// Called to report find results returned by CefBrowserHost::Find(). /// |identifer| is the identifier passed to Find(), |count| is the number of /// matches currently identified, |selectionRect| is the location of where the /// match was found (in window coordinates), |activeMatchOrdinal| is the /// current position in the search results, and |finalUpdate| is true if this /// is the last find notification. /// </summary> protected abstract void OnFindResult(CefBrowser browser, int identifier, int count, CefRectangle selectionRect, int activeMatchOrdinal, bool finalUpdate);
protected override bool GetViewRect(CefBrowser browser, ref CefRectangle rect) { return _owner.GetViewRect(ref rect); }
/// <summary> /// Called to retrieve the view rectangle which is relative to screen /// coordinates. Return true if the rectangle was provided. /// </summary> protected virtual bool GetViewRect(CefBrowser browser, ref CefRectangle rect) { // TODO: return CefRectangle? (Nullable<CefRectangle>) instead of returning bool? return false; }
protected override bool GetRootScreenRect(CefBrowser browser, ref CefRectangle rect) { return true; }
/// <summary> /// Called to retrieve the view rectangle which is relative to screen /// coordinates. This method must always provide a non-empty rectangle. /// </summary> protected abstract void GetViewRect(CefBrowser browser, out CefRectangle rect);
protected override bool GetViewRect(CefBrowser browser, ref CefRectangle rect) { return true; }
private void on_popup_size(cef_render_handler_t* self, cef_browser_t* browser, cef_rect_t* rect) { CheckSelf(self); var m_browser = CefBrowser.FromNative(browser); var m_rect = new CefRectangle(rect->x, rect->y, rect->width, rect->height); OnPopupSize(m_browser, m_rect); }
internal void HandleViewPaint( CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, IntPtr buffer, int width, int height ) { if( texture == null ) return; if( width == 0 || height == 0 ) return; if( width != viewSize.X || height != viewSize.Y ) return; try { int stride = width * 4; int sourceBufferSize = stride * height; if( ( renderBuffer == null ) || ( sourceBufferSize > renderBuffer.Length ) ) renderBuffer = new byte[ sourceBufferSize ]; Marshal.Copy( buffer, renderBuffer, 0, sourceBufferSize ); forceUpdateTexture = true; } catch( Exception ex ) { Log.Error( "WebBrowserControl: Caught exception in HandleViewPaint(): " + ex.Message ); } }
private void on_paint(cef_render_handler_t* self, cef_browser_t* browser, CefPaintElementType type, UIntPtr dirtyRectsCount, cef_rect_t* dirtyRects, void* buffer, int width, int height) { CheckSelf(self); var m_browser = CefBrowser.FromNative(browser); // TODO: reuse arrays? var m_dirtyRects = new CefRectangle[(int)dirtyRectsCount]; var count = (int)dirtyRectsCount; var rect = dirtyRects; for (var i = 0; i < count; i++) { m_dirtyRects[i].X = rect->x; m_dirtyRects[i].Y = rect->y; m_dirtyRects[i].Width = rect->width; m_dirtyRects[i].Height = rect->height; rect++; } OnPaint(m_browser, type, m_dirtyRects, (IntPtr)buffer, width, height); }
protected override bool GetRootScreenRect(CefBrowser browser, ref CefRectangle rect) { if (SizeEvent != null) { return SizeEvent(ref rect); } return false; }
protected override void OnPopupSize(CefBrowser browser, CefRectangle rect) { this.GetRootScreenRect(browser, ref rect); }
internal void OnPaint(CefBrowser browser, IntPtr buffer, int width, int height, CefRectangle[] dirtyRects) { if (Render != null) { Render(this, new RenderEventArgs(buffer, width, height, dirtyRects)); } }
public bool Size(ref CefRectangle rect) { rect.X = 0; rect.Y = 0; rect.Width = BrowserConfig.BrowserSourceSettings.Width; rect.Height = BrowserConfig.BrowserSourceSettings.Height; return true; }