diff options
author | 2011-07-02 01:26:37 +0000 | |
---|---|---|
committer | 2011-07-02 01:26:37 +0000 | |
commit | d3a8c94dfdabb333b12da3ff796d1f558cb06fba (patch) | |
tree | 3a6047b0b1446e755b9208e58e42c98c3fbde11b /include/pdf | |
parent | fc899274d96cdc7d4302f48fbcf61e3376288bc0 (diff) |
A bit set class. Will be used for font subsetting.
Committed on behalf of arthurhsu@chromium.org with a few final nits.
Original CL: http://codereview.appspot.com/4627077
Review URL: http://codereview.appspot.com/4657070
git-svn-id: http://skia.googlecode.com/svn/trunk@1788 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/pdf')
-rwxr-xr-x | include/pdf/SkBitSet.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/include/pdf/SkBitSet.h b/include/pdf/SkBitSet.h new file mode 100755 index 0000000000..84d52e547c --- /dev/null +++ b/include/pdf/SkBitSet.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SkBitSet_DEFINED +#define SkBitSet_DEFINED + +#include "SkTypes.h" + +class SkBitSet { +public: + /** NumberOfBits must be greater than zero. + */ + explicit SkBitSet(int numberOfBits); + explicit SkBitSet(const SkBitSet& source); + + const SkBitSet& operator=(const SkBitSet& rhs); + bool operator==(const SkBitSet& rhs); + bool operator!=(const SkBitSet& rhs); + + /** Clear all data. + */ + void clearAll(); + + /** Set the value of the index-th bit. + */ + void setBit(int index, bool value); + + /** Test if bit index is set. + */ + bool isBitSet(int index); + + /** Or bits from source. false is returned if this doesn't have the same + * bit count as source. + */ + bool orBits(SkBitSet& source); + +private: + SkAutoFree fBitData; + // Dword (32-bit) count of the bitset. + size_t fDwordCount; + size_t fBitCount; + + uint32_t* internalGet(int index) { + SkASSERT((size_t)index < fBitCount); + size_t internalIndex = index / 32; + SkASSERT(internalIndex < fDwordCount); + return (uint32_t*)fBitData.get() + internalIndex; + } +}; + + +#endif |