/src/skia/src/core/SkMipmapBuilder.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2023 Google LLC |
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 | | #include "src/core/SkMipmapBuilder.h" |
8 | | |
9 | | #include "include/core/SkImage.h" |
10 | | #include "include/core/SkPixmap.h" |
11 | | #include "include/core/SkTypes.h" |
12 | | #include "src/core/SkMipmap.h" |
13 | | struct SkImageInfo; |
14 | | |
15 | 12.6k | SkMipmapBuilder::SkMipmapBuilder(const SkImageInfo& info) { |
16 | 12.6k | fMM = sk_sp<SkMipmap>(SkMipmap::Build({info, nullptr, 0}, |
17 | 12.6k | /* factoryProc= */ nullptr, |
18 | 12.6k | /* computeContents= */ false)); |
19 | 12.6k | } |
20 | | |
21 | 12.6k | SkMipmapBuilder::~SkMipmapBuilder() {} |
22 | | |
23 | 12.6k | int SkMipmapBuilder::countLevels() const { |
24 | 12.6k | return fMM ? fMM->countLevels() : 0; |
25 | 12.6k | } |
26 | | |
27 | 4.67k | SkPixmap SkMipmapBuilder::level(int index) const { |
28 | 4.67k | SkPixmap pm; |
29 | | |
30 | 4.67k | SkMipmap::Level level; |
31 | 4.67k | if (fMM && fMM->getLevel(index, &level)) { |
32 | 4.67k | pm = level.fPixmap; |
33 | 4.67k | } |
34 | 4.67k | return pm; |
35 | 4.67k | } |
36 | | |
37 | 1.70k | sk_sp<SkImage> SkMipmapBuilder::attachTo(const sk_sp<const SkImage>& src) { |
38 | 1.70k | return src->withMipmaps(fMM); |
39 | 1.70k | } |