/* * Copyright 2019 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef GrSamplePatternDictionary_DEFINED #define GrSamplePatternDictionary_DEFINED #include "include/core/SkPoint.h" #include "include/private/SkTArray.h" #include /** * A bidirectional dictionary mapping between sample patterns (i.e., a list of sample locations) and * unique keys. Since we expect that most render targets will draw from the same small pool of * sample patterns, we favor sample pattern keys over actual arrays of points. */ class GrSamplePatternDictionary { public: static constexpr int kInvalidSamplePatternKey = -1; int findOrAssignSamplePatternKey(const SkTArray& sampleLocations); const SkTArray& retrieveSampleLocations(int samplePatternKey) const { return *fSampleLocationsArray[samplePatternKey]; } private: struct LessThan { bool operator()(const SkTArray&, const SkTArray&) const; }; std::map, int, LessThan> fSamplePatternKeyMap; SkTArray*> fSampleLocationsArray; }; #endif