Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkKeyedImage.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2017 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
9
11
13 if (!image) {
14 return {{0, 0, 0, 0}, 0};
15 }
16 if (const SkBitmap* bm = as_IB(image)->onPeekBitmap()) {
17 SkIPoint o = bm->pixelRefOrigin();
18 return {image->bounds().makeOffset(o), bm->getGenerationID()};
19 }
20 return {image->bounds(), image->uniqueID()};
21}
22
24 fKey = SkBitmapKeyFromImage(fImage.get());
25}
26
27SkKeyedImage::SkKeyedImage(const SkBitmap& bm) : fImage(bm.asImage()) {
28 if (fImage) {
29 fKey = {bm.getSubset(), bm.getGenerationID()};
30 }
31}
32
34 SkKeyedImage img;
35 if (fImage && subset.intersect(fImage->bounds())) {
36 img.fImage = fImage->makeSubset(nullptr, subset);
37 if (img.fImage) {
38 img.fKey = {subset.makeOffset(fKey.fSubset.topLeft()), fKey.fID};
39 }
40 }
41 return img;
42}
43
45 sk_sp<SkImage> image = std::move(fImage);
46 SkASSERT(nullptr == fImage);
47 fKey = {{0, 0, 0, 0}, 0};
48 return image;
49}
#define SkASSERT(cond)
Definition SkAssert.h:116
static SkImage_Base * as_IB(SkImage *image)
SkBitmapKey SkBitmapKeyFromImage(const SkImage *image)
SkBitmapKey SkBitmapKeyFromImage(const SkImage *)
SkIRect getSubset() const
Definition SkBitmap.h:394
uint32_t getGenerationID() const
Definition SkBitmap.cpp:361
uint32_t uniqueID() const
Definition SkImage.h:311
SkIRect bounds() const
Definition SkImage.h:303
virtual sk_sp< SkImage > makeSubset(GrDirectContext *direct, const SkIRect &subset) const =0
const sk_sp< SkImage > & image() const
SkKeyedImage subset(SkIRect subset) const
sk_sp< SkImage > release()
T * get() const
Definition SkRefCnt.h:303
sk_sp< SkImage > image
Definition examples.cpp:29
Definition ref_ptr.h:256
uint32_t fID
Definition SkBitmapKey.h:14
SkIRect fSubset
Definition SkBitmapKey.h:13
constexpr SkIRect makeOffset(int32_t dx, int32_t dy) const
Definition SkRect.h:300
constexpr SkIPoint topLeft() const
Definition SkRect.h:151