34 {
35 int srcW = srcRect.
width();
36 int srcH = srcRect.
height();
37
40
41 int stepsX;
42 int stepsY;
44 stepsX =
static_cast<int>((sx > 1.f) ?
std::ceil(std::log2f(sx))
46 stepsY =
static_cast<int>((sy > 1.f) ?
std::ceil(std::log2f(sy))
48 } else {
49 stepsX = sx != 1.f;
50 stepsY = sy != 1.f;
51 }
52
55 if (stepsX < 0 || stepsY < 0) {
56
57
58
59
62 }
63 }
64
71 }
73 };
75
78 int srcX = srcRect.
fLeft;
79 int srcY = srcRect.
fTop;
81
82
84 !bmp.info().colorSpace()->gammaIsLinear()) {
85 auto cs = bmp.info().colorSpace()->makeLinearGamma();
86
88 std::move(cs));
90 if (!linearSurf) {
92 return;
93 }
94 linearSurf->getCanvas()->drawImage(bmp.asImage().get(), -srcX, -srcY,
sampling, &
paint);
95 tempSurf = std::move(linearSurf);
97 srcX = 0;
98 srcY = 0;
100 } else {
101
103 }
104 while (stepsX || stepsY) {
105 int nextW = resultInfo.
width();
106 int nextH = resultInfo.
height();
107 if (stepsX < 0) {
108 nextW = resultInfo.
width() << (-stepsX - 1);
109 stepsX++;
110 } else if (stepsX != 0) {
111 if (stepsX > 1) {
112 nextW = srcW * 2;
113 }
114 --stepsX;
115 }
116 if (stepsY < 0) {
117 nextH = resultInfo.
height() << (-stepsY - 1);
118 stepsY++;
119 } else if (stepsY != 0) {
120 if (stepsY > 1) {
121 nextH = srcH * 2;
122 }
123 --stepsY;
124 }
126 if (!stepsX && !stepsY) {
127
128 ii = resultInfo;
129 }
133 return;
134 }
135 next->getCanvas()->drawImageRect(
138 tempSurf = std::move(
next);
140 srcX = srcY = 0;
141 srcW = nextW;
142 srcH = nextH;
144 }
145
147 std::unique_ptr<char[]>
data(
new char[resultInfo.
height() * rowBytes]);
149 if (srcImage->
readPixels(
nullptr, pm, srcX, srcY)) {
151 public:
152 Result(std::unique_ptr<
const char[]>
data,
size_t rowBytes)
153 : fData(
std::move(
data)), fRowBytes(rowBytes) {}
154 int count()
const override {
return 1; }
155 const void*
data(
int i)
const override {
return fData.get(); }
156 size_t rowBytes(
int i)
const override {
return fRowBytes; }
157
158 private:
159 std::unique_ptr<const char[]> fData;
160 size_t fRowBytes;
161 };
162 callback(context, std::make_unique<Result>(std::move(
data), rowBytes));
163 } else {
165 }
166}
static float next(float f)
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
@ kFast_SrcRectConstraint
sample outside bounds; faster
virtual size_t rowBytes(int i) const =0
virtual int count() const =0
virtual const void * data(int i) const =0
const SkImageInfo & imageInfo() const
bool readPixels(GrDirectContext *context, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
sk_sp< SkImage > makeImageSnapshot()
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
SkSamplingOptions sampling
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SkSamplingOptions(SkFilterMode::kLinear))
SIN Vec< N, float > floor(const Vec< N, float > &x)
SIN Vec< N, float > ceil(const Vec< N, float > &x)
constexpr int32_t height() const
int32_t fTop
smaller y-axis bounds
constexpr int32_t width() const
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
int32_t fLeft
smaller x-axis bounds
SkImageInfo makeWH(int newWidth, int newHeight) const
size_t minRowBytes() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRect Make(const SkISize &size)
static SkRect MakeIWH(int w, int h)
std::shared_ptr< const fml::Mapping > data