1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 package org
.mozilla
.gecko
.gfx
;
8 import android
.graphics
.RectF
;
10 import org
.mozilla
.gecko
.util
.FloatUtils
;
13 * This class keeps track of the area we request Gecko to paint, as well
14 * as the resolution of the paint. The area may be different from the visible
15 * area of the page, and the resolution may be different from the resolution
16 * used in the compositor to render the page. This is so that we can ask Gecko
17 * to paint a much larger area without using extra memory, and then render some
18 * subsection of that with compositor scaling.
20 public final class DisplayPortMetrics
{
21 private final RectF mPosition
;
22 private final float mResolution
;
24 public RectF
getPosition() {
28 public float getResolution() {
32 public DisplayPortMetrics() {
36 public DisplayPortMetrics(float left
, float top
, float right
, float bottom
, float resolution
) {
37 mPosition
= new RectF(left
, top
, right
, bottom
);
38 mResolution
= resolution
;
41 public boolean contains(RectF rect
) {
42 return mPosition
.contains(rect
);
45 public boolean fuzzyEquals(DisplayPortMetrics metrics
) {
46 return RectUtils
.fuzzyEquals(mPosition
, metrics
.mPosition
)
47 && FloatUtils
.fuzzyEquals(mResolution
, metrics
.mResolution
);
50 public String
toJSON() {
51 StringBuffer sb
= new StringBuffer(256);
52 sb
.append("{ \"left\": ").append(mPosition
.left
)
53 .append(", \"top\": ").append(mPosition
.top
)
54 .append(", \"right\": ").append(mPosition
.right
)
55 .append(", \"bottom\": ").append(mPosition
.bottom
)
56 .append(", \"resolution\": ").append(mResolution
)
62 public String
toString() {
63 return "DisplayPortMetrics v=(" + mPosition
.left
+ ","
64 + mPosition
.top
+ "," + mPosition
.right
+ ","
65 + mPosition
.bottom
+ ") z=" + mResolution
;