зеркало из https://github.com/mozilla/gecko-dev.git
Родитель
7d848712bf
Коммит
3678727236
|
@ -1,97 +1,97 @@
|
|||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// debug.cpp: Debugging utilities.
|
||||
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <d3d9.h>
|
||||
#include <windows.h>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
typedef void (WINAPI *PerfOutputFunction)(D3DCOLOR, LPCWSTR);
|
||||
|
||||
static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg)
|
||||
{
|
||||
#if !defined(ANGLE_DISABLE_PERF)
|
||||
if (perfActive())
|
||||
{
|
||||
char message[4096];
|
||||
int len = vsprintf_s(message, format, vararg);
|
||||
if (len < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// There are no ASCII variants of these D3DPERF functions.
|
||||
wchar_t wideMessage[4096];
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
wideMessage[i] = message[i];
|
||||
}
|
||||
wideMessage[len] = 0;
|
||||
|
||||
perfFunc(0, wideMessage);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(ANGLE_DISABLE_TRACE)
|
||||
#if defined(NDEBUG)
|
||||
if (traceFileDebugOnly)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
FILE* file = fopen(TRACE_OUTPUT_FILE, "a");
|
||||
if (file)
|
||||
{
|
||||
vfprintf(file, format, vararg);
|
||||
fclose(file);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void trace(bool traceFileDebugOnly, const char *format, ...)
|
||||
{
|
||||
va_list vararg;
|
||||
va_start(vararg, format);
|
||||
output(traceFileDebugOnly, D3DPERF_SetMarker, format, vararg);
|
||||
va_end(vararg);
|
||||
}
|
||||
|
||||
bool perfActive()
|
||||
{
|
||||
#if defined(ANGLE_DISABLE_PERF)
|
||||
return false;
|
||||
#else
|
||||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// debug.cpp: Debugging utilities.
|
||||
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <d3d9.h>
|
||||
#include <windows.h>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
typedef void (WINAPI *PerfOutputFunction)(D3DCOLOR, LPCWSTR);
|
||||
|
||||
static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg)
|
||||
{
|
||||
#if !defined(ANGLE_DISABLE_PERF)
|
||||
if (perfActive())
|
||||
{
|
||||
char message[4096];
|
||||
int len = vsprintf_s(message, format, vararg);
|
||||
if (len < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// There are no ASCII variants of these D3DPERF functions.
|
||||
wchar_t wideMessage[4096];
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
wideMessage[i] = message[i];
|
||||
}
|
||||
wideMessage[len] = 0;
|
||||
|
||||
perfFunc(0, wideMessage);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(ANGLE_DISABLE_TRACE)
|
||||
#if defined(NDEBUG)
|
||||
if (traceFileDebugOnly)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
FILE* file = fopen(TRACE_OUTPUT_FILE, "a");
|
||||
if (file)
|
||||
{
|
||||
vfprintf(file, format, vararg);
|
||||
fclose(file);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void trace(bool traceFileDebugOnly, const char *format, ...)
|
||||
{
|
||||
va_list vararg;
|
||||
va_start(vararg, format);
|
||||
output(traceFileDebugOnly, D3DPERF_SetMarker, format, vararg);
|
||||
va_end(vararg);
|
||||
}
|
||||
|
||||
bool perfActive()
|
||||
{
|
||||
#if defined(ANGLE_DISABLE_PERF)
|
||||
return false;
|
||||
#else
|
||||
static bool active = D3DPERF_GetStatus() != 0;
|
||||
return active;
|
||||
#endif
|
||||
}
|
||||
|
||||
ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
|
||||
{
|
||||
va_list vararg;
|
||||
va_start(vararg, format);
|
||||
output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg);
|
||||
va_end(vararg);
|
||||
}
|
||||
|
||||
ScopedPerfEventHelper::~ScopedPerfEventHelper()
|
||||
{
|
||||
#if !defined(ANGLE_DISABLE_PERF)
|
||||
if (perfActive())
|
||||
{
|
||||
D3DPERF_EndEvent();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return active;
|
||||
#endif
|
||||
}
|
||||
|
||||
ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
|
||||
{
|
||||
va_list vararg;
|
||||
va_start(vararg, format);
|
||||
output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg);
|
||||
va_end(vararg);
|
||||
}
|
||||
|
||||
ScopedPerfEventHelper::~ScopedPerfEventHelper()
|
||||
{
|
||||
#if !defined(ANGLE_DISABLE_PERF)
|
||||
if (perfActive())
|
||||
{
|
||||
D3DPERF_EndEvent();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#if _MSC_VER <= 1400
|
||||
#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
|
||||
#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
|
||||
#if _MSC_VER <= 1400
|
||||
#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
|
||||
#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
|
||||
#endif
|
||||
|
||||
#include <intrin.h>
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
#ifndef LIBGLESV2_MATHUTIL_H_
|
||||
#define LIBGLESV2_MATHUTIL_H_
|
||||
|
||||
#if _MSC_VER <= 1400
|
||||
#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
|
||||
#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
|
||||
|
||||
#if _MSC_VER <= 1400
|
||||
#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
|
||||
#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
|
||||
#endif
|
||||
|
||||
#include <intrin.h>
|
||||
|
|
|
@ -865,7 +865,7 @@ std::string getTempPath()
|
|||
return std::string();
|
||||
}
|
||||
|
||||
return path;
|
||||
return path;
|
||||
}
|
||||
|
||||
void writeFile(const char* path, const void* content, size_t size)
|
||||
|
@ -878,5 +878,5 @@ void writeFile(const char* path, const void* content, size_t size)
|
|||
}
|
||||
|
||||
fwrite(content, sizeof(char), size, file);
|
||||
fclose(file);
|
||||
fclose(file);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
diff -r e10a8066a62c gfx/cairo/cairo/src/cairo-win32-private.h
|
||||
--- a/gfx/cairo/cairo/src/cairo-win32-private.h Fri Jun 08 17:39:38 2007 -0700
|
||||
+++ b/gfx/cairo/cairo/src/cairo-win32-private.h Fri Jun 29 09:14:35 2007 +0200
|
||||
@@ -46,7 +46,7 @@
|
||||
#define SB_NONE 0
|
||||
#endif
|
||||
|
||||
-#define WIN32_FONT_LOGICAL_SCALE 32
|
||||
+#define WIN32_FONT_LOGICAL_SCALE 1
|
||||
|
||||
typedef struct _cairo_win32_surface {
|
||||
cairo_surface_t base;
|
||||
diff -r e10a8066a62c gfx/cairo/cairo/src/cairo-win32-private.h
|
||||
--- a/gfx/cairo/cairo/src/cairo-win32-private.h Fri Jun 08 17:39:38 2007 -0700
|
||||
+++ b/gfx/cairo/cairo/src/cairo-win32-private.h Fri Jun 29 09:14:35 2007 +0200
|
||||
@@ -46,7 +46,7 @@
|
||||
#define SB_NONE 0
|
||||
#endif
|
||||
|
||||
-#define WIN32_FONT_LOGICAL_SCALE 32
|
||||
+#define WIN32_FONT_LOGICAL_SCALE 1
|
||||
|
||||
typedef struct _cairo_win32_surface {
|
||||
cairo_surface_t base;
|
||||
|
|
|
@ -1,140 +1,140 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Red Hat, Inc.
|
||||
*
|
||||
* This is part of HarfBuzz, a text shaping library.
|
||||
*
|
||||
* Permission is hereby granted, without written agreement and without
|
||||
* license or royalty fees, to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose, provided that the
|
||||
* above copyright notice and the following two paragraphs appear in
|
||||
* all copies of this software.
|
||||
*
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
||||
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
||||
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
||||
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*
|
||||
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
||||
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* Red Hat Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_OT_HEAD_PRIVATE_HH
|
||||
#define HB_OT_HEAD_PRIVATE_HH
|
||||
|
||||
#include "hb-open-type-private.hh"
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
|
||||
/*
|
||||
* head
|
||||
*/
|
||||
|
||||
#define HB_OT_TAG_head HB_TAG('h','e','a','d')
|
||||
|
||||
struct head
|
||||
{
|
||||
static const hb_tag_t Tag = HB_OT_TAG_head;
|
||||
|
||||
inline unsigned int get_upem (void) const {
|
||||
unsigned int upem = unitsPerEm;
|
||||
/* If no valid head table found, assume 1000, which matches typicaly Type1 usage. */
|
||||
return 16 <= upem && upem <= 16384 ? upem : 1000;
|
||||
}
|
||||
|
||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||
TRACE_SANITIZE ();
|
||||
/* Shall we check for magicNumber here? Who cares? */
|
||||
return c->check_struct (this) && likely (version.major == 1);
|
||||
}
|
||||
|
||||
private:
|
||||
FixedVersion version; /* Version of the head table--currently
|
||||
* 0x00010000 for version 1.0. */
|
||||
FixedVersion fontRevision; /* Set by font manufacturer. */
|
||||
ULONG checkSumAdjustment; /* To compute: set it to 0, sum the
|
||||
* entire font as ULONG, then store
|
||||
* 0xB1B0AFBA - sum. */
|
||||
ULONG magicNumber; /* Set to 0x5F0F3CF5. */
|
||||
USHORT flags; /* Bit 0: Baseline for font at y=0;
|
||||
* Bit 1: Left sidebearing point at x=0;
|
||||
* Bit 2: Instructions may depend on point size;
|
||||
* Bit 3: Force ppem to integer values for all
|
||||
* internal scaler math; may use fractional
|
||||
* ppem sizes if this bit is clear;
|
||||
* Bit 4: Instructions may alter advance width
|
||||
* (the advance widths might not scale linearly);
|
||||
|
||||
* Bits 5-10: These should be set according to
|
||||
* Apple's specification. However, they are not
|
||||
* implemented in OpenType.
|
||||
* Bit 5: This bit should be set in fonts that are
|
||||
* intended to e laid out vertically, and in
|
||||
* which the glyphs have been drawn such that an
|
||||
* x-coordinate of 0 corresponds to the desired
|
||||
* vertical baseline.
|
||||
* Bit 6: This bit must be set to zero.
|
||||
* Bit 7: This bit should be set if the font
|
||||
* requires layout for correct linguistic
|
||||
* rendering (e.g. Arabic fonts).
|
||||
* Bit 8: This bit should be set for a GX font
|
||||
* which has one or more metamorphosis effects
|
||||
* designated as happening by default.
|
||||
* Bit 9: This bit should be set if the font
|
||||
* contains any strong right-to-left glyphs.
|
||||
* Bit 10: This bit should be set if the font
|
||||
* contains Indic-style rearrangement effects.
|
||||
|
||||
* Bit 11: Font data is 'lossless,' as a result
|
||||
* of having been compressed and decompressed
|
||||
* with the Agfa MicroType Express engine.
|
||||
* Bit 12: Font converted (produce compatible metrics)
|
||||
* Bit 13: Font optimized for ClearType™.
|
||||
* Note, fonts that rely on embedded bitmaps (EBDT)
|
||||
* for rendering should not be considered optimized
|
||||
* for ClearType, and therefore should keep this bit
|
||||
* cleared.
|
||||
* Bit 14: Reserved, set to 0
|
||||
* Bit 15: Reserved, set to 0. */
|
||||
USHORT unitsPerEm; /* Valid range is from 16 to 16384. This value
|
||||
* should be a power of 2 for fonts that have
|
||||
* TrueType outlines. */
|
||||
LONGDATETIME created; /* Number of seconds since 12:00 midnight,
|
||||
January 1, 1904. 64-bit integer */
|
||||
LONGDATETIME modified; /* Number of seconds since 12:00 midnight,
|
||||
January 1, 1904. 64-bit integer */
|
||||
SHORT xMin; /* For all glyph bounding boxes. */
|
||||
SHORT yMin; /* For all glyph bounding boxes. */
|
||||
SHORT xMax; /* For all glyph bounding boxes. */
|
||||
SHORT yMax; /* For all glyph bounding boxes. */
|
||||
USHORT macStyle; /* Bit 0: Bold (if set to 1);
|
||||
* Bit 1: Italic (if set to 1)
|
||||
* Bit 2: Underline (if set to 1)
|
||||
* Bit 3: Outline (if set to 1)
|
||||
* Bit 4: Shadow (if set to 1)
|
||||
* Bit 5: Condensed (if set to 1)
|
||||
* Bit 6: Extended (if set to 1)
|
||||
* Bits 7-15: Reserved (set to 0). */
|
||||
USHORT lowestRecPPEM; /* Smallest readable size in pixels. */
|
||||
SHORT fontDirectionHint; /* Deprecated (Set to 2).
|
||||
* 0: Fully mixed directional glyphs;
|
||||
* 1: Only strongly left to right;
|
||||
* 2: Like 1 but also contains neutrals;
|
||||
* -1: Only strongly right to left;
|
||||
* -2: Like -1 but also contains neutrals. */
|
||||
SHORT indexToLocFormat; /* 0 for short offsets, 1 for long. */
|
||||
SHORT glyphDataFormat; /* 0 for current format. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (54);
|
||||
};
|
||||
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
#endif /* HB_OT_HEAD_PRIVATE_HH */
|
||||
/*
|
||||
* Copyright (C) 2010 Red Hat, Inc.
|
||||
*
|
||||
* This is part of HarfBuzz, a text shaping library.
|
||||
*
|
||||
* Permission is hereby granted, without written agreement and without
|
||||
* license or royalty fees, to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose, provided that the
|
||||
* above copyright notice and the following two paragraphs appear in
|
||||
* all copies of this software.
|
||||
*
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
||||
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
||||
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
||||
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*
|
||||
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
||||
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* Red Hat Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_OT_HEAD_PRIVATE_HH
|
||||
#define HB_OT_HEAD_PRIVATE_HH
|
||||
|
||||
#include "hb-open-type-private.hh"
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
|
||||
/*
|
||||
* head
|
||||
*/
|
||||
|
||||
#define HB_OT_TAG_head HB_TAG('h','e','a','d')
|
||||
|
||||
struct head
|
||||
{
|
||||
static const hb_tag_t Tag = HB_OT_TAG_head;
|
||||
|
||||
inline unsigned int get_upem (void) const {
|
||||
unsigned int upem = unitsPerEm;
|
||||
/* If no valid head table found, assume 1000, which matches typicaly Type1 usage. */
|
||||
return 16 <= upem && upem <= 16384 ? upem : 1000;
|
||||
}
|
||||
|
||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||
TRACE_SANITIZE ();
|
||||
/* Shall we check for magicNumber here? Who cares? */
|
||||
return c->check_struct (this) && likely (version.major == 1);
|
||||
}
|
||||
|
||||
private:
|
||||
FixedVersion version; /* Version of the head table--currently
|
||||
* 0x00010000 for version 1.0. */
|
||||
FixedVersion fontRevision; /* Set by font manufacturer. */
|
||||
ULONG checkSumAdjustment; /* To compute: set it to 0, sum the
|
||||
* entire font as ULONG, then store
|
||||
* 0xB1B0AFBA - sum. */
|
||||
ULONG magicNumber; /* Set to 0x5F0F3CF5. */
|
||||
USHORT flags; /* Bit 0: Baseline for font at y=0;
|
||||
* Bit 1: Left sidebearing point at x=0;
|
||||
* Bit 2: Instructions may depend on point size;
|
||||
* Bit 3: Force ppem to integer values for all
|
||||
* internal scaler math; may use fractional
|
||||
* ppem sizes if this bit is clear;
|
||||
* Bit 4: Instructions may alter advance width
|
||||
* (the advance widths might not scale linearly);
|
||||
|
||||
* Bits 5-10: These should be set according to
|
||||
* Apple's specification. However, they are not
|
||||
* implemented in OpenType.
|
||||
* Bit 5: This bit should be set in fonts that are
|
||||
* intended to e laid out vertically, and in
|
||||
* which the glyphs have been drawn such that an
|
||||
* x-coordinate of 0 corresponds to the desired
|
||||
* vertical baseline.
|
||||
* Bit 6: This bit must be set to zero.
|
||||
* Bit 7: This bit should be set if the font
|
||||
* requires layout for correct linguistic
|
||||
* rendering (e.g. Arabic fonts).
|
||||
* Bit 8: This bit should be set for a GX font
|
||||
* which has one or more metamorphosis effects
|
||||
* designated as happening by default.
|
||||
* Bit 9: This bit should be set if the font
|
||||
* contains any strong right-to-left glyphs.
|
||||
* Bit 10: This bit should be set if the font
|
||||
* contains Indic-style rearrangement effects.
|
||||
|
||||
* Bit 11: Font data is 'lossless,' as a result
|
||||
* of having been compressed and decompressed
|
||||
* with the Agfa MicroType Express engine.
|
||||
* Bit 12: Font converted (produce compatible metrics)
|
||||
* Bit 13: Font optimized for ClearType™.
|
||||
* Note, fonts that rely on embedded bitmaps (EBDT)
|
||||
* for rendering should not be considered optimized
|
||||
* for ClearType, and therefore should keep this bit
|
||||
* cleared.
|
||||
* Bit 14: Reserved, set to 0
|
||||
* Bit 15: Reserved, set to 0. */
|
||||
USHORT unitsPerEm; /* Valid range is from 16 to 16384. This value
|
||||
* should be a power of 2 for fonts that have
|
||||
* TrueType outlines. */
|
||||
LONGDATETIME created; /* Number of seconds since 12:00 midnight,
|
||||
January 1, 1904. 64-bit integer */
|
||||
LONGDATETIME modified; /* Number of seconds since 12:00 midnight,
|
||||
January 1, 1904. 64-bit integer */
|
||||
SHORT xMin; /* For all glyph bounding boxes. */
|
||||
SHORT yMin; /* For all glyph bounding boxes. */
|
||||
SHORT xMax; /* For all glyph bounding boxes. */
|
||||
SHORT yMax; /* For all glyph bounding boxes. */
|
||||
USHORT macStyle; /* Bit 0: Bold (if set to 1);
|
||||
* Bit 1: Italic (if set to 1)
|
||||
* Bit 2: Underline (if set to 1)
|
||||
* Bit 3: Outline (if set to 1)
|
||||
* Bit 4: Shadow (if set to 1)
|
||||
* Bit 5: Condensed (if set to 1)
|
||||
* Bit 6: Extended (if set to 1)
|
||||
* Bits 7-15: Reserved (set to 0). */
|
||||
USHORT lowestRecPPEM; /* Smallest readable size in pixels. */
|
||||
SHORT fontDirectionHint; /* Deprecated (Set to 2).
|
||||
* 0: Fully mixed directional glyphs;
|
||||
* 1: Only strongly left to right;
|
||||
* 2: Like 1 but also contains neutrals;
|
||||
* -1: Only strongly right to left;
|
||||
* -2: Like -1 but also contains neutrals. */
|
||||
SHORT indexToLocFormat; /* 0 for short offsets, 1 for long. */
|
||||
SHORT glyphDataFormat; /* 0 for current format. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (54);
|
||||
};
|
||||
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
#endif /* HB_OT_HEAD_PRIVATE_HH */
|
||||
|
|
|
@ -1,97 +1,97 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Firefox.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the Mozilla Foundation <http://www.mozilla.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "SharedDIBSurface.h"
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
static const cairo_user_data_key_t SHAREDDIB_KEY = {0};
|
||||
|
||||
static const long kBytesPerPixel = 4;
|
||||
|
||||
bool
|
||||
SharedDIBSurface::Create(HDC adc, PRUint32 aWidth, PRUint32 aHeight,
|
||||
bool aTransparent)
|
||||
{
|
||||
nsresult rv = mSharedDIB.Create(adc, aWidth, aHeight, aTransparent);
|
||||
if (NS_FAILED(rv) || !mSharedDIB.IsValid())
|
||||
return false;
|
||||
|
||||
InitSurface(aWidth, aHeight, aTransparent);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
SharedDIBSurface::Attach(Handle aHandle, PRUint32 aWidth, PRUint32 aHeight,
|
||||
bool aTransparent)
|
||||
{
|
||||
nsresult rv = mSharedDIB.Attach(aHandle, aWidth, aHeight, aTransparent);
|
||||
if (NS_FAILED(rv) || !mSharedDIB.IsValid())
|
||||
return false;
|
||||
|
||||
InitSurface(aWidth, aHeight, aTransparent);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
SharedDIBSurface::InitSurface(PRUint32 aWidth, PRUint32 aHeight,
|
||||
bool aTransparent)
|
||||
{
|
||||
long stride = long(aWidth * kBytesPerPixel);
|
||||
unsigned char* data = reinterpret_cast<unsigned char*>(mSharedDIB.GetBits());
|
||||
|
||||
gfxImageFormat format = aTransparent ? ImageFormatARGB32 : ImageFormatRGB24;
|
||||
|
||||
gfxImageSurface::InitWithData(data, gfxIntSize(aWidth, aHeight),
|
||||
stride, format);
|
||||
|
||||
cairo_surface_set_user_data(mSurface, &SHAREDDIB_KEY, this, NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
SharedDIBSurface::IsSharedDIBSurface(gfxASurface* aSurface)
|
||||
{
|
||||
return aSurface &&
|
||||
aSurface->GetType() == gfxASurface::SurfaceTypeImage &&
|
||||
aSurface->GetData(&SHAREDDIB_KEY);
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Firefox.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the Mozilla Foundation <http://www.mozilla.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "SharedDIBSurface.h"
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
static const cairo_user_data_key_t SHAREDDIB_KEY = {0};
|
||||
|
||||
static const long kBytesPerPixel = 4;
|
||||
|
||||
bool
|
||||
SharedDIBSurface::Create(HDC adc, PRUint32 aWidth, PRUint32 aHeight,
|
||||
bool aTransparent)
|
||||
{
|
||||
nsresult rv = mSharedDIB.Create(adc, aWidth, aHeight, aTransparent);
|
||||
if (NS_FAILED(rv) || !mSharedDIB.IsValid())
|
||||
return false;
|
||||
|
||||
InitSurface(aWidth, aHeight, aTransparent);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
SharedDIBSurface::Attach(Handle aHandle, PRUint32 aWidth, PRUint32 aHeight,
|
||||
bool aTransparent)
|
||||
{
|
||||
nsresult rv = mSharedDIB.Attach(aHandle, aWidth, aHeight, aTransparent);
|
||||
if (NS_FAILED(rv) || !mSharedDIB.IsValid())
|
||||
return false;
|
||||
|
||||
InitSurface(aWidth, aHeight, aTransparent);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
SharedDIBSurface::InitSurface(PRUint32 aWidth, PRUint32 aHeight,
|
||||
bool aTransparent)
|
||||
{
|
||||
long stride = long(aWidth * kBytesPerPixel);
|
||||
unsigned char* data = reinterpret_cast<unsigned char*>(mSharedDIB.GetBits());
|
||||
|
||||
gfxImageFormat format = aTransparent ? ImageFormatARGB32 : ImageFormatRGB24;
|
||||
|
||||
gfxImageSurface::InitWithData(data, gfxIntSize(aWidth, aHeight),
|
||||
stride, format);
|
||||
|
||||
cairo_surface_set_user_data(mSurface, &SHAREDDIB_KEY, this, NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
SharedDIBSurface::IsSharedDIBSurface(gfxASurface* aSurface)
|
||||
{
|
||||
return aSurface &&
|
||||
aSurface->GetType() == gfxASurface::SurfaceTypeImage &&
|
||||
aSurface->GetData(&SHAREDDIB_KEY);
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -1,94 +1,94 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Firefox.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the Mozilla Foundation <http://www.mozilla.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef mozilla_gfx_SharedDIBSurface_h
|
||||
#define mozilla_gfx_SharedDIBSurface_h
|
||||
|
||||
#include "gfxImageSurface.h"
|
||||
#include "SharedDIBWin.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
/**
|
||||
* A SharedDIBSurface owns an underlying SharedDIBWin.
|
||||
*/
|
||||
class SharedDIBSurface : public gfxImageSurface
|
||||
{
|
||||
public:
|
||||
typedef base::SharedMemoryHandle Handle;
|
||||
|
||||
SharedDIBSurface() { }
|
||||
~SharedDIBSurface() { }
|
||||
|
||||
/**
|
||||
* Create this image surface backed by shared memory.
|
||||
*/
|
||||
bool Create(HDC adc, PRUint32 aWidth, PRUint32 aHeight, bool aTransparent);
|
||||
|
||||
/**
|
||||
* Attach this surface to shared memory from another process.
|
||||
*/
|
||||
bool Attach(Handle aHandle, PRUint32 aWidth, PRUint32 aHeight,
|
||||
bool aTransparent);
|
||||
|
||||
/**
|
||||
* After drawing to a surface via GDI, GDI must be flushed before the bitmap
|
||||
* is valid.
|
||||
*/
|
||||
void Flush() { ::GdiFlush(); }
|
||||
|
||||
HDC GetHDC() { return mSharedDIB.GetHDC(); }
|
||||
|
||||
nsresult ShareToProcess(base::ProcessHandle aChildProcess, Handle* aChildHandle) {
|
||||
return mSharedDIB.ShareToProcess(aChildProcess, aChildHandle);
|
||||
}
|
||||
|
||||
static bool IsSharedDIBSurface(gfxASurface* aSurface);
|
||||
|
||||
private:
|
||||
SharedDIBWin mSharedDIB;
|
||||
|
||||
void InitSurface(PRUint32 aWidth, PRUint32 aHeight, bool aTransparent);
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_gfx_SharedDIBSurface_h
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Firefox.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the Mozilla Foundation <http://www.mozilla.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef mozilla_gfx_SharedDIBSurface_h
|
||||
#define mozilla_gfx_SharedDIBSurface_h
|
||||
|
||||
#include "gfxImageSurface.h"
|
||||
#include "SharedDIBWin.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
/**
|
||||
* A SharedDIBSurface owns an underlying SharedDIBWin.
|
||||
*/
|
||||
class SharedDIBSurface : public gfxImageSurface
|
||||
{
|
||||
public:
|
||||
typedef base::SharedMemoryHandle Handle;
|
||||
|
||||
SharedDIBSurface() { }
|
||||
~SharedDIBSurface() { }
|
||||
|
||||
/**
|
||||
* Create this image surface backed by shared memory.
|
||||
*/
|
||||
bool Create(HDC adc, PRUint32 aWidth, PRUint32 aHeight, bool aTransparent);
|
||||
|
||||
/**
|
||||
* Attach this surface to shared memory from another process.
|
||||
*/
|
||||
bool Attach(Handle aHandle, PRUint32 aWidth, PRUint32 aHeight,
|
||||
bool aTransparent);
|
||||
|
||||
/**
|
||||
* After drawing to a surface via GDI, GDI must be flushed before the bitmap
|
||||
* is valid.
|
||||
*/
|
||||
void Flush() { ::GdiFlush(); }
|
||||
|
||||
HDC GetHDC() { return mSharedDIB.GetHDC(); }
|
||||
|
||||
nsresult ShareToProcess(base::ProcessHandle aChildProcess, Handle* aChildHandle) {
|
||||
return mSharedDIB.ShareToProcess(aChildProcess, aChildHandle);
|
||||
}
|
||||
|
||||
static bool IsSharedDIBSurface(gfxASurface* aSurface);
|
||||
|
||||
private:
|
||||
SharedDIBWin mSharedDIB;
|
||||
|
||||
void InitSurface(PRUint32 aWidth, PRUint32 aHeight, bool aTransparent);
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_gfx_SharedDIBSurface_h
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,109 +1,109 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert O'Callahan <robert@ocallahan.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_BASEMARGIN_H_
|
||||
#define MOZILLA_BASEMARGIN_H_
|
||||
|
||||
#include "gfxCore.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Do not use this class directly. Subclass it, pass that subclass as the
|
||||
* Sub parameter, and only use that subclass.
|
||||
*/
|
||||
template <class T, class Sub>
|
||||
struct BaseMargin {
|
||||
typedef mozilla::css::Side SideT;
|
||||
|
||||
// Do not change the layout of these members; the Side() methods below
|
||||
// depend on this order.
|
||||
T top, right, bottom, left;
|
||||
|
||||
// Constructors
|
||||
BaseMargin() : top(0), right(0), bottom(0), left(0) {}
|
||||
BaseMargin(T aLeft, T aTop, T aRight, T aBottom) :
|
||||
top(aTop), right(aRight), bottom(aBottom), left(aLeft) {}
|
||||
|
||||
void SizeTo(T aLeft, T aTop, T aRight, T aBottom)
|
||||
{
|
||||
left = aLeft; top = aTop; right = aRight; bottom = aBottom;
|
||||
}
|
||||
|
||||
T LeftRight() const { return left + right; }
|
||||
T TopBottom() const { return top + bottom; }
|
||||
|
||||
T& Side(SideT aSide) {
|
||||
NS_PRECONDITION(aSide <= NS_SIDE_LEFT, "Out of range side");
|
||||
// This is ugly!
|
||||
return *(&top + aSide);
|
||||
}
|
||||
T Side(SideT aSide) const {
|
||||
NS_PRECONDITION(aSide <= NS_SIDE_LEFT, "Out of range side");
|
||||
// This is ugly!
|
||||
return *(&top + aSide);
|
||||
}
|
||||
|
||||
// Overloaded operators. Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
bool operator==(const Sub& aMargin) const {
|
||||
return left == aMargin.left && top == aMargin.top &&
|
||||
right == aMargin.right && bottom == aMargin.bottom;
|
||||
}
|
||||
bool operator!=(const Sub& aMargin) const {
|
||||
return !(*this == aMargin);
|
||||
}
|
||||
Sub operator+(const Sub& aMargin) const {
|
||||
return Sub(left + aMargin.left, top + aMargin.top,
|
||||
right + aMargin.right, bottom + aMargin.bottom);
|
||||
}
|
||||
Sub operator-(const Sub& aMargin) const {
|
||||
return Sub(left - aMargin.left, top - aMargin.top,
|
||||
right - aMargin.right, bottom - aMargin.bottom);
|
||||
}
|
||||
Sub& operator+=(const Sub& aMargin) {
|
||||
left += aMargin.left;
|
||||
top += aMargin.top;
|
||||
right += aMargin.right;
|
||||
bottom += aMargin.bottom;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_BASEMARGIN_H_ */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert O'Callahan <robert@ocallahan.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_BASEMARGIN_H_
|
||||
#define MOZILLA_BASEMARGIN_H_
|
||||
|
||||
#include "gfxCore.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Do not use this class directly. Subclass it, pass that subclass as the
|
||||
* Sub parameter, and only use that subclass.
|
||||
*/
|
||||
template <class T, class Sub>
|
||||
struct BaseMargin {
|
||||
typedef mozilla::css::Side SideT;
|
||||
|
||||
// Do not change the layout of these members; the Side() methods below
|
||||
// depend on this order.
|
||||
T top, right, bottom, left;
|
||||
|
||||
// Constructors
|
||||
BaseMargin() : top(0), right(0), bottom(0), left(0) {}
|
||||
BaseMargin(T aLeft, T aTop, T aRight, T aBottom) :
|
||||
top(aTop), right(aRight), bottom(aBottom), left(aLeft) {}
|
||||
|
||||
void SizeTo(T aLeft, T aTop, T aRight, T aBottom)
|
||||
{
|
||||
left = aLeft; top = aTop; right = aRight; bottom = aBottom;
|
||||
}
|
||||
|
||||
T LeftRight() const { return left + right; }
|
||||
T TopBottom() const { return top + bottom; }
|
||||
|
||||
T& Side(SideT aSide) {
|
||||
NS_PRECONDITION(aSide <= NS_SIDE_LEFT, "Out of range side");
|
||||
// This is ugly!
|
||||
return *(&top + aSide);
|
||||
}
|
||||
T Side(SideT aSide) const {
|
||||
NS_PRECONDITION(aSide <= NS_SIDE_LEFT, "Out of range side");
|
||||
// This is ugly!
|
||||
return *(&top + aSide);
|
||||
}
|
||||
|
||||
// Overloaded operators. Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
bool operator==(const Sub& aMargin) const {
|
||||
return left == aMargin.left && top == aMargin.top &&
|
||||
right == aMargin.right && bottom == aMargin.bottom;
|
||||
}
|
||||
bool operator!=(const Sub& aMargin) const {
|
||||
return !(*this == aMargin);
|
||||
}
|
||||
Sub operator+(const Sub& aMargin) const {
|
||||
return Sub(left + aMargin.left, top + aMargin.top,
|
||||
right + aMargin.right, bottom + aMargin.bottom);
|
||||
}
|
||||
Sub operator-(const Sub& aMargin) const {
|
||||
return Sub(left - aMargin.left, top - aMargin.top,
|
||||
right - aMargin.right, bottom - aMargin.bottom);
|
||||
}
|
||||
Sub& operator+=(const Sub& aMargin) {
|
||||
left += aMargin.left;
|
||||
top += aMargin.top;
|
||||
right += aMargin.right;
|
||||
bottom += aMargin.bottom;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_BASEMARGIN_H_ */
|
||||
|
|
|
@ -1,100 +1,100 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert O'Callahan <robert@ocallahan.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_BASEPOINT_H_
|
||||
#define MOZILLA_BASEPOINT_H_
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Do not use this class directly. Subclass it, pass that subclass as the
|
||||
* Sub parameter, and only use that subclass. This allows methods to safely
|
||||
* cast 'this' to 'Sub*'.
|
||||
*/
|
||||
template <class T, class Sub>
|
||||
struct BasePoint {
|
||||
T x, y;
|
||||
|
||||
// Constructors
|
||||
BasePoint() : x(0), y(0) {}
|
||||
BasePoint(T aX, T aY) : x(aX), y(aY) {}
|
||||
|
||||
void MoveTo(T aX, T aY) { x = aX; y = aY; }
|
||||
void MoveBy(T aDx, T aDy) { x += aDx; y += aDy; }
|
||||
|
||||
// Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
|
||||
bool operator==(const Sub& aPoint) const {
|
||||
return x == aPoint.x && y == aPoint.y;
|
||||
}
|
||||
bool operator!=(const Sub& aPoint) const {
|
||||
return x != aPoint.x || y != aPoint.y;
|
||||
}
|
||||
|
||||
Sub operator+(const Sub& aPoint) const {
|
||||
return Sub(x + aPoint.x, y + aPoint.y);
|
||||
}
|
||||
Sub operator-(const Sub& aPoint) const {
|
||||
return Sub(x - aPoint.x, y - aPoint.y);
|
||||
}
|
||||
Sub& operator+=(const Sub& aPoint) {
|
||||
x += aPoint.x;
|
||||
y += aPoint.y;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
Sub& operator-=(const Sub& aPoint) {
|
||||
x -= aPoint.x;
|
||||
y -= aPoint.y;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
|
||||
Sub operator*(T aScale) const {
|
||||
return Sub(x * aScale, y * aScale);
|
||||
}
|
||||
Sub operator/(T aScale) const {
|
||||
return Sub(x / aScale, y / aScale);
|
||||
}
|
||||
|
||||
Sub operator-() const {
|
||||
return Sub(-x, -y);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_BASEPOINT_H_ */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert O'Callahan <robert@ocallahan.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_BASEPOINT_H_
|
||||
#define MOZILLA_BASEPOINT_H_
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Do not use this class directly. Subclass it, pass that subclass as the
|
||||
* Sub parameter, and only use that subclass. This allows methods to safely
|
||||
* cast 'this' to 'Sub*'.
|
||||
*/
|
||||
template <class T, class Sub>
|
||||
struct BasePoint {
|
||||
T x, y;
|
||||
|
||||
// Constructors
|
||||
BasePoint() : x(0), y(0) {}
|
||||
BasePoint(T aX, T aY) : x(aX), y(aY) {}
|
||||
|
||||
void MoveTo(T aX, T aY) { x = aX; y = aY; }
|
||||
void MoveBy(T aDx, T aDy) { x += aDx; y += aDy; }
|
||||
|
||||
// Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
|
||||
bool operator==(const Sub& aPoint) const {
|
||||
return x == aPoint.x && y == aPoint.y;
|
||||
}
|
||||
bool operator!=(const Sub& aPoint) const {
|
||||
return x != aPoint.x || y != aPoint.y;
|
||||
}
|
||||
|
||||
Sub operator+(const Sub& aPoint) const {
|
||||
return Sub(x + aPoint.x, y + aPoint.y);
|
||||
}
|
||||
Sub operator-(const Sub& aPoint) const {
|
||||
return Sub(x - aPoint.x, y - aPoint.y);
|
||||
}
|
||||
Sub& operator+=(const Sub& aPoint) {
|
||||
x += aPoint.x;
|
||||
y += aPoint.y;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
Sub& operator-=(const Sub& aPoint) {
|
||||
x -= aPoint.x;
|
||||
y -= aPoint.y;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
|
||||
Sub operator*(T aScale) const {
|
||||
return Sub(x * aScale, y * aScale);
|
||||
}
|
||||
Sub operator/(T aScale) const {
|
||||
return Sub(x / aScale, y / aScale);
|
||||
}
|
||||
|
||||
Sub operator-() const {
|
||||
return Sub(-x, -y);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_BASEPOINT_H_ */
|
||||
|
|
|
@ -1,318 +1,318 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert O'Callahan <robert@ocallahan.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_BASERECT_H_
|
||||
#define MOZILLA_BASERECT_H_
|
||||
|
||||
#include "nsAlgorithm.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Rectangles have two interpretations: a set of (zero-size) points,
|
||||
* and a rectangular area of the plane. Most rectangle operations behave
|
||||
* the same no matter what interpretation is being used, but some operations
|
||||
* differ:
|
||||
* -- Equality tests behave differently. When a rectangle represents an area,
|
||||
* all zero-width and zero-height rectangles are equal to each other since they
|
||||
* represent the empty area. But when a rectangle represents a set of
|
||||
* mathematical points, zero-width and zero-height rectangles can be unequal.
|
||||
* -- The union operation can behave differently. When rectangles represent
|
||||
* areas, taking the union of a zero-width or zero-height rectangle with
|
||||
* another rectangle can just ignore the empty rectangle. But when rectangles
|
||||
* represent sets of mathematical points, we may need to extend the latter
|
||||
* rectangle to include the points of a zero-width or zero-height rectangle.
|
||||
*
|
||||
* To ensure that these interpretations are explicitly disambiguated, we
|
||||
* deny access to the == and != operators and require use of IsEqualEdges and
|
||||
* IsEqualInterior instead. Similarly we provide separate Union and UnionEdges
|
||||
* methods.
|
||||
*
|
||||
* Do not use this class directly. Subclass it, pass that subclass as the
|
||||
* Sub parameter, and only use that subclass.
|
||||
*/
|
||||
template <class T, class Sub, class Point, class SizeT, class Margin>
|
||||
struct BaseRect {
|
||||
T x, y, width, height;
|
||||
|
||||
// Constructors
|
||||
BaseRect() : x(0), y(0), width(0), height(0) {}
|
||||
BaseRect(const Point& aOrigin, const SizeT &aSize) :
|
||||
x(aOrigin.x), y(aOrigin.y), width(aSize.width), height(aSize.height)
|
||||
{
|
||||
}
|
||||
BaseRect(T aX, T aY, T aWidth, T aHeight) :
|
||||
x(aX), y(aY), width(aWidth), height(aHeight)
|
||||
{
|
||||
}
|
||||
|
||||
// Emptiness. An empty rect is one that has no area, i.e. its height or width
|
||||
// is <= 0
|
||||
bool IsEmpty() const { return height <= 0 || width <= 0; }
|
||||
void SetEmpty() { width = height = 0; }
|
||||
|
||||
// Returns true if this rectangle contains the interior of aRect. Always
|
||||
// returns true if aRect is empty, and always returns false is aRect is
|
||||
// nonempty but this rect is empty.
|
||||
bool Contains(const Sub& aRect) const
|
||||
{
|
||||
return aRect.IsEmpty() ||
|
||||
(x <= aRect.x && aRect.XMost() <= XMost() &&
|
||||
y <= aRect.y && aRect.YMost() <= YMost());
|
||||
}
|
||||
// Returns true if this rectangle contains the rectangle (aX,aY,1,1).
|
||||
bool Contains(T aX, T aY) const
|
||||
{
|
||||
return x <= aX && aX + 1 <= XMost() &&
|
||||
y <= aY && aY + 1 <= YMost();
|
||||
}
|
||||
// Returns true if this rectangle contains the rectangle (aPoint.x,aPoint.y,1,1).
|
||||
bool Contains(const Point& aPoint) const { return Contains(aPoint.x, aPoint.y); }
|
||||
|
||||
// Intersection. Returns TRUE if the receiver's area has non-empty
|
||||
// intersection with aRect's area, and FALSE otherwise.
|
||||
// Always returns false if aRect is empty or 'this' is empty.
|
||||
bool Intersects(const Sub& aRect) const
|
||||
{
|
||||
return x < aRect.XMost() && aRect.x < XMost() &&
|
||||
y < aRect.YMost() && aRect.y < YMost();
|
||||
}
|
||||
// Returns the rectangle containing the intersection of the points
|
||||
// (including edges) of *this and aRect. If there are no points in that
|
||||
// intersection, returns an empty rectangle with x/y set to the max of the x/y
|
||||
// of *this and aRect.
|
||||
Sub Intersect(const Sub& aRect) const
|
||||
{
|
||||
Sub result;
|
||||
result.x = NS_MAX(x, aRect.x);
|
||||
result.y = NS_MAX(y, aRect.y);
|
||||
result.width = NS_MIN(XMost(), aRect.XMost()) - result.x;
|
||||
result.height = NS_MIN(YMost(), aRect.YMost()) - result.y;
|
||||
if (result.width < 0 || result.height < 0) {
|
||||
result.SizeTo(0, 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Sets *this to be the rectangle containing the intersection of the points
|
||||
// (including edges) of *this and aRect. If there are no points in that
|
||||
// intersection, sets *this to be an empty rectangle with x/y set to the max
|
||||
// of the x/y of *this and aRect.
|
||||
//
|
||||
// 'this' can be the same object as either aRect1 or aRect2
|
||||
bool IntersectRect(const Sub& aRect1, const Sub& aRect2)
|
||||
{
|
||||
*static_cast<Sub*>(this) = aRect1.Intersect(aRect2);
|
||||
return !IsEmpty();
|
||||
}
|
||||
|
||||
// Returns the smallest rectangle that contains both the area of both
|
||||
// this and aRect2.
|
||||
// Thus, empty input rectangles are ignored.
|
||||
// If both rectangles are empty, returns this.
|
||||
Sub Union(const Sub& aRect) const
|
||||
{
|
||||
if (IsEmpty()) {
|
||||
return aRect;
|
||||
} else if (aRect.IsEmpty()) {
|
||||
return *static_cast<const Sub*>(this);
|
||||
} else {
|
||||
return UnionEdges(aRect);
|
||||
}
|
||||
}
|
||||
// Returns the smallest rectangle that contains both the points (including
|
||||
// edges) of both aRect1 and aRect2.
|
||||
// Thus, empty input rectangles are allowed to affect the result.
|
||||
Sub UnionEdges(const Sub& aRect) const
|
||||
{
|
||||
Sub result;
|
||||
result.x = NS_MIN(x, aRect.x);
|
||||
result.y = NS_MIN(y, aRect.y);
|
||||
result.width = NS_MAX(XMost(), aRect.XMost()) - result.x;
|
||||
result.height = NS_MAX(YMost(), aRect.YMost()) - result.y;
|
||||
return result;
|
||||
}
|
||||
// Computes the smallest rectangle that contains both the area of both
|
||||
// aRect1 and aRect2, and fills 'this' with the result.
|
||||
// Thus, empty input rectangles are ignored.
|
||||
// If both rectangles are empty, sets 'this' to aRect2.
|
||||
//
|
||||
// 'this' can be the same object as either aRect1 or aRect2
|
||||
void UnionRect(const Sub& aRect1, const Sub& aRect2)
|
||||
{
|
||||
*static_cast<Sub*>(this) = aRect1.Union(aRect2);
|
||||
}
|
||||
|
||||
// Computes the smallest rectangle that contains both the points (including
|
||||
// edges) of both aRect1 and aRect2.
|
||||
// Thus, empty input rectangles are allowed to affect the result.
|
||||
//
|
||||
// 'this' can be the same object as either aRect1 or aRect2
|
||||
void UnionRectEdges(const Sub& aRect1, const Sub& aRect2)
|
||||
{
|
||||
*static_cast<Sub*>(this) = aRect1.UnionEdges(aRect2);
|
||||
}
|
||||
|
||||
void SetRect(T aX, T aY, T aWidth, T aHeight)
|
||||
{
|
||||
x = aX; y = aY; width = aWidth; height = aHeight;
|
||||
}
|
||||
void SetRect(const Point& aPt, const SizeT& aSize)
|
||||
{
|
||||
SetRect(aPt.x, aPt.y, aSize.width, aSize.height);
|
||||
}
|
||||
void MoveTo(T aX, T aY) { x = aX; y = aY; }
|
||||
void MoveTo(const Point& aPoint) { x = aPoint.x; y = aPoint.y; }
|
||||
void MoveBy(T aDx, T aDy) { x += aDx; y += aDy; }
|
||||
void MoveBy(const Point& aPoint) { x += aPoint.x; y += aPoint.y; }
|
||||
void SizeTo(T aWidth, T aHeight) { width = aWidth; height = aHeight; }
|
||||
void SizeTo(const SizeT& aSize) { width = aSize.width; height = aSize.height; }
|
||||
|
||||
void Inflate(T aD) { Inflate(aD, aD); }
|
||||
void Inflate(T aDx, T aDy)
|
||||
{
|
||||
x -= aDx;
|
||||
y -= aDy;
|
||||
width += 2 * aDx;
|
||||
height += 2 * aDy;
|
||||
}
|
||||
void Inflate(const Margin& aMargin)
|
||||
{
|
||||
x -= aMargin.left;
|
||||
y -= aMargin.top;
|
||||
width += aMargin.LeftRight();
|
||||
height += aMargin.TopBottom();
|
||||
}
|
||||
void Inflate(const SizeT& aSize) { Inflate(aSize.width, aSize.height); }
|
||||
|
||||
void Deflate(T aD) { Deflate(aD, aD); }
|
||||
void Deflate(T aDx, T aDy)
|
||||
{
|
||||
x += aDx;
|
||||
y += aDy;
|
||||
width = NS_MAX(T(0), width - 2 * aDx);
|
||||
height = NS_MAX(T(0), height - 2 * aDy);
|
||||
}
|
||||
void Deflate(const Margin& aMargin)
|
||||
{
|
||||
x += aMargin.left;
|
||||
y += aMargin.top;
|
||||
width = NS_MAX(T(0), width - aMargin.LeftRight());
|
||||
height = NS_MAX(T(0), height - aMargin.TopBottom());
|
||||
}
|
||||
void Deflate(const SizeT& aSize) { Deflate(aSize.width, aSize.height); }
|
||||
|
||||
// Return true if the rectangles contain the same set of points, including
|
||||
// points on the edges.
|
||||
// Use when we care about the exact x/y/width/height values being
|
||||
// equal (i.e. we care about differences in empty rectangles).
|
||||
bool IsEqualEdges(const Sub& aRect) const
|
||||
{
|
||||
return x == aRect.x && y == aRect.y &&
|
||||
width == aRect.width && height == aRect.height;
|
||||
}
|
||||
// Return true if the rectangles contain the same area of the plane.
|
||||
// Use when we do not care about differences in empty rectangles.
|
||||
bool IsEqualInterior(const Sub& aRect) const
|
||||
{
|
||||
return IsEqualEdges(aRect) || (IsEmpty() && aRect.IsEmpty());
|
||||
}
|
||||
|
||||
Sub operator+(const Point& aPoint) const
|
||||
{
|
||||
return Sub(x + aPoint.x, y + aPoint.y, width, height);
|
||||
}
|
||||
Sub operator-(const Point& aPoint) const
|
||||
{
|
||||
return Sub(x - aPoint.x, y - aPoint.y, width, height);
|
||||
}
|
||||
Sub& operator+=(const Point& aPoint)
|
||||
{
|
||||
MoveBy(aPoint);
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
Sub& operator-=(const Point& aPoint)
|
||||
{
|
||||
MoveBy(-aPoint);
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
|
||||
// Find difference as a Margin
|
||||
Margin operator-(const Sub& aRect) const
|
||||
{
|
||||
return Margin(aRect.x - x, aRect.y - y,
|
||||
XMost() - aRect.XMost(), YMost() - aRect.YMost());
|
||||
}
|
||||
|
||||
// Helpers for accessing the vertices
|
||||
Point TopLeft() const { return Point(x, y); }
|
||||
Point TopRight() const { return Point(XMost(), y); }
|
||||
Point BottomLeft() const { return Point(x, YMost()); }
|
||||
Point BottomRight() const { return Point(XMost(), YMost()); }
|
||||
Point Center() const { return Point(x, y) + Point(width, height)/2; }
|
||||
SizeT Size() const { return SizeT(width, height); }
|
||||
|
||||
// Helper methods for computing the extents
|
||||
T X() const { return x; }
|
||||
T Y() const { return y; }
|
||||
T Width() const { return width; }
|
||||
T Height() const { return height; }
|
||||
T XMost() const { return x + width; }
|
||||
T YMost() const { return y + height; }
|
||||
|
||||
// Scale 'this' by aScale, converting coordinates to integers so that the result is
|
||||
// the smallest integer-coordinate rectangle containing the unrounded result.
|
||||
void ScaleRoundOut(double aScale) { ScaleRoundOut(aScale, aScale); }
|
||||
void ScaleRoundOut(double aXScale, double aYScale)
|
||||
{
|
||||
T right = static_cast<T>(NS_ceil(double(XMost()) * aXScale));
|
||||
T bottom = static_cast<T>(NS_ceil(double(YMost()) * aYScale));
|
||||
x = static_cast<T>(NS_floor(double(x) * aXScale));
|
||||
y = static_cast<T>(NS_floor(double(y) * aYScale));
|
||||
width = right - x;
|
||||
height = bottom - y;
|
||||
}
|
||||
|
||||
private:
|
||||
// Do not use the default operator== or operator!= !
|
||||
// Use IsEqualEdges or IsEqualInterior explicitly.
|
||||
bool operator==(const Sub& aRect) const { return false; }
|
||||
bool operator!=(const Sub& aRect) const { return false; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_BASERECT_H_ */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert O'Callahan <robert@ocallahan.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_BASERECT_H_
|
||||
#define MOZILLA_BASERECT_H_
|
||||
|
||||
#include "nsAlgorithm.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Rectangles have two interpretations: a set of (zero-size) points,
|
||||
* and a rectangular area of the plane. Most rectangle operations behave
|
||||
* the same no matter what interpretation is being used, but some operations
|
||||
* differ:
|
||||
* -- Equality tests behave differently. When a rectangle represents an area,
|
||||
* all zero-width and zero-height rectangles are equal to each other since they
|
||||
* represent the empty area. But when a rectangle represents a set of
|
||||
* mathematical points, zero-width and zero-height rectangles can be unequal.
|
||||
* -- The union operation can behave differently. When rectangles represent
|
||||
* areas, taking the union of a zero-width or zero-height rectangle with
|
||||
* another rectangle can just ignore the empty rectangle. But when rectangles
|
||||
* represent sets of mathematical points, we may need to extend the latter
|
||||
* rectangle to include the points of a zero-width or zero-height rectangle.
|
||||
*
|
||||
* To ensure that these interpretations are explicitly disambiguated, we
|
||||
* deny access to the == and != operators and require use of IsEqualEdges and
|
||||
* IsEqualInterior instead. Similarly we provide separate Union and UnionEdges
|
||||
* methods.
|
||||
*
|
||||
* Do not use this class directly. Subclass it, pass that subclass as the
|
||||
* Sub parameter, and only use that subclass.
|
||||
*/
|
||||
template <class T, class Sub, class Point, class SizeT, class Margin>
|
||||
struct BaseRect {
|
||||
T x, y, width, height;
|
||||
|
||||
// Constructors
|
||||
BaseRect() : x(0), y(0), width(0), height(0) {}
|
||||
BaseRect(const Point& aOrigin, const SizeT &aSize) :
|
||||
x(aOrigin.x), y(aOrigin.y), width(aSize.width), height(aSize.height)
|
||||
{
|
||||
}
|
||||
BaseRect(T aX, T aY, T aWidth, T aHeight) :
|
||||
x(aX), y(aY), width(aWidth), height(aHeight)
|
||||
{
|
||||
}
|
||||
|
||||
// Emptiness. An empty rect is one that has no area, i.e. its height or width
|
||||
// is <= 0
|
||||
bool IsEmpty() const { return height <= 0 || width <= 0; }
|
||||
void SetEmpty() { width = height = 0; }
|
||||
|
||||
// Returns true if this rectangle contains the interior of aRect. Always
|
||||
// returns true if aRect is empty, and always returns false is aRect is
|
||||
// nonempty but this rect is empty.
|
||||
bool Contains(const Sub& aRect) const
|
||||
{
|
||||
return aRect.IsEmpty() ||
|
||||
(x <= aRect.x && aRect.XMost() <= XMost() &&
|
||||
y <= aRect.y && aRect.YMost() <= YMost());
|
||||
}
|
||||
// Returns true if this rectangle contains the rectangle (aX,aY,1,1).
|
||||
bool Contains(T aX, T aY) const
|
||||
{
|
||||
return x <= aX && aX + 1 <= XMost() &&
|
||||
y <= aY && aY + 1 <= YMost();
|
||||
}
|
||||
// Returns true if this rectangle contains the rectangle (aPoint.x,aPoint.y,1,1).
|
||||
bool Contains(const Point& aPoint) const { return Contains(aPoint.x, aPoint.y); }
|
||||
|
||||
// Intersection. Returns TRUE if the receiver's area has non-empty
|
||||
// intersection with aRect's area, and FALSE otherwise.
|
||||
// Always returns false if aRect is empty or 'this' is empty.
|
||||
bool Intersects(const Sub& aRect) const
|
||||
{
|
||||
return x < aRect.XMost() && aRect.x < XMost() &&
|
||||
y < aRect.YMost() && aRect.y < YMost();
|
||||
}
|
||||
// Returns the rectangle containing the intersection of the points
|
||||
// (including edges) of *this and aRect. If there are no points in that
|
||||
// intersection, returns an empty rectangle with x/y set to the max of the x/y
|
||||
// of *this and aRect.
|
||||
Sub Intersect(const Sub& aRect) const
|
||||
{
|
||||
Sub result;
|
||||
result.x = NS_MAX(x, aRect.x);
|
||||
result.y = NS_MAX(y, aRect.y);
|
||||
result.width = NS_MIN(XMost(), aRect.XMost()) - result.x;
|
||||
result.height = NS_MIN(YMost(), aRect.YMost()) - result.y;
|
||||
if (result.width < 0 || result.height < 0) {
|
||||
result.SizeTo(0, 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Sets *this to be the rectangle containing the intersection of the points
|
||||
// (including edges) of *this and aRect. If there are no points in that
|
||||
// intersection, sets *this to be an empty rectangle with x/y set to the max
|
||||
// of the x/y of *this and aRect.
|
||||
//
|
||||
// 'this' can be the same object as either aRect1 or aRect2
|
||||
bool IntersectRect(const Sub& aRect1, const Sub& aRect2)
|
||||
{
|
||||
*static_cast<Sub*>(this) = aRect1.Intersect(aRect2);
|
||||
return !IsEmpty();
|
||||
}
|
||||
|
||||
// Returns the smallest rectangle that contains both the area of both
|
||||
// this and aRect2.
|
||||
// Thus, empty input rectangles are ignored.
|
||||
// If both rectangles are empty, returns this.
|
||||
Sub Union(const Sub& aRect) const
|
||||
{
|
||||
if (IsEmpty()) {
|
||||
return aRect;
|
||||
} else if (aRect.IsEmpty()) {
|
||||
return *static_cast<const Sub*>(this);
|
||||
} else {
|
||||
return UnionEdges(aRect);
|
||||
}
|
||||
}
|
||||
// Returns the smallest rectangle that contains both the points (including
|
||||
// edges) of both aRect1 and aRect2.
|
||||
// Thus, empty input rectangles are allowed to affect the result.
|
||||
Sub UnionEdges(const Sub& aRect) const
|
||||
{
|
||||
Sub result;
|
||||
result.x = NS_MIN(x, aRect.x);
|
||||
result.y = NS_MIN(y, aRect.y);
|
||||
result.width = NS_MAX(XMost(), aRect.XMost()) - result.x;
|
||||
result.height = NS_MAX(YMost(), aRect.YMost()) - result.y;
|
||||
return result;
|
||||
}
|
||||
// Computes the smallest rectangle that contains both the area of both
|
||||
// aRect1 and aRect2, and fills 'this' with the result.
|
||||
// Thus, empty input rectangles are ignored.
|
||||
// If both rectangles are empty, sets 'this' to aRect2.
|
||||
//
|
||||
// 'this' can be the same object as either aRect1 or aRect2
|
||||
void UnionRect(const Sub& aRect1, const Sub& aRect2)
|
||||
{
|
||||
*static_cast<Sub*>(this) = aRect1.Union(aRect2);
|
||||
}
|
||||
|
||||
// Computes the smallest rectangle that contains both the points (including
|
||||
// edges) of both aRect1 and aRect2.
|
||||
// Thus, empty input rectangles are allowed to affect the result.
|
||||
//
|
||||
// 'this' can be the same object as either aRect1 or aRect2
|
||||
void UnionRectEdges(const Sub& aRect1, const Sub& aRect2)
|
||||
{
|
||||
*static_cast<Sub*>(this) = aRect1.UnionEdges(aRect2);
|
||||
}
|
||||
|
||||
void SetRect(T aX, T aY, T aWidth, T aHeight)
|
||||
{
|
||||
x = aX; y = aY; width = aWidth; height = aHeight;
|
||||
}
|
||||
void SetRect(const Point& aPt, const SizeT& aSize)
|
||||
{
|
||||
SetRect(aPt.x, aPt.y, aSize.width, aSize.height);
|
||||
}
|
||||
void MoveTo(T aX, T aY) { x = aX; y = aY; }
|
||||
void MoveTo(const Point& aPoint) { x = aPoint.x; y = aPoint.y; }
|
||||
void MoveBy(T aDx, T aDy) { x += aDx; y += aDy; }
|
||||
void MoveBy(const Point& aPoint) { x += aPoint.x; y += aPoint.y; }
|
||||
void SizeTo(T aWidth, T aHeight) { width = aWidth; height = aHeight; }
|
||||
void SizeTo(const SizeT& aSize) { width = aSize.width; height = aSize.height; }
|
||||
|
||||
void Inflate(T aD) { Inflate(aD, aD); }
|
||||
void Inflate(T aDx, T aDy)
|
||||
{
|
||||
x -= aDx;
|
||||
y -= aDy;
|
||||
width += 2 * aDx;
|
||||
height += 2 * aDy;
|
||||
}
|
||||
void Inflate(const Margin& aMargin)
|
||||
{
|
||||
x -= aMargin.left;
|
||||
y -= aMargin.top;
|
||||
width += aMargin.LeftRight();
|
||||
height += aMargin.TopBottom();
|
||||
}
|
||||
void Inflate(const SizeT& aSize) { Inflate(aSize.width, aSize.height); }
|
||||
|
||||
void Deflate(T aD) { Deflate(aD, aD); }
|
||||
void Deflate(T aDx, T aDy)
|
||||
{
|
||||
x += aDx;
|
||||
y += aDy;
|
||||
width = NS_MAX(T(0), width - 2 * aDx);
|
||||
height = NS_MAX(T(0), height - 2 * aDy);
|
||||
}
|
||||
void Deflate(const Margin& aMargin)
|
||||
{
|
||||
x += aMargin.left;
|
||||
y += aMargin.top;
|
||||
width = NS_MAX(T(0), width - aMargin.LeftRight());
|
||||
height = NS_MAX(T(0), height - aMargin.TopBottom());
|
||||
}
|
||||
void Deflate(const SizeT& aSize) { Deflate(aSize.width, aSize.height); }
|
||||
|
||||
// Return true if the rectangles contain the same set of points, including
|
||||
// points on the edges.
|
||||
// Use when we care about the exact x/y/width/height values being
|
||||
// equal (i.e. we care about differences in empty rectangles).
|
||||
bool IsEqualEdges(const Sub& aRect) const
|
||||
{
|
||||
return x == aRect.x && y == aRect.y &&
|
||||
width == aRect.width && height == aRect.height;
|
||||
}
|
||||
// Return true if the rectangles contain the same area of the plane.
|
||||
// Use when we do not care about differences in empty rectangles.
|
||||
bool IsEqualInterior(const Sub& aRect) const
|
||||
{
|
||||
return IsEqualEdges(aRect) || (IsEmpty() && aRect.IsEmpty());
|
||||
}
|
||||
|
||||
Sub operator+(const Point& aPoint) const
|
||||
{
|
||||
return Sub(x + aPoint.x, y + aPoint.y, width, height);
|
||||
}
|
||||
Sub operator-(const Point& aPoint) const
|
||||
{
|
||||
return Sub(x - aPoint.x, y - aPoint.y, width, height);
|
||||
}
|
||||
Sub& operator+=(const Point& aPoint)
|
||||
{
|
||||
MoveBy(aPoint);
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
Sub& operator-=(const Point& aPoint)
|
||||
{
|
||||
MoveBy(-aPoint);
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
|
||||
// Find difference as a Margin
|
||||
Margin operator-(const Sub& aRect) const
|
||||
{
|
||||
return Margin(aRect.x - x, aRect.y - y,
|
||||
XMost() - aRect.XMost(), YMost() - aRect.YMost());
|
||||
}
|
||||
|
||||
// Helpers for accessing the vertices
|
||||
Point TopLeft() const { return Point(x, y); }
|
||||
Point TopRight() const { return Point(XMost(), y); }
|
||||
Point BottomLeft() const { return Point(x, YMost()); }
|
||||
Point BottomRight() const { return Point(XMost(), YMost()); }
|
||||
Point Center() const { return Point(x, y) + Point(width, height)/2; }
|
||||
SizeT Size() const { return SizeT(width, height); }
|
||||
|
||||
// Helper methods for computing the extents
|
||||
T X() const { return x; }
|
||||
T Y() const { return y; }
|
||||
T Width() const { return width; }
|
||||
T Height() const { return height; }
|
||||
T XMost() const { return x + width; }
|
||||
T YMost() const { return y + height; }
|
||||
|
||||
// Scale 'this' by aScale, converting coordinates to integers so that the result is
|
||||
// the smallest integer-coordinate rectangle containing the unrounded result.
|
||||
void ScaleRoundOut(double aScale) { ScaleRoundOut(aScale, aScale); }
|
||||
void ScaleRoundOut(double aXScale, double aYScale)
|
||||
{
|
||||
T right = static_cast<T>(NS_ceil(double(XMost()) * aXScale));
|
||||
T bottom = static_cast<T>(NS_ceil(double(YMost()) * aYScale));
|
||||
x = static_cast<T>(NS_floor(double(x) * aXScale));
|
||||
y = static_cast<T>(NS_floor(double(y) * aYScale));
|
||||
width = right - x;
|
||||
height = bottom - y;
|
||||
}
|
||||
|
||||
private:
|
||||
// Do not use the default operator== or operator!= !
|
||||
// Use IsEqualEdges or IsEqualInterior explicitly.
|
||||
bool operator==(const Sub& aRect) const { return false; }
|
||||
bool operator!=(const Sub& aRect) const { return false; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_BASERECT_H_ */
|
||||
|
|
|
@ -1,101 +1,101 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert O'Callahan <robert@ocallahan.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_BASESIZE_H_
|
||||
#define MOZILLA_BASESIZE_H_
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Do not use this class directly. Subclass it, pass that subclass as the
|
||||
* Sub parameter, and only use that subclass. This allows methods to safely
|
||||
* cast 'this' to 'Sub*'.
|
||||
*/
|
||||
template <class T, class Sub>
|
||||
struct BaseSize {
|
||||
T width, height;
|
||||
|
||||
// Constructors
|
||||
BaseSize() : width(0), height(0) {}
|
||||
BaseSize(T aWidth, T aHeight) : width(aWidth), height(aHeight) {}
|
||||
|
||||
void SizeTo(T aWidth, T aHeight) { width = aWidth; height = aHeight; }
|
||||
|
||||
// Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
|
||||
bool operator==(const Sub& aSize) const {
|
||||
return width == aSize.width && height == aSize.height;
|
||||
}
|
||||
bool operator!=(const Sub& aSize) const {
|
||||
return width != aSize.width || height != aSize.height;
|
||||
}
|
||||
bool operator<=(const Sub& aSize) const {
|
||||
return width <= aSize.width && height <= aSize.height;
|
||||
}
|
||||
bool operator<(const Sub& aSize) const {
|
||||
return *this <= aSize && *this != aSize;
|
||||
}
|
||||
|
||||
Sub operator+(const Sub& aSize) const {
|
||||
return Sub(width + aSize.width, height + aSize.height);
|
||||
}
|
||||
Sub operator-(const Sub& aSize) const {
|
||||
return Sub(width - aSize.width, height - aSize.height);
|
||||
}
|
||||
Sub& operator+=(const Sub& aSize) {
|
||||
width += aSize.width;
|
||||
height += aSize.height;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
Sub& operator-=(const Sub& aSize) {
|
||||
width -= aSize.width;
|
||||
height -= aSize.height;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
|
||||
Sub operator*(T aScale) const {
|
||||
return Sub(width * aScale, height * aScale);
|
||||
}
|
||||
Sub operator/(T aScale) const {
|
||||
return Sub(width / aScale, height / aScale);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_BASESIZE_H_ */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert O'Callahan <robert@ocallahan.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_BASESIZE_H_
|
||||
#define MOZILLA_BASESIZE_H_
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Do not use this class directly. Subclass it, pass that subclass as the
|
||||
* Sub parameter, and only use that subclass. This allows methods to safely
|
||||
* cast 'this' to 'Sub*'.
|
||||
*/
|
||||
template <class T, class Sub>
|
||||
struct BaseSize {
|
||||
T width, height;
|
||||
|
||||
// Constructors
|
||||
BaseSize() : width(0), height(0) {}
|
||||
BaseSize(T aWidth, T aHeight) : width(aWidth), height(aHeight) {}
|
||||
|
||||
void SizeTo(T aWidth, T aHeight) { width = aWidth; height = aHeight; }
|
||||
|
||||
// Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
|
||||
bool operator==(const Sub& aSize) const {
|
||||
return width == aSize.width && height == aSize.height;
|
||||
}
|
||||
bool operator!=(const Sub& aSize) const {
|
||||
return width != aSize.width || height != aSize.height;
|
||||
}
|
||||
bool operator<=(const Sub& aSize) const {
|
||||
return width <= aSize.width && height <= aSize.height;
|
||||
}
|
||||
bool operator<(const Sub& aSize) const {
|
||||
return *this <= aSize && *this != aSize;
|
||||
}
|
||||
|
||||
Sub operator+(const Sub& aSize) const {
|
||||
return Sub(width + aSize.width, height + aSize.height);
|
||||
}
|
||||
Sub operator-(const Sub& aSize) const {
|
||||
return Sub(width - aSize.width, height - aSize.height);
|
||||
}
|
||||
Sub& operator+=(const Sub& aSize) {
|
||||
width += aSize.width;
|
||||
height += aSize.height;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
Sub& operator-=(const Sub& aSize) {
|
||||
width -= aSize.width;
|
||||
height -= aSize.height;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
|
||||
Sub operator*(T aScale) const {
|
||||
return Sub(width * aScale, height * aScale);
|
||||
}
|
||||
Sub operator/(T aScale) const {
|
||||
return Sub(width / aScale, height / aScale);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_BASESIZE_H_ */
|
||||
|
|
|
@ -118,7 +118,7 @@ struct NS_GFX nsIntRect :
|
|||
}
|
||||
|
||||
inline nsRect ToAppUnits(nscoord aAppUnitsPerPixel) const;
|
||||
|
||||
|
||||
// Returns a special nsIntRect that's used in some places to signify
|
||||
// "all available space".
|
||||
static const nsIntRect& GetMaxSizedIntRect() { return kMaxSizedIntRect; }
|
||||
|
|
|
@ -1308,22 +1308,22 @@ nsRegion& nsRegion::ExtendForScaling (float aXMult, float aYMult)
|
|||
*this = region;
|
||||
return *this;
|
||||
}
|
||||
|
||||
nsRegion& nsRegion::ScaleRoundOut (float aXScale, float aYScale)
|
||||
{
|
||||
nsRegion region;
|
||||
nsRegionRectIterator iter(*this);
|
||||
for (;;) {
|
||||
const nsRect* r = iter.Next();
|
||||
if (!r)
|
||||
break;
|
||||
nsRect rect = *r;
|
||||
rect.ScaleRoundOut(aXScale, aYScale);
|
||||
region.Or(region, rect);
|
||||
}
|
||||
*this = region;
|
||||
return *this;
|
||||
}
|
||||
|
||||
nsRegion& nsRegion::ScaleRoundOut (float aXScale, float aYScale)
|
||||
{
|
||||
nsRegion region;
|
||||
nsRegionRectIterator iter(*this);
|
||||
for (;;) {
|
||||
const nsRect* r = iter.Next();
|
||||
if (!r)
|
||||
break;
|
||||
nsRect rect = *r;
|
||||
rect.ScaleRoundOut(aXScale, aYScale);
|
||||
region.Or(region, rect);
|
||||
}
|
||||
*this = region;
|
||||
return *this;
|
||||
}
|
||||
|
||||
nsRegion nsRegion::ConvertAppUnitsRoundOut (PRInt32 aFromAPP, PRInt32 aToAPP) const
|
||||
{
|
||||
|
|
|
@ -441,12 +441,12 @@ public:
|
|||
{
|
||||
return FromRect (mImpl.GetLargestRectangle( ToRect(aContainingRect) ));
|
||||
}
|
||||
|
||||
nsIntRegion& ScaleRoundOut (float aXScale, float aYScale)
|
||||
{
|
||||
mImpl.ScaleRoundOut(aXScale, aYScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
nsIntRegion& ScaleRoundOut (float aXScale, float aYScale)
|
||||
{
|
||||
mImpl.ScaleRoundOut(aXScale, aYScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
nsIntRegion& ExtendForScaling (float aXMult, float aYMult)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче