本文整理汇总了C++中PassOwnPtr::cairoSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ PassOwnPtr::cairoSurface方法的具体用法?C++ PassOwnPtr::cairoSurface怎么用?C++ PassOwnPtr::cairoSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PassOwnPtr
的用法示例。
在下文中一共展示了PassOwnPtr::cairoSurface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: widgetSizeChanged
void ChromeClientJS::widgetSizeChanged(const IntSize& oldWidgetSize, IntSize newSize)
{
webkitTrace();
MainFrame& frame = (m_view->m_private->mainFrame->coreFrame()->mainFrame());
if(frame.view()) {
frame.view()->resize(newSize.width(),newSize.height());
frame.view()->adjustViewSize();
if(frame.view()->needsLayout())
frame.view()->layout();
}
if (m_view->m_private->acceleratedContext && m_view->m_private->acceleratedContext->enabled()) {
m_view->m_private->acceleratedContext->resizeRootLayer(newSize);
return;
}
if (m_view->m_private->backingStore && oldWidgetSize == newSize)
return;
if (m_view->m_private->backingStore) {
const IntSize& oldSize = m_view->m_private->backingStore->size();
if (newSize.width() > oldSize.width())
newSize.setWidth(std::max(newSize.width(), static_cast<int>(oldSize.width() * 1.5)));
if (newSize.height() > oldSize.height())
newSize.setHeight(std::max(newSize.height(), static_cast<int>(oldSize.height() * 1.5)));
}
// If we did not have a backing store before or if the backing store is growing, we need
// to reallocate a new one and set it up so that we don't see artifacts while resizing.
if (!m_view->m_private->backingStore
|| newSize.width() > m_view->m_private->backingStore->size().width()
|| newSize.height() > m_view->m_private->backingStore->size().height()) {
SDL_Surface *surface = SDL_CreateRGBSurface(SDL_SWSURFACE, newSize.width(), newSize.height(), 32, //SDL_HWSURFACE | SDL_HWPALETTE
0x00FF0000, /* Rmask */
0x0000FF00, /* Gmask */
0x000000FF, /* Bmask */
0xFF000000); /* Amask */
PassOwnPtr<WidgetBackingStore> newBackingStore = WebCore::WidgetBackingStoreCairo::create(surface, newSize);
RefPtr<cairo_t> cr = adoptRef(cairo_create(newBackingStore->cairoSurface()));
clearEverywhereInBackingStore(m_view, cr.get());
// Now we copy the old backing store image over the new cleared surface to prevent
// annoying flashing as the widget grows. We do the "real" paint in a timeout
// since we don't want to block resizing too long.
if (m_view->m_private->backingStore) {
cairo_set_source_surface(cr.get(), m_view->m_private->backingStore->cairoSurface(), 0, 0);
cairo_rectangle(cr.get(), 0, 0, m_view->m_private->backingStore->size().width(), m_view->m_private->backingStore->size().height());
cairo_fill(cr.get());
}
m_view->m_private->backingStore = newBackingStore;
} else if (oldWidgetSize.width() < newSize.width() || oldWidgetSize.height() < newSize.height()) {
// The widget is growing, but we did not need to create a new backing store.
// We should clear any old data outside of the old widget region.
RefPtr<cairo_t> cr = adoptRef(cairo_create(m_view->m_private->backingStore->cairoSurface()));
clipOutOldWidgetArea(cr.get(), oldWidgetSize, newSize);
clearEverywhereInBackingStore(m_view, cr.get());
}
// We need to force a redraw and ignore the framerate cap.
m_lastDisplayTime = 0;
m_dirtyRegion.unite(IntRect(IntPoint(), m_view->m_private->backingStore->size()));
// WebCore timers by default have a lower priority which leads to more artifacts when opaque
// resize is on
emscripten_async_call((void (*)(void *))(&repaintEverythingSoonTimeout), this, 0);
}