no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / layout / painting / BorderCache.h
blobbb6bf7e4edbcb1d511fca6bc678039e6c2a6d602
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"
14 namespace mozilla {
15 // Cache for best overlap and best dashLength.
17 struct FourFloats {
18 typedef mozilla::gfx::Float Float;
20 Float n[4];
22 FourFloats() {
23 n[0] = 0.0f;
24 n[1] = 0.0f;
25 n[2] = 0.0f;
26 n[3] = 0.0f;
29 FourFloats(Float a, Float b, Float c, Float d) {
30 n[0] = a;
31 n[1] = b;
32 n[2] = c;
33 n[3] = 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] &&
38 n[3] == aOther.n[3];
42 class FourFloatsHashKey : public PLDHashEntryHdr {
43 public:
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 };
61 private:
62 const FourFloats mValue;
65 } // namespace mozilla
67 #endif /* mozilla_BorderCache_h_ */