Flutter Engine
The Flutter Engine
SkBitmapCache.h
Go to the documentation of this file.
1/*
2 * Copyright 2014 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 SkBitmapCache_DEFINED
9#define SkBitmapCache_DEFINED
10
11#include "include/core/SkRect.h"
13
14#include <cstdint>
15#include <memory>
16
17class SkBitmap;
18class SkImage;
19class SkImage_Base;
20class SkMipmap;
21class SkPixmap;
22class SkResourceCache;
23struct SkImageInfo;
24
25uint64_t SkMakeResourceCacheSharedIDForBitmap(uint32_t bitmapGenID);
26
27void SkNotifyBitmapGenIDIsStale(uint32_t bitmapGenID);
28
30 uint32_t fImageID; // != 0
31 SkIRect fSubset; // always set to a valid rect (entire or subset)
32
33 void validate() const {
35 SkASSERT(fSubset.fLeft >= 0 && fSubset.fTop >= 0);
36 SkASSERT(fSubset.width() > 0 && fSubset.height() > 0);
37 }
38
39 static SkBitmapCacheDesc Make(const SkImage*);
40 static SkBitmapCacheDesc Make(uint32_t genID, const SkIRect& subset);
41};
42
44public:
45 /**
46 * Search based on the desc. If found, returns true and
47 * result will be set to the matching bitmap with its pixels already locked.
48 */
49 static bool Find(const SkBitmapCacheDesc&, SkBitmap* result);
50
51 class Rec;
52 struct RecDeleter { void operator()(Rec* r) { PrivateDeleteRec(r); } };
53 typedef std::unique_ptr<Rec, RecDeleter> RecPtr;
54
55 static RecPtr Alloc(const SkBitmapCacheDesc&, const SkImageInfo&, SkPixmap*);
56 static void Add(RecPtr, SkBitmap*);
57
58private:
59 static void PrivateDeleteRec(Rec*);
60};
61
63public:
64 static const SkMipmap* FindAndRef(const SkBitmapCacheDesc&,
65 SkResourceCache* localCache = nullptr);
66 static const SkMipmap* AddAndRef(const SkImage_Base*,
67 SkResourceCache* localCache = nullptr);
68};
69
70#endif
#define SkASSERT(cond)
Definition: SkAssert.h:116
uint64_t SkMakeResourceCacheSharedIDForBitmap(uint32_t bitmapGenID)
void SkNotifyBitmapGenIDIsStale(uint32_t bitmapGenID)
std::unique_ptr< Rec, RecDeleter > RecPtr
Definition: SkBitmapCache.h:53
static RecPtr Alloc(const SkBitmapCacheDesc &, const SkImageInfo &, SkPixmap *)
static bool Find(const SkBitmapCacheDesc &, SkBitmap *result)
static void Add(RecPtr, SkBitmap *)
static const SkMipmap * AddAndRef(const SkImage_Base *, SkResourceCache *localCache=nullptr)
static const SkMipmap * FindAndRef(const SkBitmapCacheDesc &, SkResourceCache *localCache=nullptr)
GAsyncResult * result
void validate() const
Definition: SkBitmapCache.h:33
static SkBitmapCacheDesc Make(const SkImage *)
Definition: SkRect.h:32
constexpr int32_t height() const
Definition: SkRect.h:165
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
constexpr int32_t width() const
Definition: SkRect.h:158
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33