widget/InProcessCompositorWidget.cpp
author Timothy Guan-tin Chien <timdream@gmail.com>
Mon, 28 Jan 2019 18:24:08 +0000
changeset 513567 c1032d34b5e0e525820446f713e4ad6288ebcb56
parent 511623 5f4630838d46dd81dadb13220a4af0da9e23a619
child 519789 0707c5d273227aed4fb04a8f6360875165f83ddd
permissions -rw-r--r--
Bug 1518932 - Convert menulist to custom element r=paolo This custom element replaces XBL <content> usage by directly prepend the two needed child nodes when the element is connected. This is doable because - There isn't any direct access of child nodes under <menulist>. Everyone seems to access via .menupopup, which is usually the only child. - We don't need to move the children under <menulist>. If we need to and if the child is a <xbl:children> (which could happen if <menulist> is inside an XBL <content> that just get cloned to the document), the layout will get very confused and crash (see finding in bug 1514926) Differential Revision: https://phabricator.services.mozilla.com/D16149

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "InProcessCompositorWidget.h"

#include "mozilla/VsyncDispatcher.h"
#include "nsBaseWidget.h"

#if defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
#  include "mozilla/widget/AndroidCompositorWidget.h"
#endif

namespace mozilla {
namespace widget {

// Platforms with no OOP compositor process support use
// InProcessCompositorWidget by default.
#if !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
/* static */ RefPtr<CompositorWidget> CompositorWidget::CreateLocal(
    const CompositorWidgetInitData& aInitData,
    const layers::CompositorOptions& aOptions, nsIWidget* aWidget) {
  MOZ_ASSERT(aWidget);
#  ifdef MOZ_WIDGET_ANDROID
  return new AndroidCompositorWidget(aOptions,
                                     static_cast<nsBaseWidget*>(aWidget));
#  else
  return new InProcessCompositorWidget(aOptions,
                                       static_cast<nsBaseWidget*>(aWidget));
#  endif
}
#endif

InProcessCompositorWidget::InProcessCompositorWidget(
    const layers::CompositorOptions& aOptions, nsBaseWidget* aWidget)
    : CompositorWidget(aOptions), mWidget(aWidget) {}

bool InProcessCompositorWidget::PreRender(WidgetRenderingContext* aContext) {
  return mWidget->PreRender(aContext);
}

void InProcessCompositorWidget::PostRender(WidgetRenderingContext* aContext) {
  mWidget->PostRender(aContext);
}

void InProcessCompositorWidget::DrawWindowUnderlay(
    WidgetRenderingContext* aContext, LayoutDeviceIntRect aRect) {
  mWidget->DrawWindowUnderlay(aContext, aRect);
}

void InProcessCompositorWidget::DrawWindowOverlay(
    WidgetRenderingContext* aContext, LayoutDeviceIntRect aRect) {
  mWidget->DrawWindowOverlay(aContext, aRect);
}

already_AddRefed<gfx::DrawTarget>
InProcessCompositorWidget::StartRemoteDrawing() {
  return mWidget->StartRemoteDrawing();
}

already_AddRefed<gfx::DrawTarget>
InProcessCompositorWidget::StartRemoteDrawingInRegion(
    LayoutDeviceIntRegion& aInvalidRegion, layers::BufferMode* aBufferMode) {
  return mWidget->StartRemoteDrawingInRegion(aInvalidRegion, aBufferMode);
}

void InProcessCompositorWidget::EndRemoteDrawing() {
  mWidget->EndRemoteDrawing();
}

void InProcessCompositorWidget::EndRemoteDrawingInRegion(
    gfx::DrawTarget* aDrawTarget, LayoutDeviceIntRegion& aInvalidRegion) {
  mWidget->EndRemoteDrawingInRegion(aDrawTarget, aInvalidRegion);
}

void InProcessCompositorWidget::CleanupRemoteDrawing() {
  mWidget->CleanupRemoteDrawing();
}

void InProcessCompositorWidget::CleanupWindowEffects() {
  mWidget->CleanupWindowEffects();
}

bool InProcessCompositorWidget::InitCompositor(
    layers::Compositor* aCompositor) {
  return mWidget->InitCompositor(aCompositor);
}

LayoutDeviceIntSize InProcessCompositorWidget::GetClientSize() {
  return mWidget->GetClientSize();
}

uint32_t InProcessCompositorWidget::GetGLFrameBufferFormat() {
  return mWidget->GetGLFrameBufferFormat();
}

uintptr_t InProcessCompositorWidget::GetWidgetKey() {
  return reinterpret_cast<uintptr_t>(mWidget);
}

nsIWidget* InProcessCompositorWidget::RealWidget() { return mWidget; }

void InProcessCompositorWidget::ObserveVsync(VsyncObserver* aObserver) {
  if (RefPtr<CompositorVsyncDispatcher> cvd =
          mWidget->GetCompositorVsyncDispatcher()) {
    cvd->SetCompositorVsyncObserver(aObserver);
  }
}

}  // namespace widget
}  // namespace mozilla