Let IRenderWebBrowser expose its width and height to the RenderClientAdapterInternal class, so we can let Chromium render in a bitmap of the right size.

This commit is contained in:
Per Lundberg
2013-07-23 22:19:15 +03:00
parent 2fe11224de
commit 7a30bd5b7e
3 changed files with 17 additions and 10 deletions
+13 -8
View File
@@ -25,7 +25,6 @@ namespace CefSharp.Wpf
private RenderClientAdapter renderClientAdapter;
private Image image;
private int width, height;
private InteropBitmap interopBitmap;
private InteropBitmap popupInteropBitmap;
@@ -53,6 +52,16 @@ namespace CefSharp.Wpf
get { return PixelFormats.Bgr32.BitsPerPixel / 8; }
}
int IRenderWebBrowser.Width
{
get { return (int) ActualWidth; }
}
int IRenderWebBrowser.Height
{
get { return (int) ActualWidth; }
}
public Uri Uri
{
get { return (Uri) GetValue(UriProperty); }
@@ -107,10 +116,6 @@ namespace CefSharp.Wpf
sync = new Object();
// FIXME: Fix this to be done correctly.
width = 500;
height = 500;
//_scriptCore = new ScriptCore();
//_paintPopupDelegate = gcnew ActionHandler(this, &WebView::SetPopupBitmap);
//_resizePopupDelegate = gcnew ActionHandler(this, &WebView::SetPopupSizeAndPositionImpl);
@@ -502,9 +507,9 @@ namespace CefSharp.Wpf
image.Source = null;
GC.Collect(1);
var stride = width * BytesPerPixel;
var bitmap = (InteropBitmap) Imaging.CreateBitmapSourceFromMemorySection(FileMappingHandle, width, height,
PixelFormats.Bgr32, stride, 0);
var stride = (int) ActualWidth * BytesPerPixel;
var bitmap = (InteropBitmap) Imaging.CreateBitmapSourceFromMemorySection(FileMappingHandle, (int) ActualWidth,
(int) ActualHeight, PixelFormats.Bgr32, stride, 0);
image.Source = bitmap;
interopBitmap = bitmap;
}
+3
View File
@@ -15,6 +15,9 @@ namespace CefSharp
property IntPtr PopupFileMappingHandle;
property int BytesPerPixel { int get(); };
property int Width { int get(); };
property int Height { int get(); };
void InvokeRenderAsync(Action^ callback);
void SetCursor(IntPtr cursor);
@@ -53,8 +53,7 @@ namespace CefSharp
// CefRenderHandler
virtual DECL bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) OVERRIDE
{
// TODO: add a real implementation... :)
rect = CefRect(0, 0, _width, _height);
rect = CefRect(0, 0, _renderWebBrowser->Width, _renderWebBrowser->Height);
return true;
}