blob: 792e802b1577fb5819c32c0b1c678c8bf4acad7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkKeyedImage_DEFINED
#define SkKeyedImage_DEFINED
#include "SkBitmap.h"
#include "SkBitmapKey.h"
#include "SkImage.h"
/**
This class has all the advantages of SkBitmaps and SkImages.
The SkImage holds on to encoded data. The SkBitmapKey properly de-dups subsets.
*/
class SkKeyedImage {
public:
SkKeyedImage() {}
SkKeyedImage(sk_sp<SkImage>);
SkKeyedImage(const SkBitmap&);
SkKeyedImage(SkKeyedImage&&) = default;
SkKeyedImage(const SkKeyedImage&) = default;
SkKeyedImage& operator=(SkKeyedImage&&) = default;
SkKeyedImage& operator=(const SkKeyedImage&) = default;
explicit operator bool() const { return fImage != nullptr; }
const SkBitmapKey& key() const { return fKey; }
const sk_sp<SkImage>& image() const { return fImage; }
sk_sp<SkImage> release();
SkKeyedImage subset(SkIRect subset) const;
private:
sk_sp<SkImage> fImage;
SkBitmapKey fKey = {{0, 0, 0, 0}, 0};
};
/**
* Given an Image, return the Bitmap Key that corresponds to it. If the Image
* wraps a Bitmap, use that Bitmap's key.
*/
SkBitmapKey SkBitmapKeyFromImage(const SkImage*);
#endif // SkKeyedImage_DEFINED
|