本文整理汇总了C++中CompositorOGL::GetDestinationSurfaceSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CompositorOGL::GetDestinationSurfaceSize方法的具体用法?C++ CompositorOGL::GetDestinationSurfaceSize怎么用?C++ CompositorOGL::GetDestinationSurfaceSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompositorOGL
的用法示例。
在下文中一共展示了CompositorOGL::GetDestinationSurfaceSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: windowSize
void
LayerManagerComposite::RenderToPresentationSurface()
{
#ifdef MOZ_WIDGET_ANDROID
nsIWidget* const widget = mCompositor->GetWidget()->RealWidget();
auto window = static_cast<ANativeWindow*>(
widget->GetNativeData(NS_PRESENTATION_WINDOW));
if (!window) {
return;
}
EGLSurface surface = widget->GetNativeData(NS_PRESENTATION_SURFACE);
if (!surface) {
//create surface;
surface = GLContextProviderEGL::CreateEGLSurface(window);
if (!surface) {
return;
}
widget->SetNativeData(NS_PRESENTATION_SURFACE,
reinterpret_cast<uintptr_t>(surface));
}
CompositorOGL* compositor = mCompositor->AsCompositorOGL();
GLContext* gl = compositor->gl();
GLContextEGL* egl = GLContextEGL::Cast(gl);
if (!egl) {
return;
}
const IntSize windowSize(ANativeWindow_getWidth(window),
ANativeWindow_getHeight(window));
#endif
if ((windowSize.width <= 0) || (windowSize.height <= 0)) {
return;
}
ScreenRotation rotation = compositor->GetScreenRotation();
const int actualWidth = windowSize.width;
const int actualHeight = windowSize.height;
const gfx::IntSize originalSize = compositor->GetDestinationSurfaceSize();
const nsIntRect originalRect = nsIntRect(0, 0, originalSize.width, originalSize.height);
int pageWidth = originalSize.width;
int pageHeight = originalSize.height;
if (rotation == ROTATION_90 || rotation == ROTATION_270) {
pageWidth = originalSize.height;
pageHeight = originalSize.width;
}
float scale = 1.0;
if ((pageWidth > actualWidth) || (pageHeight > actualHeight)) {
const float scaleWidth = (float)actualWidth / (float)pageWidth;
const float scaleHeight = (float)actualHeight / (float)pageHeight;
scale = scaleWidth <= scaleHeight ? scaleWidth : scaleHeight;
}
const gfx::IntSize actualSize(actualWidth, actualHeight);
ScopedCompostitorSurfaceSize overrideSurfaceSize(compositor, actualSize);
const ScreenPoint offset((actualWidth - (int)(scale * pageWidth)) / 2, 0);
ScopedContextSurfaceOverride overrideSurface(egl, surface);
Matrix viewMatrix = ComputeTransformForRotation(originalRect,
rotation);
viewMatrix.Invert(); // unrotate
viewMatrix.PostScale(scale, scale);
viewMatrix.PostTranslate(offset.x, offset.y);
Matrix4x4 matrix = Matrix4x4::From2D(viewMatrix);
mRoot->ComputeEffectiveTransforms(matrix);
nsIntRegion opaque;
LayerIntRegion visible;
PostProcessLayers(mRoot, opaque, visible, Nothing());
nsIntRegion invalid;
IntRect bounds = IntRect::Truncate(0, 0, scale * pageWidth, actualHeight);
IntRect rect, actualBounds;
MOZ_ASSERT(mRoot->GetOpacity() == 1);
mCompositor->BeginFrame(invalid, nullptr, bounds, nsIntRegion(), &rect, &actualBounds);
// The Java side of Fennec sets a scissor rect that accounts for
// chrome such as the URL bar. Override that so that the entire frame buffer
// is cleared.
ScopedScissorRect scissorRect(egl, 0, 0, actualWidth, actualHeight);
egl->fClearColor(0.0, 0.0, 0.0, 0.0);
egl->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
const IntRect clipRect = IntRect::Truncate(0, 0, actualWidth, actualHeight);
RootLayer()->Prepare(RenderTargetIntRect::FromUnknownRect(clipRect));
RootLayer()->RenderLayer(clipRect);
//.........这里部分代码省略.........
示例2: overrideSurfaceSize
void
LayerManagerComposite::RenderToPresentationSurface()
{
if (!AndroidBridge::Bridge()) {
return;
}
void* window = AndroidBridge::Bridge()->GetPresentationWindow();
if (!window) {
return;
}
EGLSurface surface = AndroidBridge::Bridge()->GetPresentationSurface();
if (!surface) {
//create surface;
surface = GLContextProviderEGL::CreateEGLSurface(window);
if (!surface) {
return;
}
AndroidBridge::Bridge()->SetPresentationSurface(surface);
}
CompositorOGL* compositor = static_cast<CompositorOGL*>(mCompositor.get());
GLContext* gl = compositor->gl();
GLContextEGL* egl = GLContextEGL::Cast(gl);
if (!egl) {
return;
}
const IntSize windowSize = AndroidBridge::Bridge()->GetNativeWindowSize(window);
if ((windowSize.width <= 0) || (windowSize.height <= 0)) {
return;
}
const int actualWidth = windowSize.width;
const int actualHeight = windowSize.height;
const gfx::IntSize originalSize = compositor->GetDestinationSurfaceSize();
const int pageWidth = originalSize.width;
const int pageHeight = originalSize.height;
float scale = 1.0;
if ((pageWidth > actualWidth) || (pageHeight > actualHeight)) {
const float scaleWidth = (float)actualWidth / (float)pageWidth;
const float scaleHeight = (float)actualHeight / (float)pageHeight;
scale = scaleWidth <= scaleHeight ? scaleWidth : scaleHeight;
}
const gfx::IntSize actualSize(actualWidth, actualHeight);
ScopedCompostitorSurfaceSize overrideSurfaceSize(compositor, actualSize);
const ScreenPoint offset((actualWidth - (int)(scale * pageWidth)) / 2, 0);
ScopedCompositorRenderOffset overrideRenderOffset(compositor, offset);
ScopedContextSurfaceOverride overrideSurface(egl, surface);
nsIntRegion invalid;
Rect bounds(0.0f, 0.0f, scale * pageWidth, (float)actualHeight);
Rect rect, actualBounds;
mCompositor->BeginFrame(invalid, nullptr, bounds, &rect, &actualBounds);
// Override the projection matrix since the presentation frame buffer
// is probably not the same size as the device frame buffer. The override
// projection matrix also scales the content to fit into the presentation
// frame buffer.
Matrix viewMatrix;
viewMatrix.PreTranslate(-1.0, 1.0);
viewMatrix.PreScale((2.0f * scale) / (float)actualWidth, (2.0f * scale) / (float)actualHeight);
viewMatrix.PreScale(1.0f, -1.0f);
viewMatrix.PreTranslate((int)((float)offset.x / scale), offset.y);
Matrix4x4 projMatrix = Matrix4x4::From2D(viewMatrix);
ScopedCompositorProjMatrix overrideProjMatrix(compositor, projMatrix);
// The Java side of Fennec sets a scissor rect that accounts for
// chrome such as the URL bar. Override that so that the entire frame buffer
// is cleared.
ScopedScissorRect screen(egl, 0, 0, actualWidth, actualHeight);
egl->fClearColor(0.0, 0.0, 0.0, 0.0);
egl->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
const IntRect clipRect = IntRect(0, 0, (int)(scale * pageWidth), actualHeight);
RootLayer()->Prepare(RenderTargetPixel::FromUntyped(clipRect));
RootLayer()->RenderLayer(clipRect);
mCompositor->EndFrame();
mCompositor->SetDispAcquireFence(mRoot);
}
示例3: overrideSurfaceSize
void
LayerManagerComposite::RenderToPresentationSurface()
{
#ifdef MOZ_WIDGET_ANDROID
if (!AndroidBridge::Bridge()) {
return;
}
void* window = AndroidBridge::Bridge()->GetPresentationWindow();
if (!window) {
return;
}
EGLSurface surface = AndroidBridge::Bridge()->GetPresentationSurface();
if (!surface) {
//create surface;
surface = GLContextProviderEGL::CreateEGLSurface(window);
if (!surface) {
return;
}
AndroidBridge::Bridge()->SetPresentationSurface(surface);
}
CompositorOGL* compositor = static_cast<CompositorOGL*>(mCompositor.get());
GLContext* gl = compositor->gl();
GLContextEGL* egl = GLContextEGL::Cast(gl);
if (!egl) {
return;
}
const IntSize windowSize = AndroidBridge::Bridge()->GetNativeWindowSize(window);
#elif defined(MOZ_WIDGET_GONK)
CompositorOGL* compositor = static_cast<CompositorOGL*>(mCompositor.get());
nsScreenGonk* screen = static_cast<nsWindow*>(mCompositor->GetWidget())->GetScreen();
if (!screen->IsPrimaryScreen()) {
// Only primary screen support mirroring
return;
}
nsWindow* mirrorScreenWidget = screen->GetMirroringWidget();
if (!mirrorScreenWidget) {
// No mirroring
return;
}
nsScreenGonk* mirrorScreen = mirrorScreenWidget->GetScreen();
if (!mirrorScreen->GetTopWindows().IsEmpty()) {
return;
}
EGLSurface surface = mirrorScreen->GetEGLSurface();
if (surface == LOCAL_EGL_NO_SURFACE) {
// Create GLContext
nsRefPtr<GLContext> gl = gl::GLContextProvider::CreateForWindow(mirrorScreenWidget);
mirrorScreenWidget->SetNativeData(NS_NATIVE_OPENGL_CONTEXT,
reinterpret_cast<uintptr_t>(gl.get()));
surface = mirrorScreen->GetEGLSurface();
if (surface == LOCAL_EGL_NO_SURFACE) {
// Failed to create EGLSurface
return;
}
}
GLContext* gl = compositor->gl();
GLContextEGL* egl = GLContextEGL::Cast(gl);
const IntSize windowSize = mirrorScreen->GetNaturalBounds().Size();
#endif
if ((windowSize.width <= 0) || (windowSize.height <= 0)) {
return;
}
ScreenRotation rotation = compositor->GetScreenRotation();
const int actualWidth = windowSize.width;
const int actualHeight = windowSize.height;
const gfx::IntSize originalSize = compositor->GetDestinationSurfaceSize();
const nsIntRect originalRect = nsIntRect(0, 0, originalSize.width, originalSize.height);
int pageWidth = originalSize.width;
int pageHeight = originalSize.height;
if (rotation == ROTATION_90 || rotation == ROTATION_270) {
pageWidth = originalSize.height;
pageHeight = originalSize.width;
}
float scale = 1.0;
if ((pageWidth > actualWidth) || (pageHeight > actualHeight)) {
const float scaleWidth = (float)actualWidth / (float)pageWidth;
const float scaleHeight = (float)actualHeight / (float)pageHeight;
scale = scaleWidth <= scaleHeight ? scaleWidth : scaleHeight;
}
const gfx::IntSize actualSize(actualWidth, actualHeight);
//.........这里部分代码省略.........