Use bitmap.asImage()
Change-Id: Ie16194937530d7cd75f84d9af66c31b77875ef83 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347043 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
839eef3e9a
commit
dc607e35e1
@ -221,7 +221,7 @@ protected:
|
|||||||
SkBitmap bm;
|
SkBitmap bm;
|
||||||
bm.allocN32Pixels(256, 256);
|
bm.allocN32Pixels(256, 256);
|
||||||
bm.eraseColor(fColors[i].toSkColor());
|
bm.eraseColor(fColors[i].toSkColor());
|
||||||
auto image = SkImage::MakeFromBitmap(bm);
|
auto image = bm.asImage();
|
||||||
|
|
||||||
fImages[i] = direct ? image->makeTextureImage(direct) : std::move(image);
|
fImages[i] = direct ? image->makeTextureImage(direct) : std::move(image);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
canvas->scale(16, 16);
|
canvas->scale(16, 16);
|
||||||
canvas->drawBitmap(redBorder, 0, 0, nullptr);
|
canvas->drawBitmap(redBorder, 0, 0, nullptr);
|
||||||
canvas->resetMatrix();
|
canvas->resetMatrix();
|
||||||
sk_sp<SkImage> image = SkImage::MakeFromBitmap(redBorder);
|
sk_sp<SkImage> image = redBorder.asImage();
|
||||||
SkPaint lowPaint;
|
SkPaint lowPaint;
|
||||||
lowPaint.setFilterQuality(kLow_SkFilterQuality);
|
lowPaint.setFilterQuality(kLow_SkFilterQuality);
|
||||||
for (auto constraint : { SkCanvas::kStrict_SrcRectConstraint,
|
for (auto constraint : { SkCanvas::kStrict_SrcRectConstraint,
|
||||||
|
@ -21,7 +21,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
}
|
}
|
||||||
left = right;
|
left = right;
|
||||||
}
|
}
|
||||||
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
|
sk_sp<SkImage> image = bitmap.asImage();
|
||||||
SkImage* imagePtr = image.get();
|
SkImage* imagePtr = image.get();
|
||||||
for (auto dest: { 20, 30, 40, 60, 90 } ) {
|
for (auto dest: { 20, 30, 40, 60, 90 } ) {
|
||||||
canvas->drawImageNine(imagePtr, center, SkRect::MakeWH(dest, dest), nullptr);
|
canvas->drawImageNine(imagePtr, center, SkRect::MakeWH(dest, dest), nullptr);
|
||||||
|
@ -21,7 +21,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
}
|
}
|
||||||
left = right;
|
left = right;
|
||||||
}
|
}
|
||||||
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
|
sk_sp<SkImage> image = bitmap.asImage();
|
||||||
for (auto dest: { 20, 30, 40, 60, 90 } ) {
|
for (auto dest: { 20, 30, 40, 60, 90 } ) {
|
||||||
canvas->drawImageNine(image, center, SkRect::MakeWH(dest, 110 - dest), nullptr);
|
canvas->drawImageNine(image, center, SkRect::MakeWH(dest, 110 - dest), nullptr);
|
||||||
canvas->translate(dest + 4, 0);
|
canvas->translate(dest + 4, 0);
|
||||||
|
@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
SkBitmap redBorder;
|
SkBitmap redBorder;
|
||||||
redBorder.installPixels(SkImageInfo::MakeN32Premul(4, 4),
|
redBorder.installPixels(SkImageInfo::MakeN32Premul(4, 4),
|
||||||
(void*) pixels, sizeof(pixels[0]));
|
(void*) pixels, sizeof(pixels[0]));
|
||||||
sk_sp<SkImage> image = SkImage::MakeFromBitmap(redBorder);
|
sk_sp<SkImage> image = redBorder.asImage();
|
||||||
SkPaint lowPaint;
|
SkPaint lowPaint;
|
||||||
for (auto constraint : {
|
for (auto constraint : {
|
||||||
SkCanvas::kFast_SrcRectConstraint,
|
SkCanvas::kFast_SrcRectConstraint,
|
||||||
|
@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
|
bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
|
||||||
(void*) pixels, sizeof(pixels[0]));
|
(void*) pixels, sizeof(pixels[0]));
|
||||||
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
|
sk_sp<SkImage> image = bitmap.asImage();
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
canvas->scale(4, 4);
|
canvas->scale(4, 4);
|
||||||
for (auto alpha : { 50, 100, 150, 255 } ) {
|
for (auto alpha : { 50, 100, 150, 255 } ) {
|
||||||
|
@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
|
bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
|
||||||
(void*) pixels, sizeof(pixels[0]));
|
(void*) pixels, sizeof(pixels[0]));
|
||||||
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
|
sk_sp<SkImage> image = bitmap.asImage();
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
canvas->scale(4, 4);
|
canvas->scale(4, 4);
|
||||||
for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
|
for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
|
||||||
|
@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
|
bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
|
||||||
(void*) pixels, sizeof(pixels[0]));
|
(void*) pixels, sizeof(pixels[0]));
|
||||||
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
|
sk_sp<SkImage> image = bitmap.asImage();
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
canvas->scale(4, 4);
|
canvas->scale(4, 4);
|
||||||
for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
|
for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
|
||||||
|
@ -13,9 +13,9 @@ void draw(SkCanvas* canvas) {
|
|||||||
SkPixmap pixmap(imageInfo, storage[0], sizeof(storage) / 5);
|
SkPixmap pixmap(imageInfo, storage[0], sizeof(storage) / 5);
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
bitmap.installPixels(pixmap);
|
bitmap.installPixels(pixmap);
|
||||||
sk_sp<SkImage> image1 = SkImage::MakeFromBitmap(bitmap);
|
sk_sp<SkImage> image1 = bitmap.asImage();
|
||||||
bitmap.setImmutable();
|
bitmap.setImmutable();
|
||||||
sk_sp<SkImage> image2 = SkImage::MakeFromBitmap(bitmap);
|
sk_sp<SkImage> image2 = bitmap.asImage();
|
||||||
*pixmap.writable_addr8(2, 2) = 0x00;
|
*pixmap.writable_addr8(2, 2) = 0x00;
|
||||||
canvas->scale(10, 10);
|
canvas->scale(10, 10);
|
||||||
canvas->drawImage(image1, 0, 0);
|
canvas->drawImage(image1, 0, 0);
|
||||||
|
@ -22,7 +22,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
image->isLazyGenerated() ? "is lazily generated" : "not lazily generated",
|
image->isLazyGenerated() ? "is lazily generated" : "not lazily generated",
|
||||||
20, image->height() * 3 / 4, font, paint);
|
20, image->height() * 3 / 4, font, paint);
|
||||||
};
|
};
|
||||||
sk_sp<SkImage> bitmapImage(SkImage::MakeFromBitmap(source));
|
sk_sp<SkImage> bitmapImage(source.asImage());
|
||||||
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
||||||
kTopLeft_GrSurfaceOrigin,
|
kTopLeft_GrSurfaceOrigin,
|
||||||
kRGBA_8888_SkColorType,
|
kRGBA_8888_SkColorType,
|
||||||
|
@ -21,7 +21,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
canvas->drawString(image->isTextureBacked() ? "is GPU texture" : "not GPU texture",
|
canvas->drawString(image->isTextureBacked() ? "is GPU texture" : "not GPU texture",
|
||||||
20, image->height() * 3 / 4, font, paint);
|
20, image->height() * 3 / 4, font, paint);
|
||||||
};
|
};
|
||||||
sk_sp<SkImage> bitmapImage(SkImage::MakeFromBitmap(source));
|
sk_sp<SkImage> bitmapImage(source.asImage());
|
||||||
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
||||||
kTopLeft_GrSurfaceOrigin,
|
kTopLeft_GrSurfaceOrigin,
|
||||||
kRGBA_8888_SkColorType,
|
kRGBA_8888_SkColorType,
|
||||||
|
@ -28,7 +28,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
|
|
||||||
canvas->drawString(msg, 20, image->height() * 7 / 8, font, paint);
|
canvas->drawString(msg, 20, image->height() * 7 / 8, font, paint);
|
||||||
};
|
};
|
||||||
sk_sp<SkImage> bitmapImage(SkImage::MakeFromBitmap(source));
|
sk_sp<SkImage> bitmapImage(source.asImage());
|
||||||
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
||||||
kTopLeft_GrSurfaceOrigin,
|
kTopLeft_GrSurfaceOrigin,
|
||||||
kRGBA_8888_SkColorType,
|
kRGBA_8888_SkColorType,
|
||||||
|
@ -20,7 +20,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
canvas->drawImage(nonTexture, 0, 0);
|
canvas->drawImage(nonTexture, 0, 0);
|
||||||
canvas->drawString(label, 20, nonTexture->height() / 4, font, paint);
|
canvas->drawString(label, 20, nonTexture->height() / 4, font, paint);
|
||||||
};
|
};
|
||||||
sk_sp<SkImage> bitmapImage(SkImage::MakeFromBitmap(source));
|
sk_sp<SkImage> bitmapImage(source.asImage());
|
||||||
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
||||||
kTopLeft_GrSurfaceOrigin,
|
kTopLeft_GrSurfaceOrigin,
|
||||||
kRGBA_8888_SkColorType,
|
kRGBA_8888_SkColorType,
|
||||||
|
@ -20,7 +20,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
canvas->drawImage(raster, 0, 0);
|
canvas->drawImage(raster, 0, 0);
|
||||||
canvas->drawString(label, 20, raster->height() / 4, font, paint);
|
canvas->drawString(label, 20, raster->height() / 4, font, paint);
|
||||||
};
|
};
|
||||||
sk_sp<SkImage> bitmapImage(SkImage::MakeFromBitmap(source));
|
sk_sp<SkImage> bitmapImage(source.asImage());
|
||||||
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
||||||
kTopLeft_GrSurfaceOrigin,
|
kTopLeft_GrSurfaceOrigin,
|
||||||
kRGBA_8888_SkColorType,
|
kRGBA_8888_SkColorType,
|
||||||
|
@ -25,7 +25,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
canvas->drawImage(texture, 0, 0);
|
canvas->drawImage(texture, 0, 0);
|
||||||
canvas->drawString(label, 20, texture->height() / 4, font, paint);
|
canvas->drawString(label, 20, texture->height() / 4, font, paint);
|
||||||
};
|
};
|
||||||
sk_sp<SkImage> bitmapImage(SkImage::MakeFromBitmap(source));
|
sk_sp<SkImage> bitmapImage(source.asImage());
|
||||||
|
|
||||||
|
|
||||||
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
sk_sp<SkImage> textureImage(SkImage::MakeFromTexture(dContext, backEndTexture,
|
||||||
|
@ -14,7 +14,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
sk_sp<SkImage> image;
|
sk_sp<SkImage> image;
|
||||||
} tests[] = {
|
} tests[] = {
|
||||||
{ "image", image },
|
{ "image", image },
|
||||||
{ "bitmap", SkImage::MakeFromBitmap(source) },
|
{ "bitmap", source.asImage() },
|
||||||
{ "texture", SkImage::MakeFromTexture(dContext, backEndTexture, kTopLeft_GrSurfaceOrigin,
|
{ "texture", SkImage::MakeFromTexture(dContext, backEndTexture, kTopLeft_GrSurfaceOrigin,
|
||||||
kRGBA_8888_SkColorType, kOpaque_SkAlphaType,
|
kRGBA_8888_SkColorType, kOpaque_SkAlphaType,
|
||||||
nullptr) }
|
nullptr) }
|
||||||
|
@ -15,7 +15,7 @@ void doCell(SkCanvas* canvas, float x, float y, SkAlphaType at, SkColor c, int n
|
|||||||
SkBitmap bmp;
|
SkBitmap bmp;
|
||||||
bmp.allocPixels(info);
|
bmp.allocPixels(info);
|
||||||
fill(bmp, c, n);
|
fill(bmp, c, n);
|
||||||
sk_sp<SkImage> img = SkImage::MakeFromBitmap(bmp);
|
sk_sp<SkImage> img = bmp.asImage();
|
||||||
|
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
const SkTileMode tile = SkTileMode::kRepeat;
|
const SkTileMode tile = SkTileMode::kRepeat;
|
||||||
|
@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
*(premulBitmap.getAddr32(x, y)) = 0x80808080;
|
*(premulBitmap.getAddr32(x, y)) = 0x80808080;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sk_sp<SkImage> premulImage = SkImage::MakeFromBitmap(premulBitmap);
|
sk_sp<SkImage> premulImage = premulBitmap.asImage();
|
||||||
|
|
||||||
SkImageInfo unpremulInfo = premulInfo.makeAlphaType(kUnpremul_SkAlphaType);
|
SkImageInfo unpremulInfo = premulInfo.makeAlphaType(kUnpremul_SkAlphaType);
|
||||||
SkBitmap unpremulBitmap;
|
SkBitmap unpremulBitmap;
|
||||||
@ -22,7 +22,7 @@ void draw(SkCanvas* canvas) {
|
|||||||
*(unpremulBitmap.getAddr32(x, y)) = 0x80FFFFFF;
|
*(unpremulBitmap.getAddr32(x, y)) = 0x80FFFFFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sk_sp<SkImage> unpremulImage = SkImage::MakeFromBitmap(unpremulBitmap);
|
sk_sp<SkImage> unpremulImage = unpremulBitmap.asImage();
|
||||||
|
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
const SkTileMode tile = SkTileMode::kRepeat;
|
const SkTileMode tile = SkTileMode::kRepeat;
|
||||||
|
@ -25,7 +25,7 @@ static sk_sp<SkColorFilter> make_color_filter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void draw(SkCanvas* canvas) {
|
void draw(SkCanvas* canvas) {
|
||||||
auto image = SkImage::MakeFromBitmap(make_alpha_image(96, 96));
|
auto image = make_alpha_image(96, 96).asImage();
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
|
|
||||||
paint.setColorFilter(make_color_filter());
|
paint.setColorFilter(make_color_filter());
|
||||||
|
@ -23,7 +23,7 @@ sk_sp<SkImage> foo() {
|
|||||||
SkCanvas c(bm);
|
SkCanvas c(bm);
|
||||||
c.clear(0);
|
c.clear(0);
|
||||||
c.drawRect(bounds, paint);
|
c.drawRect(bounds, paint);
|
||||||
return SkImage::MakeFromBitmap(bm);
|
return bm.asImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(SkCanvas* canvas) {
|
void draw(SkCanvas* canvas) {
|
||||||
|
@ -6,8 +6,8 @@ REG_FIDDLE(skbug_5648, 256, 256, true, 4) {
|
|||||||
void draw(SkCanvas*) {
|
void draw(SkCanvas*) {
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
source.extractSubset(&bitmap, {0, 0, source.width() - 1, source.height() - 1});
|
source.extractSubset(&bitmap, {0, 0, source.width() - 1, source.height() - 1});
|
||||||
auto img0 = SkImage::MakeFromBitmap(bitmap);
|
auto img0 = bitmap.asImage();
|
||||||
auto img1 = SkImage::MakeFromBitmap(bitmap);
|
auto img1 = bitmap.asImage();
|
||||||
SkDebugf("%u\n%u\n", img0->uniqueID(), img1->uniqueID());
|
SkDebugf("%u\n%u\n", img0->uniqueID(), img1->uniqueID());
|
||||||
}
|
}
|
||||||
} // END FIDDLE
|
} // END FIDDLE
|
||||||
|
@ -271,7 +271,7 @@ static void fuzz_drawImage(Fuzz* fuzz) {
|
|||||||
SkBitmap bmp;
|
SkBitmap bmp;
|
||||||
init_bitmap(fuzz, &bmp);
|
init_bitmap(fuzz, &bmp);
|
||||||
|
|
||||||
sk_sp<SkImage> image(SkImage::MakeFromBitmap(bmp));
|
sk_sp<SkImage> image(bmp.asImage());
|
||||||
|
|
||||||
bool bl;
|
bool bl;
|
||||||
fuzz->next(&bl);
|
fuzz->next(&bl);
|
||||||
|
@ -1224,6 +1224,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SkImage(const SkImageInfo& info, uint32_t uniqueID);
|
SkImage(const SkImageInfo& info, uint32_t uniqueID);
|
||||||
|
|
||||||
|
friend class SkBitmap;
|
||||||
friend class SkImage_Base;
|
friend class SkImage_Base;
|
||||||
friend class SkMipmapBuilder;
|
friend class SkMipmapBuilder;
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ sk_sp<SkImage> MultiFrameImageAsset::generateFrame(float t) {
|
|||||||
SkSamplingOptions(SkFilterMode::kLinear,
|
SkSamplingOptions(SkFilterMode::kLinear,
|
||||||
SkMipmapMode::kNearest),
|
SkMipmapMode::kNearest),
|
||||||
SkImage::kDisallow_CachingHint)) {
|
SkImage::kDisallow_CachingHint)) {
|
||||||
image = SkImage::MakeFromBitmap(bm);
|
image = bm.asImage();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// When the image size is OK, just force-decode.
|
// When the image size is OK, just force-decode.
|
||||||
|
@ -169,8 +169,8 @@ public:
|
|||||||
|
|
||||||
void onOnceBeforeDraw() override {
|
void onOnceBeforeDraw() override {
|
||||||
fBlur = SkImageFilters::Blur(8.f, 8.f, nullptr);
|
fBlur = SkImageFilters::Blur(8.f, 8.f, nullptr);
|
||||||
fImage = SkImage::MakeFromBitmap(ToolUtils::create_checkerboard_bitmap(
|
fImage = ToolUtils::create_checkerboard_image(
|
||||||
300, 300, SK_ColorMAGENTA, SK_ColorLTGRAY, 50));
|
300, 300, SK_ColorMAGENTA, SK_ColorLTGRAY, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onDrawContent(SkCanvas* canvas) override {
|
void onDrawContent(SkCanvas* canvas) override {
|
||||||
|
@ -1943,7 +1943,7 @@ static sk_sp<SkImage> bitmap_as_image(const SkBitmap& bitmap) {
|
|||||||
if (bitmap.drawsNothing()) {
|
if (bitmap.drawsNothing()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return SkImage::MakeFromBitmap(bitmap);
|
return bitmap.asImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, const SkPaint* paint) {
|
void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, const SkPaint* paint) {
|
||||||
|
@ -238,7 +238,7 @@ bool SkPixmap::scalePixels(const SkPixmap& actualDst, const SkSamplingOptions& s
|
|||||||
SkRect::Make(dst.bounds()),
|
SkRect::Make(dst.bounds()),
|
||||||
SkMatrix::kFill_ScaleToFit);
|
SkMatrix::kFill_ScaleToFit);
|
||||||
|
|
||||||
sk_sp<SkShader> shader = SkImageShader::Make(SkImage::MakeFromBitmap(bitmap),
|
sk_sp<SkShader> shader = SkImageShader::Make(bitmap.asImage(),
|
||||||
SkTileMode::kClamp,
|
SkTileMode::kClamp,
|
||||||
SkTileMode::kClamp,
|
SkTileMode::kClamp,
|
||||||
&sampling,
|
&sampling,
|
||||||
|
@ -239,10 +239,10 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SkImage::MakeFromBitmap(subsetBM);
|
return subsetBM.asImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return SkImage::MakeFromBitmap(fBitmap);
|
return fBitmap.asImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkSurface> onMakeTightSurface(SkColorType colorType, const SkColorSpace* colorSpace,
|
sk_sp<SkSurface> onMakeTightSurface(SkColorType colorType, const SkColorSpace* colorSpace,
|
||||||
|
@ -244,7 +244,7 @@ sk_sp<SkImage> SkImage_Lazy::onReinterpretColorSpace(sk_sp<SkColorSpace> newCS)
|
|||||||
pixmap.setColorSpace(this->refColorSpace());
|
pixmap.setColorSpace(this->refColorSpace());
|
||||||
if (ScopedGenerator(fSharedGenerator)->getPixels(pixmap)) {
|
if (ScopedGenerator(fSharedGenerator)->getPixels(pixmap)) {
|
||||||
bitmap.setImmutable();
|
bitmap.setImmutable();
|
||||||
return SkImage::MakeFromBitmap(bitmap);
|
return bitmap.asImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -267,7 +267,7 @@ sk_sp<SkImage> SkImage_Raster::onMakeSubset(const SkIRect& subset, GrDirectConte
|
|||||||
subset.height());
|
subset.height());
|
||||||
|
|
||||||
bitmap.setImmutable();
|
bitmap.setImmutable();
|
||||||
return MakeFromBitmap(bitmap);
|
return bitmap.asImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -399,7 +399,7 @@ sk_sp<SkImage> SkImage_Raster::onMakeColorTypeAndColorSpace(SkColorType targetCT
|
|||||||
|
|
||||||
SkAssertResult(dst.writePixels(src));
|
SkAssertResult(dst.writePixels(src));
|
||||||
dst.setImmutable();
|
dst.setImmutable();
|
||||||
return SkImage::MakeFromBitmap(dst);
|
return dst.asImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkImage> SkImage_Raster::onReinterpretColorSpace(sk_sp<SkColorSpace> newCS) const {
|
sk_sp<SkImage> SkImage_Raster::onReinterpretColorSpace(sk_sp<SkColorSpace> newCS) const {
|
||||||
|
@ -94,7 +94,7 @@ sk_sp<SkImage> SkSurface_Raster::onNewImageSnapshot(const SkIRect* subset) {
|
|||||||
dst.allocPixels(fBitmap.info().makeDimensions(subset->size()));
|
dst.allocPixels(fBitmap.info().makeDimensions(subset->size()));
|
||||||
SkAssertResult(fBitmap.readPixels(dst.pixmap(), subset->left(), subset->top()));
|
SkAssertResult(fBitmap.readPixels(dst.pixmap(), subset->left(), subset->top()));
|
||||||
dst.setImmutable(); // key, so MakeFromBitmap doesn't make a copy of the buffer
|
dst.setImmutable(); // key, so MakeFromBitmap doesn't make a copy of the buffer
|
||||||
return SkImage::MakeFromBitmap(dst);
|
return dst.asImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkCopyPixelsMode cpm = kIfMutable_SkCopyPixelsMode;
|
SkCopyPixelsMode cpm = kIfMutable_SkCopyPixelsMode;
|
||||||
|
@ -24,7 +24,7 @@ SkKeyedImage::SkKeyedImage(sk_sp<SkImage> i) : fImage(std::move(i)) {
|
|||||||
fKey = SkBitmapKeyFromImage(fImage.get());
|
fKey = SkBitmapKeyFromImage(fImage.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
SkKeyedImage::SkKeyedImage(const SkBitmap& bm) : fImage(SkImage::MakeFromBitmap(bm)) {
|
SkKeyedImage::SkKeyedImage(const SkBitmap& bm) : fImage(bm.asImage()) {
|
||||||
if (fImage) {
|
if (fImage) {
|
||||||
fKey = {bm.getSubset(), bm.getGenerationID()};
|
fKey = {bm.getSubset(), bm.getGenerationID()};
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,8 @@ sk_sp<SkImage> alpha_image_to_greyscale_image(const SkImage* mask) {
|
|||||||
greyBitmap.getPixels(), greyBitmap.rowBytes(), 0, 0)) {
|
greyBitmap.getPixels(), greyBitmap.rowBytes(), 0, 0)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return SkImage::MakeFromBitmap(greyBitmap);
|
greyBitmap.setImmutable();
|
||||||
|
return greyBitmap.asImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_resource(SkTHashSet<SkPDFIndirectReference>& resources, SkPDFIndirectReference ref) {
|
static int add_resource(SkTHashSet<SkPDFIndirectReference>& resources, SkPDFIndirectReference ref) {
|
||||||
|
@ -462,7 +462,7 @@ static ImageAndOffset to_image(SkGlyphID gid, SkBulkGlyphMetricsAndImages* small
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bm.setImmutable();
|
bm.setImmutable();
|
||||||
return {SkImage::MakeFromBitmap(bm), {bounds.x(), bounds.y()}};
|
return {bm.asImage(), {bounds.x(), bounds.y()}};
|
||||||
case SkMask::kA8_Format:
|
case SkMask::kA8_Format:
|
||||||
bm.installPixels(SkImageInfo::MakeA8(bounds.width(), bounds.height()),
|
bm.installPixels(SkImageInfo::MakeA8(bounds.width(), bounds.height()),
|
||||||
mask.fImage, mask.fRowBytes);
|
mask.fImage, mask.fRowBytes);
|
||||||
|
@ -247,7 +247,7 @@ sk_sp<SkImage> SkMakeImageFromCGImage(CGImageRef src) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bm.setImmutable();
|
bm.setImmutable();
|
||||||
return SkImage::MakeFromBitmap(bm);
|
return bm.asImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
|
#endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
|
||||||
|
@ -101,7 +101,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_GPUDevice, reporter, ctxInfo) {
|
|||||||
SkASSERT(SkIRect::MakeWH(kWidth, kHeight) == special->subset());
|
SkASSERT(SkIRect::MakeWH(kWidth, kHeight) == special->subset());
|
||||||
|
|
||||||
// Create a gpu-backed special image from a raster-backed SkImage
|
// Create a gpu-backed special image from a raster-backed SkImage
|
||||||
sk_sp<SkImage> image(SkImage::MakeFromBitmap(bm));
|
sk_sp<SkImage> image(bm.asImage());
|
||||||
special = DeviceTestingAccess::MakeSpecial(gpuDev.get(), image.get());
|
special = DeviceTestingAccess::MakeSpecial(gpuDev.get(), image.get());
|
||||||
SkASSERT(special->isTextureBacked());
|
SkASSERT(special->isTextureBacked());
|
||||||
SkASSERT(kWidth == special->width());
|
SkASSERT(kWidth == special->width());
|
||||||
|
@ -37,6 +37,6 @@ DEF_TEST(FlattenableFactoryToName, r) {
|
|||||||
SkBitmap bm;
|
SkBitmap bm;
|
||||||
bm.allocN32Pixels(8, 8);
|
bm.allocN32Pixels(8, 8);
|
||||||
bm.eraseColor(SK_ColorCYAN);
|
bm.eraseColor(SK_ColorCYAN);
|
||||||
sk_sp<SkImage> image(SkImage::MakeFromBitmap(bm));
|
sk_sp<SkImage> image(bm.asImage());
|
||||||
test_flattenable(r, image->makeShader(SkSamplingOptions()).get(), "SkImage::newShader()");
|
test_flattenable(r, image->makeShader(SkSamplingOptions()).get(), "SkImage::newShader()");
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ DEF_GPUTEST(GrDDLImage_MakeSubset, reporter, options) {
|
|||||||
bm.allocPixels();
|
bm.allocPixels();
|
||||||
bm.eraseColor(SK_ColorBLACK);
|
bm.eraseColor(SK_ColorBLACK);
|
||||||
bm.setImmutable();
|
bm.setImmutable();
|
||||||
auto rasterImg = SkImage::MakeFromBitmap(bm);
|
auto rasterImg = bm.asImage();
|
||||||
REPORTER_ASSERT(reporter, rasterImg->isValid(static_cast<GrRecordingContext*>(nullptr)));
|
REPORTER_ASSERT(reporter, rasterImg->isValid(static_cast<GrRecordingContext*>(nullptr)));
|
||||||
|
|
||||||
// raster + context:
|
// raster + context:
|
||||||
|
@ -329,7 +329,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(Gr1x1TextureMipMappedTest, reporter, ctxInfo)
|
|||||||
SkPMColor* pixel = reinterpret_cast<SkPMColor*>(bmp.getPixels());
|
SkPMColor* pixel = reinterpret_cast<SkPMColor*>(bmp.getPixels());
|
||||||
*pixel = 0;
|
*pixel = 0;
|
||||||
|
|
||||||
sk_sp<SkImage> bmpImage = SkImage::MakeFromBitmap(bmp);
|
sk_sp<SkImage> bmpImage = bmp.asImage();
|
||||||
|
|
||||||
// Make sure we scale so we don't optimize out the use of mips.
|
// Make sure we scale so we don't optimize out the use of mips.
|
||||||
surface->getCanvas()->scale(0.5f, 0.5f);
|
surface->getCanvas()->scale(0.5f, 0.5f);
|
||||||
|
@ -22,9 +22,9 @@ DEF_TEST(ImageBitmapIdentity, r) {
|
|||||||
(void)bm.extractSubset(&a, SkIRect::MakeXYWH(0, 0, 32, 32));
|
(void)bm.extractSubset(&a, SkIRect::MakeXYWH(0, 0, 32, 32));
|
||||||
(void)bm.extractSubset(&b, SkIRect::MakeXYWH(0, 32, 32, 32));
|
(void)bm.extractSubset(&b, SkIRect::MakeXYWH(0, 32, 32, 32));
|
||||||
REPORTER_ASSERT(r, a.getGenerationID() == b.getGenerationID());
|
REPORTER_ASSERT(r, a.getGenerationID() == b.getGenerationID());
|
||||||
auto img = SkImage::MakeFromBitmap(bm);
|
auto img = bm.asImage();
|
||||||
auto imgA = SkImage::MakeFromBitmap(a);
|
auto imgA = a.asImage();
|
||||||
auto imgB = SkImage::MakeFromBitmap(b);
|
auto imgB = b.asImage();
|
||||||
REPORTER_ASSERT(r, img->uniqueID() == bm.getGenerationID());
|
REPORTER_ASSERT(r, img->uniqueID() == bm.getGenerationID());
|
||||||
REPORTER_ASSERT(r, img->uniqueID() != imgA->uniqueID());
|
REPORTER_ASSERT(r, img->uniqueID() != imgA->uniqueID());
|
||||||
REPORTER_ASSERT(r, img->uniqueID() != imgB->uniqueID());
|
REPORTER_ASSERT(r, img->uniqueID() != imgB->uniqueID());
|
||||||
|
@ -193,7 +193,7 @@ static void test_image_backed(skiatest::Reporter* reporter,
|
|||||||
DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) {
|
DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) {
|
||||||
SkBitmap srcBM = create_bm();
|
SkBitmap srcBM = create_bm();
|
||||||
|
|
||||||
sk_sp<SkImage> srcImage(SkImage::MakeFromBitmap(srcBM));
|
sk_sp<SkImage> srcImage(srcBM.asImage());
|
||||||
|
|
||||||
test_image_backed(reporter, nullptr, srcImage);
|
test_image_backed(reporter, nullptr, srcImage);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ public:
|
|||||||
SkImageFilters::ColorFilter(std::move(cf), input, cropRect));
|
SkImageFilters::ColorFilter(std::move(cf), input, cropRect));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
sk_sp<SkImage> gradientImage(SkImage::MakeFromBitmap(make_gradient_circle(64, 64)));
|
sk_sp<SkImage> gradientImage(make_gradient_circle(64, 64).asImage());
|
||||||
sk_sp<SkImageFilter> gradientSource(SkImageFilters::Image(std::move(gradientImage)));
|
sk_sp<SkImageFilter> gradientSource(SkImageFilters::Image(std::move(gradientImage)));
|
||||||
|
|
||||||
this->addFilter("displacement map",
|
this->addFilter("displacement map",
|
||||||
@ -515,7 +515,7 @@ static void test_negative_blur_sigma(skiatest::Reporter* reporter,
|
|||||||
sk_sp<SkImageFilter> positiveFilter(SkImageFilters::Blur(kBlurSigma, kBlurSigma, nullptr));
|
sk_sp<SkImageFilter> positiveFilter(SkImageFilters::Blur(kBlurSigma, kBlurSigma, nullptr));
|
||||||
sk_sp<SkImageFilter> negativeFilter(SkImageFilters::Blur(-kBlurSigma, kBlurSigma, nullptr));
|
sk_sp<SkImageFilter> negativeFilter(SkImageFilters::Blur(-kBlurSigma, kBlurSigma, nullptr));
|
||||||
|
|
||||||
sk_sp<SkImage> gradient = SkImage::MakeFromBitmap(make_gradient_circle(kWidth, kHeight));
|
sk_sp<SkImage> gradient = make_gradient_circle(kWidth, kHeight).asImage();
|
||||||
sk_sp<SkSpecialImage> imgSrc(
|
sk_sp<SkSpecialImage> imgSrc(
|
||||||
SkSpecialImage::MakeFromImage(dContext, SkIRect::MakeWH(kWidth, kHeight), gradient));
|
SkSpecialImage::MakeFromImage(dContext, SkIRect::MakeWH(kWidth, kHeight), gradient));
|
||||||
|
|
||||||
@ -607,7 +607,7 @@ static void test_morphology_radius_with_mirror_ctm(skiatest::Reporter* reporter,
|
|||||||
paint.setColor(SK_ColorWHITE);
|
paint.setColor(SK_ColorWHITE);
|
||||||
canvas.drawRect(SkRect::MakeXYWH(kWidth / 4, kHeight / 4, kWidth / 2, kHeight / 2),
|
canvas.drawRect(SkRect::MakeXYWH(kWidth / 4, kHeight / 4, kWidth / 2, kHeight / 2),
|
||||||
paint);
|
paint);
|
||||||
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
|
sk_sp<SkImage> image = bitmap.asImage();
|
||||||
sk_sp<SkSpecialImage> imgSrc(
|
sk_sp<SkSpecialImage> imgSrc(
|
||||||
SkSpecialImage::MakeFromImage(dContext, SkIRect::MakeWH(kWidth, kHeight), image));
|
SkSpecialImage::MakeFromImage(dContext, SkIRect::MakeWH(kWidth, kHeight), image));
|
||||||
|
|
||||||
@ -1002,7 +1002,7 @@ static void test_imagefilter_merge_result_size(skiatest::Reporter* reporter,
|
|||||||
SkBitmap greenBM;
|
SkBitmap greenBM;
|
||||||
greenBM.allocN32Pixels(20, 20);
|
greenBM.allocN32Pixels(20, 20);
|
||||||
greenBM.eraseColor(SK_ColorGREEN);
|
greenBM.eraseColor(SK_ColorGREEN);
|
||||||
sk_sp<SkImage> greenImage(SkImage::MakeFromBitmap(greenBM));
|
sk_sp<SkImage> greenImage(greenBM.asImage());
|
||||||
sk_sp<SkImageFilter> source(SkImageFilters::Image(std::move(greenImage)));
|
sk_sp<SkImageFilter> source(SkImageFilters::Image(std::move(greenImage)));
|
||||||
sk_sp<SkImageFilter> merge(SkImageFilters::Merge(source, source));
|
sk_sp<SkImageFilter> merge(SkImageFilters::Merge(source, source));
|
||||||
|
|
||||||
@ -1637,7 +1637,7 @@ static void test_large_blur_input(skiatest::Reporter* reporter, SkCanvas* canvas
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkImage> largeImage(SkImage::MakeFromBitmap(largeBmp));
|
sk_sp<SkImage> largeImage(largeBmp.asImage());
|
||||||
if (!largeImage) {
|
if (!largeImage) {
|
||||||
ERRORF(reporter, "Failed to create large image.");
|
ERRORF(reporter, "Failed to create large image.");
|
||||||
return;
|
return;
|
||||||
@ -1954,7 +1954,7 @@ DEF_TEST(DisplacementMapBounds, reporter) {
|
|||||||
|
|
||||||
// Test SkImageSource::filterBounds.
|
// Test SkImageSource::filterBounds.
|
||||||
DEF_TEST(ImageSourceBounds, reporter) {
|
DEF_TEST(ImageSourceBounds, reporter) {
|
||||||
sk_sp<SkImage> image(SkImage::MakeFromBitmap(make_gradient_circle(64, 64)));
|
sk_sp<SkImage> image(make_gradient_circle(64, 64).asImage());
|
||||||
// Default src and dst rects.
|
// Default src and dst rects.
|
||||||
sk_sp<SkImageFilter> source1(SkImageFilters::Image(image));
|
sk_sp<SkImageFilter> source1(SkImageFilters::Image(image));
|
||||||
SkIRect imageBounds = SkIRect::MakeWH(64, 64);
|
SkIRect imageBounds = SkIRect::MakeWH(64, 64);
|
||||||
|
@ -15,5 +15,5 @@ DEF_TEST(ImageFrom565Bitmap, r) {
|
|||||||
bm.allocPixels(SkImageInfo::Make(
|
bm.allocPixels(SkImageInfo::Make(
|
||||||
5, 7, kRGB_565_SkColorType, kOpaque_SkAlphaType));
|
5, 7, kRGB_565_SkColorType, kOpaque_SkAlphaType));
|
||||||
bm.eraseColor(SK_ColorBLACK);
|
bm.eraseColor(SK_ColorBLACK);
|
||||||
REPORTER_ASSERT(r, SkImage::MakeFromBitmap(bm) != nullptr);
|
REPORTER_ASSERT(r, bm.asImage() != nullptr);
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,7 @@ DEF_TEST(image_newfrombitmap, reporter) {
|
|||||||
SkBitmap bm;
|
SkBitmap bm;
|
||||||
rec[i].fMakeProc(&bm);
|
rec[i].fMakeProc(&bm);
|
||||||
|
|
||||||
sk_sp<SkImage> image(SkImage::MakeFromBitmap(bm));
|
sk_sp<SkImage> image(bm.asImage());
|
||||||
SkPixmap pmap;
|
SkPixmap pmap;
|
||||||
|
|
||||||
const bool sharedID = (image->uniqueID() == bm.getGenerationID());
|
const bool sharedID = (image->uniqueID() == bm.getGenerationID());
|
||||||
@ -511,7 +511,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UnpremulTextureImage, reporter, ctxInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto dContext = ctxInfo.directContext();
|
auto dContext = ctxInfo.directContext();
|
||||||
auto texImage = SkImage::MakeFromBitmap(bmp)->makeTextureImage(dContext);
|
auto texImage = bmp.asImage()->makeTextureImage(dContext);
|
||||||
if (!texImage || texImage->alphaType() != kUnpremul_SkAlphaType) {
|
if (!texImage || texImage->alphaType() != kUnpremul_SkAlphaType) {
|
||||||
ERRORF(reporter, "Failed to make unpremul texture image.");
|
ERRORF(reporter, "Failed to make unpremul texture image.");
|
||||||
return;
|
return;
|
||||||
@ -746,7 +746,7 @@ static void test_legacy_bitmap(skiatest::Reporter* reporter, GrDirectContext* dC
|
|||||||
SkBitmap tmp;
|
SkBitmap tmp;
|
||||||
REPORTER_ASSERT(reporter, bitmap.extractSubset(&tmp, SkIRect::MakeWH(image->width() / 2,
|
REPORTER_ASSERT(reporter, bitmap.extractSubset(&tmp, SkIRect::MakeWH(image->width() / 2,
|
||||||
image->height() / 2)));
|
image->height() / 2)));
|
||||||
sk_sp<SkImage> subsetImage(SkImage::MakeFromBitmap(tmp));
|
sk_sp<SkImage> subsetImage(tmp.asImage());
|
||||||
REPORTER_ASSERT(reporter, subsetImage.get());
|
REPORTER_ASSERT(reporter, subsetImage.get());
|
||||||
|
|
||||||
SkBitmap subsetBitmap;
|
SkBitmap subsetBitmap;
|
||||||
@ -1169,7 +1169,7 @@ DEF_TEST(Image_ColorSpace, r) {
|
|||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
SkImageInfo info = SkImageInfo::MakeN32(10, 10, kPremul_SkAlphaType, rec2020);
|
SkImageInfo info = SkImageInfo::MakeN32(10, 10, kPremul_SkAlphaType, rec2020);
|
||||||
bitmap.allocPixels(info);
|
bitmap.allocPixels(info);
|
||||||
image = SkImage::MakeFromBitmap(bitmap);
|
image = bitmap.asImage();
|
||||||
REPORTER_ASSERT(r, SkColorSpace::Equals(rec2020.get(), image->colorSpace()));
|
REPORTER_ASSERT(r, SkColorSpace::Equals(rec2020.get(), image->colorSpace()));
|
||||||
|
|
||||||
sk_sp<SkSurface> surface = SkSurface::MakeRaster(
|
sk_sp<SkSurface> surface = SkSurface::MakeRaster(
|
||||||
@ -1192,7 +1192,7 @@ DEF_TEST(Image_makeColorSpace, r) {
|
|||||||
srgbBitmap.allocPixels(SkImageInfo::MakeS32(1, 1, kOpaque_SkAlphaType));
|
srgbBitmap.allocPixels(SkImageInfo::MakeS32(1, 1, kOpaque_SkAlphaType));
|
||||||
*srgbBitmap.getAddr32(0, 0) = SkSwizzle_RGBA_to_PMColor(0xFF604020);
|
*srgbBitmap.getAddr32(0, 0) = SkSwizzle_RGBA_to_PMColor(0xFF604020);
|
||||||
srgbBitmap.setImmutable();
|
srgbBitmap.setImmutable();
|
||||||
sk_sp<SkImage> srgbImage = SkImage::MakeFromBitmap(srgbBitmap);
|
sk_sp<SkImage> srgbImage = srgbBitmap.asImage();
|
||||||
sk_sp<SkImage> p3Image = srgbImage->makeColorSpace(p3, nullptr);
|
sk_sp<SkImage> p3Image = srgbImage->makeColorSpace(p3, nullptr);
|
||||||
SkBitmap p3Bitmap;
|
SkBitmap p3Bitmap;
|
||||||
bool success = p3Image->asLegacyBitmap(&p3Bitmap);
|
bool success = p3Image->asLegacyBitmap(&p3Bitmap);
|
||||||
@ -1253,7 +1253,7 @@ DEF_TEST(image_roundtrip_encode, reporter) {
|
|||||||
SkBitmap bm0;
|
SkBitmap bm0;
|
||||||
make_all_premul(&bm0);
|
make_all_premul(&bm0);
|
||||||
|
|
||||||
auto img0 = SkImage::MakeFromBitmap(bm0);
|
auto img0 = bm0.asImage();
|
||||||
sk_sp<SkData> data = img0->encodeToData(SkEncodedImageFormat::kPNG, 100);
|
sk_sp<SkData> data = img0->encodeToData(SkEncodedImageFormat::kPNG, 100);
|
||||||
auto img1 = SkImage::MakeFromEncoded(data);
|
auto img1 = SkImage::MakeFromEncoded(data);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RepeatedClippedBlurTest, reporter, ctxInfo) {
|
|||||||
bm.eraseColor(SK_ColorRED);
|
bm.eraseColor(SK_ColorRED);
|
||||||
bm.eraseArea(SkIRect::MakeXYWH(1, 2, 1277, 1274), SK_ColorGREEN);
|
bm.eraseArea(SkIRect::MakeXYWH(1, 2, 1277, 1274), SK_ColorGREEN);
|
||||||
|
|
||||||
sk_sp<SkImage> rasterImg = SkImage::MakeFromBitmap(bm);
|
sk_sp<SkImage> rasterImg = bm.asImage();
|
||||||
bigImg = rasterImg->makeTextureImage(dContext);
|
bigImg = rasterImg->makeTextureImage(dContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,9 +271,9 @@ static void TestBitmapSerialization(const SkBitmap& validBitmap,
|
|||||||
const SkBitmap& invalidBitmap,
|
const SkBitmap& invalidBitmap,
|
||||||
bool shouldSucceed,
|
bool shouldSucceed,
|
||||||
skiatest::Reporter* reporter) {
|
skiatest::Reporter* reporter) {
|
||||||
sk_sp<SkImage> validImage(SkImage::MakeFromBitmap(validBitmap));
|
sk_sp<SkImage> validImage(validBitmap.asImage());
|
||||||
sk_sp<SkImageFilter> validBitmapSource(SkImageFilters::Image(std::move(validImage)));
|
sk_sp<SkImageFilter> validBitmapSource(SkImageFilters::Image(std::move(validImage)));
|
||||||
sk_sp<SkImage> invalidImage(SkImage::MakeFromBitmap(invalidBitmap));
|
sk_sp<SkImage> invalidImage(invalidBitmap.asImage());
|
||||||
sk_sp<SkImageFilter> invalidBitmapSource(SkImageFilters::Image(std::move(invalidImage)));
|
sk_sp<SkImageFilter> invalidBitmapSource(SkImageFilters::Image(std::move(invalidImage)));
|
||||||
sk_sp<SkImageFilter> xfermodeImageFilter(
|
sk_sp<SkImageFilter> xfermodeImageFilter(
|
||||||
SkImageFilters::Blend(SkBlendMode::kSrcOver,
|
SkImageFilters::Blend(SkBlendMode::kSrcOver,
|
||||||
|
@ -40,13 +40,13 @@ DEF_TEST(Shader_isAImage, reporter) {
|
|||||||
const int H = 100;
|
const int H = 100;
|
||||||
SkBitmap bm;
|
SkBitmap bm;
|
||||||
bm.allocN32Pixels(W, H);
|
bm.allocN32Pixels(W, H);
|
||||||
auto img = SkImage::MakeFromBitmap(bm);
|
auto img = bm.asImage();
|
||||||
const SkMatrix localM = SkMatrix::Scale(2, 3);
|
const SkMatrix localM = SkMatrix::Scale(2, 3);
|
||||||
const SkTileMode tmx = SkTileMode::kRepeat;
|
const SkTileMode tmx = SkTileMode::kRepeat;
|
||||||
const SkTileMode tmy = SkTileMode::kMirror;
|
const SkTileMode tmy = SkTileMode::kMirror;
|
||||||
|
|
||||||
auto shader0 = bm.makeShader(tmx, tmy, SkSamplingOptions(), localM);
|
auto shader0 = bm.makeShader(tmx, tmy, SkSamplingOptions(), localM);
|
||||||
auto shader1 = SkImage::MakeFromBitmap(bm)->makeShader(tmx, tmy, SkSamplingOptions(), localM);
|
auto shader1 = bm.asImage()->makeShader(tmx, tmy, SkSamplingOptions(), localM);
|
||||||
|
|
||||||
check_isaimage(reporter, shader0.get(), W, H, tmx, tmy, localM);
|
check_isaimage(reporter, shader0.get(), W, H, tmx, tmy, localM);
|
||||||
check_isaimage(reporter, shader1.get(), W, H, tmx, tmy, localM);
|
check_isaimage(reporter, shader1.get(), W, H, tmx, tmy, localM);
|
||||||
|
@ -27,7 +27,7 @@ DEF_TEST(SkImageFromBitmap_extractSubset, reporter) {
|
|||||||
canvas.drawIRect(r, p);
|
canvas.drawIRect(r, p);
|
||||||
SkBitmap dstBitmap;
|
SkBitmap dstBitmap;
|
||||||
srcBitmap.extractSubset(&dstBitmap, r);
|
srcBitmap.extractSubset(&dstBitmap, r);
|
||||||
image = SkImage::MakeFromBitmap(dstBitmap);
|
image = dstBitmap.asImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkBitmap tgt;
|
SkBitmap tgt;
|
||||||
|
@ -43,7 +43,7 @@ static void test_mipmapcache(skiatest::Reporter* reporter, SkResourceCache* cach
|
|||||||
SkBitmap src;
|
SkBitmap src;
|
||||||
src.allocN32Pixels(5, 5);
|
src.allocN32Pixels(5, 5);
|
||||||
src.setImmutable();
|
src.setImmutable();
|
||||||
sk_sp<SkImage> img = SkImage::MakeFromBitmap(src);
|
sk_sp<SkImage> img = src.asImage();
|
||||||
const auto desc = SkBitmapCacheDesc::Make(img.get());
|
const auto desc = SkBitmapCacheDesc::Make(img.get());
|
||||||
|
|
||||||
const SkMipmap* mipmap = SkMipmapCache::FindAndRef(desc, cache);
|
const SkMipmap* mipmap = SkMipmapCache::FindAndRef(desc, cache);
|
||||||
@ -85,7 +85,7 @@ static void test_mipmap_notify(skiatest::Reporter* reporter, SkResourceCache* ca
|
|||||||
for (int i = 0; i < N; ++i) {
|
for (int i = 0; i < N; ++i) {
|
||||||
src[i].allocN32Pixels(5, 5);
|
src[i].allocN32Pixels(5, 5);
|
||||||
src[i].setImmutable();
|
src[i].setImmutable();
|
||||||
img[i] = SkImage::MakeFromBitmap(src[i]);
|
img[i] = src[i].asImage();
|
||||||
SkMipmapCache::AddAndRef(as_IB(img[i].get()), cache)->unref();
|
SkMipmapCache::AddAndRef(as_IB(img[i].get()), cache)->unref();
|
||||||
desc[i] = SkBitmapCacheDesc::Make(img[i].get());
|
desc[i] = SkBitmapCacheDesc::Make(img[i].get());
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ DEF_TEST(SpecialImage_Raster, reporter) {
|
|||||||
static void test_specialimage_image(skiatest::Reporter* reporter) {
|
static void test_specialimage_image(skiatest::Reporter* reporter) {
|
||||||
SkBitmap bm = create_bm();
|
SkBitmap bm = create_bm();
|
||||||
|
|
||||||
sk_sp<SkImage> fullImage(SkImage::MakeFromBitmap(bm));
|
sk_sp<SkImage> fullImage(bm.asImage());
|
||||||
|
|
||||||
sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromImage(
|
sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromImage(
|
||||||
nullptr,
|
nullptr,
|
||||||
|
@ -229,7 +229,7 @@ static void invalidation_test(GrDirectContext* dContext, skiatest::Reporter* rep
|
|||||||
SkBitmap bm;
|
SkBitmap bm;
|
||||||
bm.allocPixels(ii);
|
bm.allocPixels(ii);
|
||||||
|
|
||||||
rasterImg = SkImage::MakeFromBitmap(bm);
|
rasterImg = bm.asImage();
|
||||||
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
||||||
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ sk_sp<SkImage> DDLPromiseImageHelper::CreatePromiseImages(const void* rawData,
|
|||||||
// texture wouldn't fit on the GPU. Create a separate bitmap-backed image for each thread.
|
// texture wouldn't fit on the GPU. Create a separate bitmap-backed image for each thread.
|
||||||
if (!curImage.isYUV() && !curImage.callbackContext(0)) {
|
if (!curImage.isYUV() && !curImage.callbackContext(0)) {
|
||||||
SkASSERT(curImage.baseLevel().isImmutable());
|
SkASSERT(curImage.baseLevel().isImmutable());
|
||||||
return SkImage::MakeFromBitmap(curImage.baseLevel());
|
return curImage.baseLevel().asImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkASSERT(curImage.index() == *indexPtr);
|
SkASSERT(curImage.index() == *indexPtr);
|
||||||
|
@ -35,7 +35,7 @@ sk_sp<SkImage> SkSharingDeserialContext::deserializeImage(
|
|||||||
// Return something so the rest of the debugger can proceeed.
|
// Return something so the rest of the debugger can proceeed.
|
||||||
SkBitmap bm;
|
SkBitmap bm;
|
||||||
bm.allocPixels(SkImageInfo::MakeN32Premul(1, 1));
|
bm.allocPixels(SkImageInfo::MakeN32Premul(1, 1));
|
||||||
return SkImage::MakeFromBitmap(bm);
|
return bm.asImage();
|
||||||
}
|
}
|
||||||
SkSharingDeserialContext* context = reinterpret_cast<SkSharingDeserialContext*>(ctx);
|
SkSharingDeserialContext* context = reinterpret_cast<SkSharingDeserialContext*>(ctx);
|
||||||
uint32_t fid;
|
uint32_t fid;
|
||||||
|
@ -721,7 +721,7 @@ static const char* alpha_type_name(SkAlphaType alphaType) {
|
|||||||
bool DrawCommand::flatten(const SkBitmap& bitmap,
|
bool DrawCommand::flatten(const SkBitmap& bitmap,
|
||||||
SkJSONWriter& writer,
|
SkJSONWriter& writer,
|
||||||
UrlDataManager& urlDataManager) {
|
UrlDataManager& urlDataManager) {
|
||||||
sk_sp<SkImage> image(SkImage::MakeFromBitmap(bitmap));
|
sk_sp<SkImage> image(bitmap.asImage());
|
||||||
writer.appendString(DEBUGCANVAS_ATTRIBUTE_COLOR, color_type_name(bitmap.colorType()));
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_COLOR, color_type_name(bitmap.colorType()));
|
||||||
writer.appendString(DEBUGCANVAS_ATTRIBUTE_ALPHA, alpha_type_name(bitmap.alphaType()));
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_ALPHA, alpha_type_name(bitmap.alphaType()));
|
||||||
// Image will appear to have no uses, TODO(nifong): provide the user with a useful explanation
|
// Image will appear to have no uses, TODO(nifong): provide the user with a useful explanation
|
||||||
|
Loading…
Reference in New Issue
Block a user