SkYUVPlanesCache.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright 2015 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. #ifndef SkYUVPlanesCache_DEFINED
  8. #define SkYUVPlanesCache_DEFINED
  9. #include "include/core/SkImageInfo.h"
  10. #include "include/core/SkYUVAIndex.h"
  11. #include "include/core/SkYUVASizeInfo.h"
  12. #include "src/core/SkCachedData.h"
  13. class SkResourceCache;
  14. class SkYUVPlanesCache {
  15. public:
  16. /**
  17. * The Info struct contains data about the 4 Y, U, V, and A planes of memory stored
  18. * contiguously, in that order, as a single block of memory within SkYUVPlanesCache.
  19. *
  20. * fSizeInfo: fWidth, fHeight, and fWidthBytes of each of the Y, U, V, and A planes.
  21. * fColorSpace: color space that will be used for the YUV -> RGB conversion.
  22. */
  23. struct Info {
  24. SkYUVASizeInfo fSizeInfo;
  25. SkYUVAIndex fYUVAIndices[SkYUVAIndex::kIndexCount];
  26. SkYUVColorSpace fColorSpace;
  27. };
  28. /**
  29. * On success, return a ref to the SkCachedData that holds the pixels.
  30. *
  31. * On failure, return nullptr.
  32. */
  33. static SkCachedData* FindAndRef(uint32_t genID, Info* info,
  34. SkResourceCache* localCache = nullptr);
  35. /**
  36. * Add a pixelRef ID and its YUV planes data to the cache.
  37. */
  38. static void Add(uint32_t genID, SkCachedData* data, Info* info,
  39. SkResourceCache* localCache = nullptr);
  40. };
  41. #endif