Home | History | Annotate | Download | only in core
      1 /*
      2  * Copyright 2016 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #ifndef SkImageFilterCacheKey_DEFINED
      9 #define SkImageFilterCacheKey_DEFINED
     10 
     11 struct SkImageFilter::Cache::Key {
     12     Key(const uint32_t uniqueID, const SkMatrix& matrix,
     13         const SkIRect& clipBounds, uint32_t srcGenID, const SkIRect& srcSubset)
     14         : fUniqueID(uniqueID)
     15         , fMatrix(matrix)
     16         , fClipBounds(clipBounds)
     17         , fSrcGenID(srcGenID)
     18         , fSrcSubset(srcSubset) {
     19         // Assert that Key is tightly-packed, since it is hashed.
     20         static_assert(sizeof(Key) == sizeof(uint32_t) + sizeof(SkMatrix) + sizeof(SkIRect) +
     21                                      sizeof(uint32_t) + 4 * sizeof(int32_t),
     22                                      "image_filter_key_tight_packing");
     23         fMatrix.getType();  // force initialization of type, so hashes match
     24     }
     25 
     26     uint32_t fUniqueID;
     27     SkMatrix fMatrix;
     28     SkIRect fClipBounds;
     29     uint32_t fSrcGenID;
     30     SkIRect fSrcSubset;
     31 
     32     bool operator==(const Key& other) const {
     33         return fUniqueID == other.fUniqueID &&
     34                fMatrix == other.fMatrix &&
     35                fClipBounds == other.fClipBounds &&
     36                fSrcGenID == other.fSrcGenID &&
     37                fSrcSubset == other.fSrcSubset;
     38     }
     39 };
     40 
     41 #endif
     42 
     43