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