Commit Graph

48 Commits

Author SHA1 Message Date
Alex Maitland 71562dddc8 WPF - Add WritableBitmapRenderHandler.CopyOnlyDirtyRect (defaults to false)
- To improve performance we can only copy the part of the DirtyRect that was changed
  currently disabled by default, can be enabled once more testing one.
2022-09-19 14:29:39 +10:00
Alex Maitland 837f6ec7a6 WPF - CompositionTargetRenderHandler add null check 2022-04-20 12:15:30 +10:00
Alex Maitland 3b1c46aab9 Code Cleanup - Minor code cleanup
- Add Microsoft.CodeAnalysis.NetAnalyzers package
- Make some classes sealed
- Fix/Add xml doc
2022-02-01 14:07:01 +10:00
Alex Maitland 6cf756f25a WPF - WritableBitmapRenderHandler ArgumentOutofRange
Resolves #3474
2021-07-30 10:29:52 +10:00
amaitland 049172fbba WPF - CompositionTargetRenderHandler improve Dispose 2020-10-31 09:25:07 +10:00
amaitland 839e6ceee4 WPF - Resize Glitches (Image glitches during resize)
- WritableBitmapRenderHandler/InteropBitmapRenderHandler ignore update if size doesn't match
- Revert back to using WritableBitmapRenderHandler as the default implementation
- CompositionTargetRenderHandler only update bitmap if buffer is dirty
- AllocHGlobalWritableBitmapRenderHandler only update bitmap if buffer is dirty

It's possible that OnPaint is called multiple times before our BeginInvoke call is marshalled onto the UI Thread.
In those cases we check width/height and ignore the call if it doesn't match

Issue #3114
2020-10-30 14:51:12 +10:00
amaitland b24efd2853 WPF - Resize Glitches (Image glitches during resize)
- WritableBitmapRenderHandler/InteropBitmapRenderHandler ignore update if size doesn't match

It's possible that OnPaint is called multiple times before our BeginInvoke call is marshalled onto the UI Thread.
In those cases we check width/height and ignore the call if it doesn't match

Issue #3114
2020-10-30 14:30:35 +10:00
amaitland fb289d49d8 WPF - Add AllocHGlobalWritableBitmapRenderHandler
A port of WritableBitmapRenderHandler to use Marshal.AllocHGlobal instead of MemoryMappedFile

Remove disable-gpu-compositing command line arg

Resovles #3114
2020-10-28 15:39:33 +10:00
amaitland 59b8e7fbdd WPF - Default to using WritableBitmapRenderHandler for DPI 100%
- No longer use InteropBitmapRenderHandler as the default (InteropBitmap doesn't support DPI scaling).
- Remove old IncreaseBufferInteropRenderHandler as reusing the buffer causing glitching as detailed in https://github.com/cefsharp/CefSharp/issues/3114#issuecomment-717334316

Issue #3114
2020-10-28 13:42:01 +10:00
amaitland a8119cc145 WPF - InteropBitmapRenderHandler always create new buffer
InteropBitmap is strangely glitching on resize when reusing the same buffer as detailed in https://github.com/cefsharp/CefSharp/issues/3114#issuecomment-717334316
Go back to the old method approach of creating a new buffer for every resize operation.

Revert part of commit https://github.com/cefsharp/CefSharp/commit/b1bd7499e578f2486ad1c49f0b4bdc93c63d790f#diff-10ce38e86ac5782d06a15b191dc6216fd098f3e23fe1fa88b3711761d8944055

InteropBitmapRenderHandler will no longer be the default shortly.

Issue #3114
2020-10-28 13:26:36 +10:00
amaitland 57ab2ec982 WPF - Add CompositionTargetRenderHandler (experimental) 2019-12-13 21:07:25 +10:00
amaitland 55c825efdc WPF - Add new DirectWritableBitmapRenderHandler implementation
Use as default when MultiThreadedMessageLoop = false
2019-09-07 15:41:13 +10:00
amaitland 6d438d6504 WPF - Add lock to AbstractRenderHandler Dispose
Was trying to avoid adding a lock, unfortunately it's still possible for the CopyMemory function to be called
after the MemoryMappedFile has been Disposed.
2019-09-07 15:12:59 +10:00
amaitland ea714b327c WPF - Additional RenderHandler Dispose Improvements
- Hide Browser when Disposing, reduce changes of RenderHandler being called
- Add additional IsDisposed check
- Set RenderHandler to null before Disposing
2019-09-07 14:02:10 +10:00
amaitland b1bd7499e5 WPF - Interop/WritableBitmapRenderHandler memory allocation improvement
If the MemoryMappedFile is smaller than we need then create a larger one
2019-09-07 12:15:49 +10:00
amaitland b1b930605c WPF - Replace RtlCopyMemory p/invoke with NativeMethodWrapper.MemoryCopy
- RtlCopyMemory only works on x64, we could use the slower RtlMoveMemory, going with a native wrapper around RtlCopyMemory
- Renamed CopyMemoryUsingHandle to MemoryCopy (cannot be CopyMemory or RtlCopyMemory as macro with that name already exists)

https://github.com/cefsharp/CefSharp/pull/2885#issuecomment-529033351

Issue #2885
2019-09-07 09:02:30 +10:00
Konstantin Preißer c311a581e6 WPF - Modify CopyMemory EntryPoint to work with .Net Core (#2885)
* Fix the entrypoint declaration for CopyMemory.

Contributes to #2796

* Follow-Up: Switch to RtlCopyMemory which is faster, but requires that the buffers do not overlap.
2019-09-06 13:15:47 +10:00
amaitland 4a145bf363 WPF ByteArrayWritableBitmapRenderHandler - Remove base class
AbstractRenderHandler - change pixel properties to internal so they can be shared ByteArrayWritableBitmapRenderHandler
WritableBitmapRenderHandler - run Format Document (changed fields to read only)

Follow up to #2652
2019-03-01 13:19:35 +10:00
Chris 5c292cd707 WPF - Refactor RenderHandler implementations (#2652)
* WPF - Refactored the RenderHandler implementations

* Added a AbstractRenderHandler
* Refactored the RenderHandlers to inherit from AbstractRenderHandler
* Implemented the correct and thread safe dispose pattern

* WPF - AbstractRenderHandler updated xml documentation

* WPF - ByteArrayWritableBitmapRenderHandler: Removed incorrect PixelFormat

* WPF - AbstractRenderHandler: Added missing GC.SuppressFinalize
2019-03-01 13:03:52 +10:00
amaitland bbf7795d80 WPF/OffScreen - Add OnAcceleratedPaint
Exposes the CEF API for Shared D3D11 Texture support. This should be considered experimental as there are quite a few known bugs in the CEF implementation
(PDF Viewer not working correctly)

OffScreen.ChromiumWebBrowser.CreateBrowser API changed (breaking change) now pass in `WindowInfo` to customise settings
Refactor CreateBrowser to support windowed and OSR rendering (now accepts IWindowInfo)

Resolves #2527
2018-12-16 19:37:12 +10:00
maloshuk 5622809d68 WPF - Change PixelFormat from Bgra32 to Pbgra32 to fix control transparency (#2589)
* WPF - set PixelFormats.Pbgra32 for all rendering methods #2127
2018-12-07 19:42:54 +10:00
Chris bef5dd37c4 Maintenance - Fixed formatting, file encoding, and copyright year (#2504)
* Applied formatting

* Fixed file encoding + Updated copyright year

* Updated License

* Fixed more file encoding

* Copyright notice now shows the year the file was created
2018-09-10 10:41:13 +10:00
amaitland 28f43261b6 Xml Doc - Add more comments and fixes 2018-09-05 13:02:43 +10:00
amaitland 93fdd63525 WPF - Fix incorrect param ordering of IRenderHandler.OnPaint
Param order now matches CEF interface
2018-04-23 13:06:05 +10:00
amaitland c1b89c62e9 WPF/OffScreen - Code cleanup and minor refactor
IRenderWebBrowser - Method naming now matches CEF, xmldoc updated to be more accurate

CefSharp.Wpf.ChromiumWebBrowser and CefSharp.OffScreen.ChromiumWebBrowser both updated as a result of IRenderWebBrowser changes
Should be minimal public API changes, should only require changes for those that are implementing their own rendering, who will have a major rewrite on their hands regardless of this.
2018-04-20 14:49:25 +10:00
amaitland b97c0c54b5 WPF - Add ByteArrayWritableBitmapRenderHandler
Copies every bitmap into a unique byte[], no locking is used.
Will use lots of memory
2018-04-05 16:53:55 +10:00
amaitland 895ad8d94f WPF OSR - Rename IBitmapFactory to IRenderHandler
At some point it would be nice to expose the whole of the CefRenderHandler API, this should at some point make that easier.

Issue #2237
2018-03-21 14:36:30 +10:00
amaitland 59c6da399c WPF OSR - WritableBitmapFactory Add checks for a valid sourceBuffer 2018-03-21 14:11:21 +10:00
amaitland 73894a592d WPF OSR Rendering - InteropBitmapFactory split the experimental resize on increase option into IncreaseBufferInteropBitmapFactory
Also some minor threading improvements and buffer validation (check if closed and invalid)
2018-03-18 00:07:37 +10:00
amaitland 9c62fa4d46 InteropBitmapFactory and WritableBitmapFactory - Add ability to customise the dispatcherPriority 2018-03-06 10:59:06 +10:00
amaitland e7002a7874 WPF - Fix exception in WritableBitmapFactory
WritableBitmapFactory now works as expected
Add option to invalidate whole bitmap in response to #2035 (default is to invalidate only the dirty rect still)
2018-02-06 11:03:38 +10:00
amaitland 127c00554f Rewrite WPF/OffScreen OnPaint
OffScreen
  - Now maintains a raw Byte[] buffer that is used to create the GDI bitmaps
can be overridden and raw buffer access granted (eliminates the forced memory copy to the memory mapped view)

WPF
  - MemoryMappedFile.CreateNew is now used to create the in memory view and copy the buffer
  - InteropBitmapFactory only create new MemoryMappedFile selectively. If the MemoryMappedFile is larger than we require then just reuse it rather than
    releasing then allocating a smaller section of memory that's used for double buffering with InteropBitmap and WritableBitmap
  - Removed CefDirtyRect and used existing Rect class
  - Rename rendering event to Paint, still preferable to implement IBitmapFactory or subclass ChromiumWebBrowser
  - Update ChromiumWebBrowserWithScreenshotSupport to support new rendering method - not very well tested.

Resolves #2237
2018-01-18 11:29:12 +10:00
Chris cd934267c6 Updated copyright year and made sure it used same format everywhere (#1966) 2017-03-06 08:44:37 +10:00
amaitland afe758eb51 Use GhostDoc to generate bulk xml documentation - it's not perfect at least a lot of the interface doco has been copied into the
ChromiumWebBrowser instance classes
2016-06-15 13:44:16 +10:00
amaitland fdef48623e Update InteropBitmapInfo to have DirectRect support (possible as we've upgraded to .Net 4.5.2) 2016-05-13 15:47:23 +10:00
amaitland bae3c28e92 Update copyright to 2016 2016-01-11 14:11:30 +10:00
amaitland a3c3d6c51f Untabify RenderClientAdapter
Remove GetPixelPosition method - inline code
Remove redundant else branch from BitmapFactory
2015-08-26 15:21:38 +10:00
Bjarte Skogøy 4bbd9e7b09 A start. Need to test popups and test on high dpi screen. 2015-08-18 14:17:20 +02:00
amaitland 0413c0bc6c Merge remote-tracking branch 'remotes/upstream/master' into cef/2272 2015-05-13 09:29:07 +10:00
amaitland 561507b87b Add BackBufferHandle == IntPtr.Zero check to WritableBitmapInfo - in the rare case where it's been disposed of and the async OnPaint is called after the file handles have been released
Related to #1003
2015-05-06 11:10:51 +10:00
amaitland a4507d3c2e Reorder InteropBitmapInfo changes - fail fast, no need to calculate stride, remove redundant else block 2015-05-06 11:05:17 +10:00
jamespearce2006 6fa4b470f7 Return null immediately if file handle is not valid 2015-05-05 22:57:50 +01:00
jamespearce2006 6c16aa2725 switch to evaluate == first 2015-05-05 22:42:13 +01:00
jamespearce2006 446eda3435 WPF - Handle case where Bitmap is IntPtr.Zero
Because the OnPaint arrives on a thread other than the UI thread, it the
bitmap rendering process can occur after Dispose() has been called.
2015-05-05 18:05:44 +01:00
rassilon 7128e40fd1 It's time for copyright updates again. Yay!
Throw in a couple of tab containing files for good measure.
Evil tabs, evil I say.
2015-04-25 02:45:21 -04:00
amaitland ffe8302921 Add license disclaimer 2015-02-15 22:37:37 +10:00
amaitland 396eeb41b1 Untabify 2015-02-15 22:29:09 +10:00
amaitland bfec2c95b1 Add IBitmapFactory so that different Rendering methods can be plugged in (potentially a .Net 4.5 InteropBitmapInfo can be created)
Move into Rendering namespace
2015-01-29 15:25:08 +10:00