Skip to content

Commit

Permalink
update to CEF 3.2743
Browse files Browse the repository at this point in the history
- replace BGRABitmap with OpenGL in OSR example
- various fixes
  • Loading branch information
dliw committed Sep 24, 2016
1 parent 5335a5b commit aa8daf3
Show file tree
Hide file tree
Showing 14 changed files with 430 additions and 170 deletions.
2 changes: 1 addition & 1 deletion Component/cef3.lpk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</Other>
</CompilerOptions>
<Description Value="Chromium component for Lazarus"/>
<Version Major="3" Minor="2704"/>
<Version Major="3" Minor="2743"/>
<Files Count="11">
<Item1>
<Filename Value="../cef.inc"/>
Expand Down
23 changes: 11 additions & 12 deletions Component/cef3lcl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ TCustomChromium = class(TWinControl, IChromiumEvents)

{ LoadHandler }
procedure doOnLoadingStateChange(const Browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); virtual;
procedure doOnLoadStart(const Browser: ICefBrowser; const Frame: ICefFrame); virtual;
procedure doOnLoadStart(const Browser: ICefBrowser; const Frame: ICefFrame; transitionType: TCefTransitionType); virtual;
procedure doOnLoadEnd(const Browser: ICefBrowser; const Frame: ICefFrame; httpStatusCode: Integer); virtual;
procedure doOnLoadError(const Browser: ICefBrowser; const Frame: ICefFrame; errorCode: TCefErrorCode;
const errorText, failedUrl: ustring); virtual;
Expand All @@ -282,7 +282,7 @@ TCustomChromium = class(TWinControl, IChromiumEvents)
procedure doOnPopupShow(const Browser: ICefBrowser; doshow: Boolean); virtual;
procedure doOnPopupSize(const Browser: ICefBrowser; const rect: PCefRect); virtual;
procedure doOnPaint(const Browser: ICefBrowser; kind: TCefPaintElementType;
dirtyRectsCount: TSize; const dirtyRects: PCefRectArray;
dirtyRectsCount: TSize; const dirtyRects: TCefRectArray;
const buffer: Pointer; awidth, aheight: Integer); virtual;
procedure doOnCursorChange(const browser: ICefBrowser; aCursor: TCefCursorHandle; type_: TCefCursorType;
const customCursorInfo: PCefCursorInfo); virtual;
Expand Down Expand Up @@ -536,7 +536,7 @@ TLCLClientHandler = class(TCustomClientHandler)
class procedure OnTimer(Sender : TObject);
public
constructor Create(const crm: IChromiumEvents); override;
procedure Cleanup;
destructor Destroy; override;
procedure StartTimer;
end;

Expand Down Expand Up @@ -586,11 +586,10 @@ constructor TLCLClientHandler.Create(const crm: IChromiumEvents);
{$ENDIF}
end;

procedure TLCLClientHandler.Cleanup;
destructor TLCLClientHandler.Destroy;
begin
{ TODO : Check, why Destroy; override never gets called }
{$IFDEF DEBUG}
Debugln('LCLClientHandler.Cleanup');
Debugln('LCLClientHandler.Destroy');
{$ENDIF}

{$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
Expand All @@ -608,7 +607,7 @@ procedure TLCLClientHandler.Cleanup;
end;
{$ENDIF}

// inherited;
inherited;
end;

procedure TLCLClientHandler.StartTimer;
Expand Down Expand Up @@ -714,7 +713,7 @@ procedure TCustomChromium.CreateBrowser;
fBrowserId := fBrowser.Identifier;
{$ENDIF}

(FHandler as TLCLClientHandler).StartTimer;
(fHandler as TLCLClientHandler).StartTimer;
Load(fDefaultUrl);
end;
end;
Expand Down Expand Up @@ -876,7 +875,6 @@ destructor TCustomChromium.Destroy;

If fHandler <> nil then
begin
(fHandler as TLCLClientHandler).Cleanup;
(fHandler as ICefClientHandler).Disconnect;
fHandler := nil;
end;
Expand Down Expand Up @@ -1139,9 +1137,10 @@ procedure TCustomChromium.doOnLoadingStateChange(const Browser: ICefBrowser;
fOnLoadingStateChange(Self, Browser, isLoading, canGoBack, canGoForward);
end;

procedure TCustomChromium.doOnLoadStart(const Browser: ICefBrowser; const Frame: ICefFrame);
procedure TCustomChromium.doOnLoadStart(const Browser: ICefBrowser; const Frame: ICefFrame;
transitionType: TCefTransitionType);
begin
If Assigned(fOnLoadStart) then fOnLoadStart(Self, Browser, Frame);
If Assigned(fOnLoadStart) then fOnLoadStart(Self, Browser, Frame, transitionType);
end;

procedure TCustomChromium.doOnLoadEnd(const Browser: ICefBrowser; const Frame: ICefFrame;
Expand Down Expand Up @@ -1189,7 +1188,7 @@ procedure TCustomChromium.doOnPopupSize(const Browser: ICefBrowser; const rect:
end;

procedure TCustomChromium.doOnPaint(const Browser: ICefBrowser; kind: TCefPaintElementType;
dirtyRectsCount: TSize; const dirtyRects: PCefRectArray; const buffer: Pointer; awidth, aheight: Integer);
dirtyRectsCount: TSize; const dirtyRects: TCefRectArray; const buffer: Pointer; awidth, aheight: Integer);
begin
{ empty }
end;
Expand Down
33 changes: 16 additions & 17 deletions Component/cef3osr.pas
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ TCustomChromiumOSR = class(TComponent, IChromiumEvents)

{ LoadHandler }
procedure doOnLoadingStateChange(const Browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); virtual;
procedure doOnLoadStart(const Browser: ICefBrowser; const Frame: ICefFrame); virtual;
procedure doOnLoadStart(const Browser: ICefBrowser; const Frame: ICefFrame; transitionType: TCefTransitionType); virtual;
procedure doOnLoadEnd(const Browser: ICefBrowser; const Frame: ICefFrame; httpStatusCode: Integer); virtual;
procedure doOnLoadError(const Browser: ICefBrowser; const Frame: ICefFrame; errorCode: TCefErrorCode;
const errorText, failedUrl: ustring); virtual;
Expand All @@ -244,7 +244,7 @@ TCustomChromiumOSR = class(TComponent, IChromiumEvents)
procedure doOnPopupShow(const Browser: ICefBrowser; doshow: Boolean); virtual;
procedure doOnPopupSize(const Browser: ICefBrowser; const rect: PCefRect); virtual;
procedure doOnPaint(const Browser: ICefBrowser; kind: TCefPaintElementType;
dirtyRectsCount: TSize; const dirtyRects: PCefRectArray;
dirtyRectsCount: TSize; const dirtyRects: TCefRectArray;
const buffer: Pointer; awidth, aheight: Integer); virtual;
procedure doOnCursorChange(const browser: ICefBrowser; aCursor: TCefCursorHandle; type_: TCefCursorType;
const customCursorInfo: PCefCursorInfo); virtual;
Expand Down Expand Up @@ -515,7 +515,7 @@ TOSRClientHandler = class(TCustomClientHandler)
class procedure OnTimer(Sender : TObject);
public
constructor Create(const crm: IChromiumEvents); override;
procedure Cleanup;
destructor Destroy; override;
procedure StartTimer;
end;

Expand Down Expand Up @@ -565,11 +565,10 @@ constructor TOSRClientHandler.Create(const crm : IChromiumEvents);
{$ENDIF}
end;

procedure TOSRClientHandler.Cleanup;
destructor TOSRClientHandler.Destroy;
begin
{ TODO : Check, why Destroy; override never gets called }
{$IFDEF DEBUG}
Debugln('LCLClientHandler.Cleanup');
Debugln('OSRClientHandler.Cleanup');
{$ENDIF}

{$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
Expand All @@ -587,7 +586,7 @@ procedure TOSRClientHandler.Cleanup;
end;
{$ENDIF}

// inherited;
inherited;
end;

procedure TOSRClientHandler.StartTimer;
Expand Down Expand Up @@ -661,13 +660,13 @@ procedure TCustomChromiumOSR.CreateBrowser;
If Assigned(fChromiumContext) then fRequestContext := fChromiumContext.GetRequestContext;

{$IFDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
CefBrowserHostCreateBrowser(@info, FHandler, FDefaultUrl, @settings, fRequestContext);
CefBrowserHostCreateBrowser(@info, fHandler, UTF8Decode(fDefaultUrl), @settings, fRequestContext);
{$ELSE}
FBrowser := CefBrowserHostCreateBrowserSync(@info, FHandler, '', @settings, fRequestContext);
fBrowser := CefBrowserHostCreateBrowserSync(@info, fHandler, UTF8Decode(fDefaultUrl), @settings, fRequestContext);
FBrowserId := FBrowser.Identifier;
{$ENDIF}

(FHandler as TOSRClientHandler).StartTimer;
(fHandler as TOSRClientHandler).StartTimer;
end;
end;

Expand Down Expand Up @@ -932,9 +931,10 @@ procedure TCustomChromiumOSR.doOnLoadingStateChange(const Browser : ICefBrowser;
FOnLoadingStateChange(Self, Browser, isLoading, canGoBack, canGoForward);
end;

procedure TCustomChromiumOSR.doOnLoadStart(const Browser : ICefBrowser; const Frame : ICefFrame);
procedure TCustomChromiumOSR.doOnLoadStart(const Browser: ICefBrowser; const Frame: ICefFrame;
transitionType: TCefTransitionType);
begin
If Assigned(FOnLoadStart) then FOnLoadStart(Self, Browser, frame);
If Assigned(FOnLoadStart) then FOnLoadStart(Self, Browser, Frame, transitionType);
end;

procedure TCustomChromiumOSR.doOnLoadEnd(const Browser : ICefBrowser;
Expand Down Expand Up @@ -989,7 +989,7 @@ procedure TCustomChromiumOSR.doOnPopupSize(const Browser : ICefBrowser; const re
end;

procedure TCustomChromiumOSR.doOnPaint(const Browser : ICefBrowser;
kind : TCefPaintElementType; dirtyRectsCount : TSize; const dirtyRects : PCefRectArray;
kind : TCefPaintElementType; dirtyRectsCount : TSize; const dirtyRects : TCefRectArray;
const buffer : Pointer; awidth, aheight : Integer);
begin
If Assigned(FOnPaint) then
Expand Down Expand Up @@ -1143,7 +1143,7 @@ constructor TCustomChromiumOSR.Create(AOwner : TComponent);
begin
fHandler := TOSRClientHandler.Create(Self);

If not Assigned(FHandler) then raise Exception.Create('FHandler is nil');
If not Assigned(fHandler) then raise Exception.Create('FHandler is nil');
end;

fOptions := TChromiumOptions.Create;
Expand All @@ -1164,16 +1164,15 @@ destructor TCustomChromiumOSR.Destroy;
begin
fBrowser.StopLoad;
fBrowser.Host.CloseBrowser(True);
fBrowser := nil;
end;

If fHandler <> nil then
begin
(fHandler as TOSRClientHandler).Cleanup;
(fHandler as ICefClientHandler).Disconnect;
fHandler := nil;
end;

fHandler := nil;
fBrowser := nil;
fFontOptions.Free;
fOptions.Free;

Expand Down
1 change: 0 additions & 1 deletion Examples/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

# OSRDemo
Basic example on how to use TChromiumOSR.
BGRAControls are needed for this example (http://wiki.lazarus.freepascal.org/BGRAControls).

# SubProcess
Minimal subprocess, can be used as is as long as no custom render handler is needed.
64 changes: 41 additions & 23 deletions Examples/OSRDemo/main.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ object Mainform: TMainform
ClientHeight = 475
ClientWidth = 762
OnCreate = FormCreate
OnDestroy = FormDestroy
LCLVersion = '1.6.0.4'
object BGo: TButton
AnchorSideTop.Control = Owner
Expand Down Expand Up @@ -53,42 +54,59 @@ object Mainform: TMainform
TabOrder = 2
Text = 'http://'
end
object OSRPanel: TPanel
object OSRPanel: TOpenGLControl
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = EUrl
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
AnchorSideBottom.Control = CBAnimate
Left = 0
Height = 430
Top = 45
Height = 404
Top = 40
Width = 762
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 10
BevelOuter = bvNone
ClientHeight = 430
ClientWidth = 762
TabOrder = 3
BorderSpacing.Top = 5
BorderSpacing.Bottom = 5
OnEnter = OSRPanelEnter
OnExit = OSRPanelExit
object PaintBox: TPaintBox
Left = 0
Height = 430
Top = 0
Width = 762
Align = alClient
OnMouseDown = PaintBoxMouseDown
OnMouseMove = PaintBoxMouseMove
OnMouseUp = PaintBoxMouseUp
OnMouseWheel = PaintBoxMouseWheel
OnResize = PaintBoxResize
end
OnMouseDown = OSRPanelMouseDown
OnMouseMove = OSRPanelMouseMove
OnMouseUp = OSRPanelMouseUp
OnMouseWheel = OSRPanelMouseWheel
OnPaint = OSRPanelPaint
OnResize = OSRPanelResize
end
object CBAnimate: TCheckBox
AnchorSideLeft.Control = LUrl
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 26
Top = 449
Width = 74
Anchors = [akLeft, akBottom]
Caption = 'animate'
OnChange = CBAnimateChange
TabOrder = 4
end
object CBShowUpdate: TCheckBox
AnchorSideLeft.Control = CBAnimate
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 92
Height = 26
Top = 449
Width = 103
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 10
Caption = 'show update'
TabOrder = 5
end
object Chromium: TChromiumOSR
OnGetRootScreenRect = ChromiumGetRootScreenRect
OnGetViewRect = ChromiumGetViewRect
OnGetScreenPoint = ChromiumGetScreenPoint
OnPaint = ChromiumPaint
DefaultUrl = 'about:blank'
WindowlessFrameRate = 30
Expand Down
Loading

0 comments on commit aa8daf3

Please sign in to comment.