mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
This implementation supports both GPU compositing and software compositing (used when GPU is not supported or when passing `--disable-gpu --disable-gpu-compositing` command-line flags). GPU-accelerated features (WebGL and 3D CSS) that did not work with the previous off-screen rendering implementation do work with this implementation when GPU support is available. Rendering now operates on a per-frame basis. The frame rate is configurable via CefBrowserSettings.windowless_frame_rate up to a maximum of 60fps (potentially limited by how fast the system can generate new frames). CEF generates a bitmap from the compositor backing and passes it to CefRenderHandler::OnPaint. The previous CefRenderHandler/CefBrowserHost API for off-screen rendering has been restored mostly as-is with some minor changes: - CefBrowserHost::Invalidate no longer accepts a CefRect region argument. Instead of invalidating a specific region it now triggers generation of a new frame. - The |dirtyRects| argument to CefRenderHandler::OnPaint will now always be a single CefRect representing the whole view (frame) size. Previously, invalidated regions were listed separately. - Linux: CefBrowserHost::SendKeyEvent now expects X11 event information instead of GTK event information. See cefclient for an example of converting GTK events to the necessary format. - Sizes passed to the CefRenderHandler OnPaint and OnPopupSize methods are now already DPI scaled. Previously, the client had to perform DPI scaling. - Includes drag&drop implementation from issue #1032. - Includes unit test fixes from issue #1245. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1751 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
276 lines
7.1 KiB
C++
276 lines
7.1 KiB
C++
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
// can be found in the LICENSE file.
|
|
//
|
|
// ---------------------------------------------------------------------------
|
|
//
|
|
// This file was generated by the CEF translator tool. If making changes by
|
|
// hand only do so within the body of existing method and function
|
|
// implementations. See the translator.README.txt file in the tools directory
|
|
// for more information.
|
|
//
|
|
|
|
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
|
#include "libcef_dll/cpptoc/drag_data_cpptoc.h"
|
|
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
|
|
|
|
|
|
// VIRTUAL METHODS - Body may be edited by hand.
|
|
|
|
bool CefRenderHandlerCToCpp::GetRootScreenRect(CefRefPtr<CefBrowser> browser,
|
|
CefRect& rect) {
|
|
if (CEF_MEMBER_MISSING(struct_, get_root_screen_rect))
|
|
return false;
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
// Verify param: browser; type: refptr_diff
|
|
DCHECK(browser.get());
|
|
if (!browser.get())
|
|
return false;
|
|
|
|
// Execute
|
|
int _retval = struct_->get_root_screen_rect(struct_,
|
|
CefBrowserCppToC::Wrap(browser),
|
|
&rect);
|
|
|
|
// Return type: bool
|
|
return _retval?true:false;
|
|
}
|
|
|
|
bool CefRenderHandlerCToCpp::GetViewRect(CefRefPtr<CefBrowser> browser,
|
|
CefRect& rect) {
|
|
if (CEF_MEMBER_MISSING(struct_, get_view_rect))
|
|
return false;
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
// Verify param: browser; type: refptr_diff
|
|
DCHECK(browser.get());
|
|
if (!browser.get())
|
|
return false;
|
|
|
|
// Execute
|
|
int _retval = struct_->get_view_rect(struct_,
|
|
CefBrowserCppToC::Wrap(browser),
|
|
&rect);
|
|
|
|
// Return type: bool
|
|
return _retval?true:false;
|
|
}
|
|
|
|
bool CefRenderHandlerCToCpp::GetScreenPoint(CefRefPtr<CefBrowser> browser,
|
|
int viewX, int viewY, int& screenX, int& screenY) {
|
|
if (CEF_MEMBER_MISSING(struct_, get_screen_point))
|
|
return false;
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
// Verify param: browser; type: refptr_diff
|
|
DCHECK(browser.get());
|
|
if (!browser.get())
|
|
return false;
|
|
|
|
// Execute
|
|
int _retval = struct_->get_screen_point(struct_,
|
|
CefBrowserCppToC::Wrap(browser),
|
|
viewX,
|
|
viewY,
|
|
&screenX,
|
|
&screenY);
|
|
|
|
// Return type: bool
|
|
return _retval?true:false;
|
|
}
|
|
|
|
bool CefRenderHandlerCToCpp::GetScreenInfo(CefRefPtr<CefBrowser> browser,
|
|
CefScreenInfo& screen_info) {
|
|
if (CEF_MEMBER_MISSING(struct_, get_screen_info))
|
|
return false;
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
// Verify param: browser; type: refptr_diff
|
|
DCHECK(browser.get());
|
|
if (!browser.get())
|
|
return false;
|
|
|
|
// Execute
|
|
int _retval = struct_->get_screen_info(struct_,
|
|
CefBrowserCppToC::Wrap(browser),
|
|
&screen_info);
|
|
|
|
// Return type: bool
|
|
return _retval?true:false;
|
|
}
|
|
|
|
void CefRenderHandlerCToCpp::OnPopupShow(CefRefPtr<CefBrowser> browser,
|
|
bool show) {
|
|
if (CEF_MEMBER_MISSING(struct_, on_popup_show))
|
|
return;
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
// Verify param: browser; type: refptr_diff
|
|
DCHECK(browser.get());
|
|
if (!browser.get())
|
|
return;
|
|
|
|
// Execute
|
|
struct_->on_popup_show(struct_,
|
|
CefBrowserCppToC::Wrap(browser),
|
|
show);
|
|
}
|
|
|
|
void CefRenderHandlerCToCpp::OnPopupSize(CefRefPtr<CefBrowser> browser,
|
|
const CefRect& rect) {
|
|
if (CEF_MEMBER_MISSING(struct_, on_popup_size))
|
|
return;
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
// Verify param: browser; type: refptr_diff
|
|
DCHECK(browser.get());
|
|
if (!browser.get())
|
|
return;
|
|
|
|
// Execute
|
|
struct_->on_popup_size(struct_,
|
|
CefBrowserCppToC::Wrap(browser),
|
|
&rect);
|
|
}
|
|
|
|
void CefRenderHandlerCToCpp::OnPaint(CefRefPtr<CefBrowser> browser,
|
|
PaintElementType type, const RectList& dirtyRects, const void* buffer,
|
|
int width, int height) {
|
|
if (CEF_MEMBER_MISSING(struct_, on_paint))
|
|
return;
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
// Verify param: browser; type: refptr_diff
|
|
DCHECK(browser.get());
|
|
if (!browser.get())
|
|
return;
|
|
// Verify param: buffer; type: simple_byaddr
|
|
DCHECK(buffer);
|
|
if (!buffer)
|
|
return;
|
|
|
|
// Translate param: dirtyRects; type: simple_vec_byref_const
|
|
const size_t dirtyRectsCount = dirtyRects.size();
|
|
cef_rect_t* dirtyRectsList = NULL;
|
|
if (dirtyRectsCount > 0) {
|
|
dirtyRectsList = new cef_rect_t[dirtyRectsCount];
|
|
DCHECK(dirtyRectsList);
|
|
if (dirtyRectsList) {
|
|
for (size_t i = 0; i < dirtyRectsCount; ++i) {
|
|
dirtyRectsList[i] = dirtyRects[i];
|
|
}
|
|
}
|
|
}
|
|
|
|
// Execute
|
|
struct_->on_paint(struct_,
|
|
CefBrowserCppToC::Wrap(browser),
|
|
type,
|
|
dirtyRectsCount,
|
|
dirtyRectsList,
|
|
buffer,
|
|
width,
|
|
height);
|
|
|
|
// Restore param:dirtyRects; type: simple_vec_byref_const
|
|
if (dirtyRectsList)
|
|
delete [] dirtyRectsList;
|
|
}
|
|
|
|
void CefRenderHandlerCToCpp::OnCursorChange(CefRefPtr<CefBrowser> browser,
|
|
CefCursorHandle cursor) {
|
|
if (CEF_MEMBER_MISSING(struct_, on_cursor_change))
|
|
return;
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
// Verify param: browser; type: refptr_diff
|
|
DCHECK(browser.get());
|
|
if (!browser.get())
|
|
return;
|
|
|
|
// Execute
|
|
struct_->on_cursor_change(struct_,
|
|
CefBrowserCppToC::Wrap(browser),
|
|
cursor);
|
|
}
|
|
|
|
bool CefRenderHandlerCToCpp::StartDragging(CefRefPtr<CefBrowser> browser,
|
|
CefRefPtr<CefDragData> drag_data, DragOperationsMask allowed_ops, int x,
|
|
int y) {
|
|
if (CEF_MEMBER_MISSING(struct_, start_dragging))
|
|
return false;
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
// Verify param: browser; type: refptr_diff
|
|
DCHECK(browser.get());
|
|
if (!browser.get())
|
|
return false;
|
|
// Verify param: drag_data; type: refptr_diff
|
|
DCHECK(drag_data.get());
|
|
if (!drag_data.get())
|
|
return false;
|
|
|
|
// Execute
|
|
int _retval = struct_->start_dragging(struct_,
|
|
CefBrowserCppToC::Wrap(browser),
|
|
CefDragDataCppToC::Wrap(drag_data),
|
|
allowed_ops,
|
|
x,
|
|
y);
|
|
|
|
// Return type: bool
|
|
return _retval?true:false;
|
|
}
|
|
|
|
void CefRenderHandlerCToCpp::UpdateDragCursor(CefRefPtr<CefBrowser> browser,
|
|
DragOperation operation) {
|
|
if (CEF_MEMBER_MISSING(struct_, update_drag_cursor))
|
|
return;
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
// Verify param: browser; type: refptr_diff
|
|
DCHECK(browser.get());
|
|
if (!browser.get())
|
|
return;
|
|
|
|
// Execute
|
|
struct_->update_drag_cursor(struct_,
|
|
CefBrowserCppToC::Wrap(browser),
|
|
operation);
|
|
}
|
|
|
|
void CefRenderHandlerCToCpp::OnScrollOffsetChanged(
|
|
CefRefPtr<CefBrowser> browser) {
|
|
if (CEF_MEMBER_MISSING(struct_, on_scroll_offset_changed))
|
|
return;
|
|
|
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
|
|
// Verify param: browser; type: refptr_diff
|
|
DCHECK(browser.get());
|
|
if (!browser.get())
|
|
return;
|
|
|
|
// Execute
|
|
struct_->on_scroll_offset_changed(struct_,
|
|
CefBrowserCppToC::Wrap(browser));
|
|
}
|
|
|
|
|
|
#ifndef NDEBUG
|
|
template<> long CefCToCpp<CefRenderHandlerCToCpp, CefRenderHandler,
|
|
cef_render_handler_t>::DebugObjCt = 0;
|
|
#endif
|
|
|