1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 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/. */
7 #ifndef mozilla_BorderCache_h_
8 #define mozilla_BorderCache_h_
10 #include "mozilla/gfx/2D.h"
11 #include "mozilla/HashFunctions.h"
12 #include "PLDHashTable.h"
15 // Cache for best overlap and best dashLength.
18 typedef mozilla::gfx::Float Float
;
29 FourFloats(Float a
, Float b
, Float c
, Float d
) {
36 bool operator==(const FourFloats
& aOther
) const {
37 return n
[0] == aOther
.n
[0] && n
[1] == aOther
.n
[1] && n
[2] == aOther
.n
[2] &&
42 class FourFloatsHashKey
: public PLDHashEntryHdr
{
44 typedef const FourFloats
& KeyType
;
45 typedef const FourFloats
* KeyTypePointer
;
47 explicit FourFloatsHashKey(KeyTypePointer aKey
) : mValue(*aKey
) {}
48 FourFloatsHashKey(const FourFloatsHashKey
& aToCopy
)
49 : mValue(aToCopy
.mValue
) {}
50 ~FourFloatsHashKey() = default;
52 KeyType
GetKey() const { return mValue
; }
53 bool KeyEquals(KeyTypePointer aKey
) const { return *aKey
== mValue
; }
55 static KeyTypePointer
KeyToPointer(KeyType aKey
) { return &aKey
; }
56 static PLDHashNumber
HashKey(KeyTypePointer aKey
) {
57 return HashBytes(aKey
->n
, sizeof(mozilla::gfx::Float
) * 4);
59 enum { ALLOW_MEMMOVE
= true };
62 const FourFloats mValue
;
65 } // namespace mozilla
67 #endif /* mozilla_BorderCache_h_ */