1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=2 et tw=80 : */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #include "AndroidCompositorWidget.h"
8 #include "nsWindow.h"
9
10 namespace mozilla {
11 namespace widget {
12
13 void
SetFirstPaintViewport(const LayerIntPoint & aOffset,const CSSToLayerScale & aZoom,const CSSRect & aCssPageRect)14 AndroidCompositorWidget::SetFirstPaintViewport(const LayerIntPoint& aOffset,
15 const CSSToLayerScale& aZoom,
16 const CSSRect& aCssPageRect)
17 {
18 auto layerClient = static_cast<nsWindow*>(RealWidget())->GetLayerClient();
19 if (!layerClient) {
20 return;
21 }
22
23 layerClient->SetFirstPaintViewport(
24 float(aOffset.x), float(aOffset.y), aZoom.scale, aCssPageRect.x,
25 aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
26 }
27
28 void
SyncFrameMetrics(const ParentLayerPoint & aScrollOffset,const CSSToParentLayerScale & aZoom,const CSSRect & aCssPageRect,const CSSRect & aDisplayPort,const CSSToLayerScale & aPaintedResolution,bool aLayersUpdated,int32_t aPaintSyncId,ScreenMargin & aFixedLayerMargins)29 AndroidCompositorWidget::SyncFrameMetrics(const ParentLayerPoint& aScrollOffset,
30 const CSSToParentLayerScale& aZoom,
31 const CSSRect& aCssPageRect,
32 const CSSRect& aDisplayPort,
33 const CSSToLayerScale& aPaintedResolution,
34 bool aLayersUpdated,
35 int32_t aPaintSyncId,
36 ScreenMargin& aFixedLayerMargins)
37 {
38 auto layerClient = static_cast<nsWindow*>(RealWidget())->GetLayerClient();
39 if (!layerClient) {
40 return;
41 }
42
43 // convert the displayport rect from document-relative CSS pixels to
44 // document-relative device pixels
45 LayerIntRect dp = gfx::RoundedToInt(aDisplayPort * aPaintedResolution);
46
47 java::ViewTransform::LocalRef viewTransform = layerClient->SyncFrameMetrics(
48 aScrollOffset.x, aScrollOffset.y, aZoom.scale,
49 aCssPageRect.x, aCssPageRect.y,
50 aCssPageRect.XMost(), aCssPageRect.YMost(),
51 dp.x, dp.y, dp.width, dp.height,
52 aPaintedResolution.scale, aLayersUpdated, aPaintSyncId);
53
54 MOZ_ASSERT(viewTransform, "No view transform object!");
55
56 aFixedLayerMargins.top = viewTransform->FixedLayerMarginTop();
57 aFixedLayerMargins.right = viewTransform->FixedLayerMarginRight();
58 aFixedLayerMargins.bottom = viewTransform->FixedLayerMarginBottom();
59 aFixedLayerMargins.left = viewTransform->FixedLayerMarginLeft();
60 }
61
62 } // namespace widget
63 } // namespace mozilla
64