Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkImage_LazyTexture.cpp
Go to the documentation of this file.
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
9
18#include "include/private/gpu/ganesh/GrTextureGenerator.h" // IWYU pragma: keep
22#include "src/gpu/ganesh/SkGr.h"
25
26#include <cstddef>
27#include <memory>
28#include <utility>
29
30enum class GrColorType;
31
33 const SkIRect& subset) const {
34 auto pixels = direct ? SkImages::TextureFromImage(direct, this) :
35 this->makeRasterImage(nullptr);
36 return pixels ? pixels->makeSubset(direct, subset) : nullptr;
37}
38
40 if (!ctx) {
41 return false;
42 }
44 ctx, this, GrImageTexGenPolicy::kDraw, skgpu::Mipmapped::kNo);
45
46 if (!view) {
47 return false;
48 }
49
51 this->colorType());
52 GrColorInfo colorInfo(ct, this->alphaType(), this->refColorSpace());
53 auto sContext = ctx->priv().makeSC(std::move(view), colorInfo);
54 if (!sContext) {
55 return false;
56 }
57 size_t rowBytes = this->imageInfo().minRowBytes();
58 return sContext->readPixels(ctx, {this->imageInfo(), pixmap.writable_addr(), rowBytes}, {0, 0});
59}
60
61namespace SkImages {
62sk_sp<SkImage> DeferredFromTextureGenerator(std::unique_ptr<GrTextureGenerator> generator) {
64 SharedGenerator::Make(std::move(generator)), nullptr, nullptr);
65
66 return validator ? sk_make_sp<SkImage_LazyTexture>(&validator) : nullptr;
67}
68}
GrColorType
const GrCaps * caps() const
GrDirectContextPriv priv()
std::unique_ptr< skgpu::ganesh::SurfaceContext > makeSC(GrSurfaceProxyView readView, const GrColorInfo &)
static sk_sp< SharedGenerator > Make(std::unique_ptr< SkImageGenerator > gen)
sk_sp< SkImage > onMakeSubset(GrDirectContext *, const SkIRect &) const override
bool readPixelsProxy(GrDirectContext *, const SkPixmap &) const override
sk_sp< SkImage > makeRasterImage(GrDirectContext *, CachingHint cachingHint=kDisallow_CachingHint) const
Definition SkImage.cpp:267
const SkImageInfo & imageInfo() const
Definition SkImage.h:279
SkAlphaType alphaType() const
Definition SkImage.cpp:154
sk_sp< SkColorSpace > refColorSpace() const
Definition SkImage.cpp:158
void * writable_addr() const
Definition SkPixmap.h:483
SK_API sk_sp< SkImage > DeferredFromTextureGenerator(std::unique_ptr< GrTextureGenerator > gen)
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
GrColorType ColorTypeOfLockTextureProxy(const GrCaps *caps, SkColorType sct)
GrSurfaceProxyView LockTextureProxyView(GrRecordingContext *rContext, const SkImage_Lazy *img, GrImageTexGenPolicy texGenPolicy, skgpu::Mipmapped mipmapped)
size_t minRowBytes() const