0

Use SkImage factory methods from SkImages namespace

This new namespace will be added in https://skia-review.googlesource.com/c/skia/+/648297

This CL should be landed after that change rolls into
Chrome.

Bug: skia:13983
Change-Id: Idc71962cbd6534d640f5d66c2477b776d5ba149e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4348201
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Giovanni Ortuno Urquidi <ortuno@chromium.org>
Reviewed-by: Calder Kitagawa <ckitagawa@chromium.org>
Commit-Queue: Kevin Lubick <kjlubick@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org>
Reviewed-by: Piotr Bialecki <bialpio@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1121911}
This commit is contained in:
Kevin Lubick
2023-03-24 20:43:03 +00:00
committed by Chromium LUCI CQ
parent 9392005a12
commit 35abb3d4d0
76 changed files with 201 additions and 142 deletions
android_webview/browser/gfx
cc
chrome/browser/ash
chromeos/utils
components
content/browser/android
device/vr/android/arcore
extensions/common
gpu/command_buffer/service
media
pdf/pdfium
third_party/blink/renderer

@ -23,8 +23,9 @@
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkSamplingOptions.h"
#include "third_party/skia/include/gpu/GrTypes.h"
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
#include "third_party/skia/include/gpu/GrTypes.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "third_party/skia/include/gpu/vk/GrVkBackendContext.h"
#include "third_party/skia/include/gpu/vk/GrVkExtensions.h"
#include "third_party/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h"
@ -321,7 +322,7 @@ void VulkanGLInterop::DrawVk(sk_sp<GrVkSecondaryCBDrawContext> draw_context,
// Create an SkImage from AHB.
GrBackendTexture backend_texture(params.width, params.height,
pending_draw->image_info);
pending_draw->ahb_skimage = SkImage::MakeFromTexture(
pending_draw->ahb_skimage = SkImages::BorrowTextureFrom(
vulkan_context_provider_->GetGrContext(), backend_texture,
kBottomLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kPremul_SkAlphaType,
color_space);

@ -1130,12 +1130,13 @@ TEST_F(DiscardableImageMapTest, HighBitDepth) {
nullptr /* color_space */);
bitmap.allocPixels(info);
bitmap.eraseColor(SK_AlphaTRANSPARENT);
PaintImage discardable_image = PaintImageBuilder::WithDefault()
.set_id(PaintImage::GetNextId())
.set_is_high_bit_depth(true)
.set_image(SkImage::MakeFromBitmap(bitmap),
PaintImage::GetNextContentId())
.TakePaintImage();
PaintImage discardable_image =
PaintImageBuilder::WithDefault()
.set_id(PaintImage::GetNextId())
.set_is_high_bit_depth(true)
.set_image(SkImages::RasterFromBitmap(bitmap),
PaintImage::GetNextContentId())
.TakePaintImage();
FakeContentLayerClient content_layer_client;
content_layer_client.set_bounds(visible_rect.size());

@ -23,6 +23,7 @@
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/GrYUVABackendTextures.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "ui/gfx/color_conversion_sk_filter_cache.h"
#include "ui/gfx/hdr_metadata.h"
@ -43,7 +44,7 @@ void ReleaseContext(SkImage::ReleaseContext context) {
// first extracted out of the |plane_images| (and work is flushed on each one).
// Note that we assume that the image is opaque (no alpha plane). Then, a
// SkImage is created out of those textures using the
// SkImage::MakeFromYUVATextures() API. Finally, |image_color_space| is the
// SkImages::TextureFromYUVATextures() API. Finally, |image_color_space| is the
// color space of the resulting image after applying |yuv_color_space|
// (converting from YUV to RGB). This is assumed to be sRGB if nullptr.
//
@ -80,7 +81,7 @@ sk_sp<SkImage> MakeYUVImageFromUploadedPlanes(
GrYUVABackendTextures yuva_backend_textures(
yuva_info, plane_backend_textures.data(), kTopLeft_GrSurfaceOrigin);
Context* ctx = new Context{plane_images};
sk_sp<SkImage> image = SkImage::MakeFromYUVATextures(
sk_sp<SkImage> image = SkImages::TextureFromYUVATextures(
context, yuva_backend_textures, std::move(image_color_space),
ReleaseContext, ctx);
if (!image) {
@ -569,7 +570,8 @@ bool ServiceImageTransferCacheEntry::Deserialize(
return false;
}
sk_sp<SkImage> plane = SkImage::MakeFromRaster(pixmap, nullptr, nullptr);
sk_sp<SkImage> plane =
SkImages::RasterFromPixmap(pixmap, nullptr, nullptr);
if (!plane) {
DLOG(ERROR) << "Failed to create image from plane pixmap";
return false;
@ -598,7 +600,8 @@ bool ServiceImageTransferCacheEntry::Deserialize(
DLOG(ERROR) << "Failed to read pixmap";
return false;
}
rgba_pixmap_image = SkImage::MakeFromRaster(rgba_pixmap, nullptr, nullptr);
rgba_pixmap_image =
SkImages::RasterFromPixmap(rgba_pixmap, nullptr, nullptr);
if (!rgba_pixmap_image) {
DLOG(ERROR) << "Failed to create image from plane pixmap";
return false;
@ -664,7 +667,7 @@ bool ServiceImageTransferCacheEntry::Deserialize(
// a copy of it, because `rgba_pixmap` is directly referencing the transfer
// buffer's memory, and will go away after this this call.
if (image_ == rgba_pixmap_image) {
image_ = SkImage::MakeRasterCopy(rgba_pixmap);
image_ = SkImages::RasterFromPixmapCopy(rgba_pixmap);
if (!image_) {
DLOG(ERROR) << "Failed to create raster copy";
return false;

@ -29,6 +29,7 @@
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/GrTypes.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "ui/gfx/geometry/size.h"
@ -188,7 +189,7 @@ class ImageTransferCacheEntryTest
DCHECK(!allocated_texture.hasMipMaps());
DCHECK(allocated_texture_info.fTarget == GL_TEXTURE_2D);
*released = false;
return SkImage::MakeFromTexture(
return SkImages::BorrowTextureFrom(
gr_context, allocated_texture, kTopLeft_GrSurfaceOrigin,
texture_format == GL_RG8_EXT ? kR8G8_unorm_SkColorType
: kAlpha_8_SkColorType,

@ -40,6 +40,7 @@
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkColorType.h"
#include "third_party/skia/include/core/SkGraphics.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkSurface.h"
@ -89,7 +90,7 @@ sk_sp<SkImage> MakeSkImage(const gfx::Size& size,
green.setColor(SkColors::kGreen);
canvas.drawRect(SkRect::MakeXYWH(10, 20, 30, 40), green);
return SkImage::MakeFromBitmap(bitmap);
return SkImages::RasterFromBitmap(bitmap);
}
constexpr size_t kCacheLimitBytes = 1024 * 1024;
@ -651,7 +652,7 @@ TEST_F(OopPixelTest, DrawHdrImageWithMetadata) {
SkColor4f color{image_pq_pixel, image_pq_pixel, image_pq_pixel, 1.f};
canvas.drawColor(color);
image = SkImage::MakeFromBitmap(bitmap);
image = SkImages::RasterFromBitmap(bitmap);
image = image->reinterpretColorSpace(
SkColorSpace::MakeRGB(pq, SkNamedGamut::kSRGB));
}

@ -23,6 +23,7 @@
#include "cc/paint/scoped_raster_flags.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkScalar.h"
#include "third_party/skia/include/core/SkString.h"
#include "third_party/skia/include/core/SkTileMode.h"
@ -755,9 +756,9 @@ RecordPaintFilter::RecordPaintFilter(PaintRecord record,
int height = SkScalarCeilToInt(record_bounds.height());
SkMatrix originAdjust =
SkMatrix::Translate(-record_bounds.fLeft, -record_bounds.fTop);
auto image = SkImage::MakeFromPicture(
auto image = SkImages::DeferredFromPicture(
std::move(picture), SkISize::Make(width, height), &originAdjust,
nullptr, SkImage::BitDepth::kU8, SkColorSpace::MakeSRGB());
nullptr, SkImages::BitDepth::kU8, SkColorSpace::MakeSRGB());
// Must account for the raster scale when drawing the picture image,
SkRect src = SkRect::MakeWH(record_bounds.width(), record_bounds.height());

@ -110,7 +110,7 @@ PaintImage PaintImage::CreateFromBitmap(SkBitmap bitmap) {
return PaintImageBuilder::WithDefault()
.set_id(PaintImage::GetNextId())
.set_image(SkImage::MakeFromBitmap(bitmap),
.set_image(SkImages::RasterFromBitmap(bitmap),
PaintImage::GetNextContentId())
.TakePaintImage();
}
@ -181,15 +181,15 @@ void PaintImage::CreateSkImage() {
if (sk_image_) {
cached_sk_image_ = sk_image_;
} else if (paint_record_) {
cached_sk_image_ = SkImage::MakeFromPicture(
cached_sk_image_ = SkImages::DeferredFromPicture(
paint_record_->ToSkPicture(gfx::RectToSkRect(paint_record_rect_)),
SkISize::Make(paint_record_rect_.width(), paint_record_rect_.height()),
nullptr, nullptr, SkImage::BitDepth::kU8, SkColorSpace::MakeSRGB());
nullptr, nullptr, SkImages::BitDepth::kU8, SkColorSpace::MakeSRGB());
} else if (paint_image_generator_) {
cached_sk_image_ =
SkImage::MakeFromGenerator(std::make_unique<SkiaPaintImageGenerator>(
paint_image_generator_, kDefaultFrameIndex,
kDefaultGeneratorClientId));
cached_sk_image_ = SkImages::DeferredFromGenerator(
std::make_unique<SkiaPaintImageGenerator>(paint_image_generator_,
kDefaultFrameIndex,
kDefaultGeneratorClientId));
} else if (texture_backing_) {
cached_sk_image_ = texture_backing_->GetAcceleratedSkImage();
}
@ -362,7 +362,7 @@ sk_sp<SkImage> PaintImage::GetSkImageForFrame(
return GetSwSkImage();
sk_sp<SkImage> image =
SkImage::MakeFromGenerator(std::make_unique<SkiaPaintImageGenerator>(
SkImages::DeferredFromGenerator(std::make_unique<SkiaPaintImageGenerator>(
paint_image_generator_, index, client_id));
return image;
}

@ -2743,7 +2743,7 @@ class MockImageProvider : public ImageProvider {
SkBitmap bitmap;
bitmap.allocPixelsFlags(SkImageInfo::MakeN32Premul(10, 10),
SkBitmap::kZeroPixels_AllocFlag);
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
sk_sp<SkImage> image = SkImages::RasterFromBitmap(bitmap);
size_t i = index_++;
return ScopedResult(DecodedDrawImage(image, nullptr, src_rect_offset_[i],
scale_[i], quality_[i], true));

@ -34,6 +34,7 @@
#include "cc/paint/transfer_cache_deserialize_helper.h"
#include "components/crash/core/common/crash_key.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkRRect.h"
#include "third_party/skia/include/core/SkSerialProcs.h"
@ -361,7 +362,7 @@ void PaintOpReader::Read(PaintImage* image) {
*image = PaintImageBuilder::WithDefault()
.set_id(PaintImage::GetNextId())
.set_texture_image(SkImage::MakeRasterCopy(pixmap),
.set_texture_image(SkImages::RasterFromPixmapCopy(pixmap),
PaintImage::kNonLazyStableId)
.TakePaintImage();
}

@ -25,6 +25,7 @@
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkFlattenable.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkM44.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkPath.h"
@ -986,8 +987,8 @@ void PaintOpWriter::Write(const PaintRecord& record,
// Nested records are used for picture shaders and filters. These are always
// converted to a fixed scale mode (hence |post_scale|), which means they are
// first rendered offscreen via SkImage::MakeFromPicture. This inherently does
// not support lcd text, so reflect that in the serialization options.
// first rendered offscreen via SkImages::DeferredFromPicture. This inherently
// does not support lcd text, so reflect that in the serialization options.
PaintOp::SerializeOptions lcd_disabled_options = *options_;
lcd_disabled_options.can_use_lcd_text = false;
SimpleBufferSerializer serializer(memory_, remaining_bytes_,

@ -16,6 +16,7 @@
#include "cc/paint/paint_op_writer.h"
#include "cc/paint/paint_record.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@ -460,10 +461,10 @@ sk_sp<SkShader> PaintShader::GetSkShader(
// For fixed scale, we create an image shader with an image backed by
// the picture.
case ScalingBehavior::kFixedScale: {
auto image = SkImage::MakeFromPicture(
auto image = SkImages::DeferredFromPicture(
sk_cached_picture_,
SkISize::Make(tile_.width(), tile_.height()), nullptr, nullptr,
SkImage::BitDepth::kU8, SkColorSpace::MakeSRGB());
SkImages::BitDepth::kU8, SkColorSpace::MakeSRGB());
return image->makeShader(tx_, ty_, sampling,
base::OptionalToPtr(local_matrix_));
}

@ -50,7 +50,7 @@ class MockImageProvider : public ImageProvider {
SkBitmap bitmap;
bitmap.allocN32Pixels(10, 10);
bitmap.eraseColor(SK_ColorBLACK);
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
sk_sp<SkImage> image = SkImages::RasterFromBitmap(bitmap);
return ScopedResult(DecodedDrawImage(image, nullptr, SkSize::MakeEmpty(),
SkSize::Make(1.0f, 1.0f),
draw_image.filter_quality(), true));

@ -34,7 +34,7 @@ class MockImageProvider : public ImageProvider {
SkBitmap bitmap;
bitmap.allocN32Pixels(10, 10);
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
sk_sp<SkImage> image = SkImages::RasterFromBitmap(bitmap);
return ScopedResult(
DecodedDrawImage(image, nullptr, SkSize::MakeEmpty(),

@ -26,7 +26,7 @@ namespace {
sk_sp<SkImage> CreateRasterImage() {
SkBitmap bitmap;
bitmap.allocN32Pixels(10, 10);
return SkImage::MakeFromBitmap(bitmap);
return SkImages::RasterFromBitmap(bitmap);
}
DecodedDrawImage CreateDecode() {

@ -26,6 +26,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkImageGenerator.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkPixmap.h"
@ -225,7 +226,7 @@ PaintImage CreateBitmapImage(const gfx::Size& size, SkColorType color_type) {
bitmap.eraseColor(SK_AlphaTRANSPARENT);
return PaintImageBuilder::WithDefault()
.set_id(PaintImage::GetNextId())
.set_image(SkImage::MakeFromBitmap(bitmap),
.set_image(SkImages::RasterFromBitmap(bitmap),
PaintImage::GetNextContentId())
.TakePaintImage();
}
@ -289,7 +290,7 @@ PaintImage CreateNonDiscardablePaintImage(const gfx::Size& size) {
return PaintImageBuilder::WithDefault()
.set_id(PaintImage::GetNextId())
.set_texture_image(
SkImage::MakeFromBitmap(bitmap)->makeTextureImage(context.get()),
SkImages::RasterFromBitmap(bitmap)->makeTextureImage(context.get()),
PaintImage::GetNextContentId())
.TakePaintImage();
}

@ -50,6 +50,7 @@
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkPixmap.h"
#include "third_party/skia/include/core/SkRect.h"
@ -60,6 +61,7 @@
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/GrYUVABackendTextures.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/skia_conversions.h"
@ -433,11 +435,12 @@ sk_sp<SkImage> TakeOwnershipOfSkImageBacking(GrDirectContext* context,
}
sk_sp<SkColorSpace> color_space = image->refColorSpace();
GrBackendTexture backend_texture;
SkImage::BackendTextureReleaseProc release_proc;
SkImage::MakeBackendTextureFromSkImage(context, std::move(image),
&backend_texture, &release_proc);
return SkImage::MakeFromTexture(context, backend_texture, origin, color_type,
kPremul_SkAlphaType, std::move(color_space));
SkImages::BackendTextureReleaseProc release_proc;
SkImages::GetBackendTextureFromImage(context, std::move(image),
&backend_texture, &release_proc);
return SkImages::BorrowTextureFrom(context, backend_texture, origin,
color_type, kPremul_SkAlphaType,
std::move(color_space));
}
// Immediately deletes an SkImage, preventing caching of that image. Must be
@ -2200,9 +2203,9 @@ void GpuImageDecodeCache::DecodeImageIfNecessary(
backing_memory->Unlock();
backing_memory.reset();
} else {
image_y = SkImage::MakeFromRaster(pixmap_y, release_proc, nullptr);
image_u = SkImage::MakeFromRaster(pixmap_u, release_proc, nullptr);
image_v = SkImage::MakeFromRaster(pixmap_v, release_proc, nullptr);
image_y = SkImages::RasterFromPixmap(pixmap_y, release_proc, nullptr);
image_u = SkImages::RasterFromPixmap(pixmap_u, release_proc, nullptr);
image_v = SkImages::RasterFromPixmap(pixmap_v, release_proc, nullptr);
}
} else { // RGBX decoding is the default path.
SkPixmap pixmap(image_info, backing_memory->data(),
@ -2212,7 +2215,7 @@ void GpuImageDecodeCache::DecodeImageIfNecessary(
backing_memory->Unlock();
backing_memory.reset();
} else {
image = SkImage::MakeFromRaster(pixmap, release_proc, nullptr);
image = SkImages::RasterFromPixmap(pixmap, release_proc, nullptr);
}
}
}
@ -3236,7 +3239,7 @@ sk_sp<SkImage> GpuImageDecodeCache::CreateImageFromYUVATexturesInternal(
target_color_space = nullptr;
}
sk_sp<SkImage> yuva_image = SkImage::MakeFromYUVATextures(
sk_sp<SkImage> yuva_image = SkImages::TextureFromYUVATextures(
context_->GrContext(), yuva_backend_textures,
std::move(decoded_color_space));
if (target_color_space)

@ -35,7 +35,7 @@ static const int kCacheSize = 128 * 1024 * 1024;
sk_sp<SkImage> CreateImage(int width, int height) {
SkBitmap bitmap;
bitmap.allocPixels(SkImageInfo::MakeS32(width, height, kPremul_SkAlphaType));
return SkImage::MakeFromBitmap(bitmap);
return SkImages::RasterFromBitmap(bitmap);
}
SkM44 CreateMatrix(const SkSize& scale) {

@ -1455,7 +1455,7 @@ TEST_P(GpuImageDecodeCacheTest, GetHdrDecodedImageForDrawToHdr) {
PaintImage image = PaintImageBuilder::WithDefault()
.set_id(PaintImage::kInvalidId)
.set_is_high_bit_depth(true)
.set_image(SkImage::MakeFromBitmap(bitmap),
.set_image(SkImages::RasterFromBitmap(bitmap),
PaintImage::GetNextContentId())
.TakePaintImage();
@ -1509,7 +1509,7 @@ TEST_P(GpuImageDecodeCacheTest, GetHdrDecodedImageForDrawToSdr) {
PaintImage image = PaintImageBuilder::WithDefault()
.set_id(PaintImage::kInvalidId)
.set_is_high_bit_depth(true)
.set_image(SkImage::MakeFromBitmap(bitmap),
.set_image(SkImages::RasterFromBitmap(bitmap),
PaintImage::GetNextContentId())
.TakePaintImage();

@ -30,7 +30,7 @@ static const int kTimeCheckInterval = 10;
sk_sp<SkImage> CreateImage(int width, int height) {
SkBitmap bitmap;
bitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height));
return SkImage::MakeFromBitmap(bitmap);
return SkImages::RasterFromBitmap(bitmap);
}
SkM44 CreateMatrix(const SkSize& scale) {

@ -2029,7 +2029,7 @@ TEST_F(SoftwareImageDecodeCacheTest, HdrDecodeToHdr) {
PaintImage image = PaintImageBuilder::WithDefault()
.set_id(PaintImage::kInvalidId)
.set_is_high_bit_depth(true)
.set_image(SkImage::MakeFromBitmap(bitmap),
.set_image(SkImages::RasterFromBitmap(bitmap),
PaintImage::GetNextContentId())
.TakePaintImage();
@ -2055,7 +2055,7 @@ TEST_F(SoftwareImageDecodeCacheTest, HdrDecodeToSdr) {
PaintImage image = PaintImageBuilder::WithDefault()
.set_id(PaintImage::kInvalidId)
.set_is_high_bit_depth(true)
.set_image(SkImage::MakeFromBitmap(bitmap),
.set_image(SkImages::RasterFromBitmap(bitmap),
PaintImage::GetNextContentId())
.TakePaintImage();

@ -18,6 +18,7 @@
#include "cc/paint/paint_flags.h"
#include "cc/tiles/mipmap_util.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "ui/gfx/geometry/skia_conversions.h"
namespace cc {
@ -327,7 +328,7 @@ SoftwareImageDecodeCacheUtils::CacheEntry::CacheEntry(
tracing_id_(g_next_tracing_id_.GetNext()) {
DCHECK(memory);
SkPixmap pixmap(image_info_, memory->data(), image_info_.minRowBytes());
image_ = SkImage::MakeFromRaster(
image_ = SkImages::RasterFromPixmap(
pixmap, [](const void* pixels, void* context) {}, nullptr);
}

@ -49,6 +49,7 @@
#include "components/viz/test/begin_frame_args_test.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkImageGenerator.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkSurface.h"
@ -3722,7 +3723,7 @@ class HdrImageTileManagerTest : public CheckerImagingTileManagerTest {
PaintImage hdr_image = PaintImageBuilder::WithDefault()
.set_id(PaintImage::kInvalidId)
.set_is_high_bit_depth(true)
.set_image(SkImage::MakeFromBitmap(bitmap),
.set_image(SkImages::RasterFromBitmap(bitmap),
PaintImage::GetNextContentId())
.TakePaintImage();

@ -88,6 +88,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPicture.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "ui/gfx/animation/keyframe/timing_function.h"
@ -8429,7 +8430,7 @@ class LayerTreeHostTestQueueImageDecodeNonLazy : public LayerTreeHostTest {
bitmap_.allocN32Pixels(10, 10);
PaintImage image = PaintImageBuilder::WithDefault()
.set_id(PaintImage::GetNextId())
.set_image(SkImage::MakeFromBitmap(bitmap_),
.set_image(SkImages::RasterFromBitmap(bitmap_),
PaintImage::GetNextContentId())
.TakePaintImage();
auto callback = base::BindOnce(

@ -1410,7 +1410,7 @@ class AppListSortColorOrderBrowserTest : public AppListSortBrowserTest {
gfx::ImageSkia icon;
icon = gfx::ImageSkiaOperations::CreateImageWithCircleBackground(
icon_size / 2, icon_color, icon);
const sk_sp<SkImage> image = SkImage::MakeFromBitmap(*icon.bitmap());
const sk_sp<SkImage> image = SkImages::RasterFromBitmap(*icon.bitmap());
const sk_sp<SkData> png_data(
image->encodeToData(SkEncodedImageFormat::kPNG, /*quality=*/100));
icon_file.Write(0, (const char*)png_data->data(), png_data->size());

@ -56,7 +56,7 @@ std::string ConvertAndEncode(const SkBitmap& bitmap) {
DLOG(WARNING) << "Got an invalid bitmap";
return std::string();
}
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
sk_sp<SkImage> image = SkImages::RasterFromBitmap(bitmap);
sk_sp<SkData> png_data(image->encodeToData(SkEncodedImageFormat::kPNG, 100));
if (!png_data) {
DLOG(WARNING) << "Thumbnail encoding error";

@ -31,7 +31,7 @@ bool AddPdfPage(sk_sp<SkDocument> pdf_doc,
const sk_sp<SkData>& image_data,
bool rotate,
absl::optional<int> dpi) {
const sk_sp<SkImage> image = SkImage::MakeFromEncoded(image_data);
const sk_sp<SkImage> image = SkImages::DeferredFromEncodedData(image_data);
if (!image) {
LOG(ERROR) << "Unable to generate image from encoded image data.";
return false;

@ -92,7 +92,7 @@ sk_sp<const SkPicture> PaintPictureLargeImage(gfx::Size bounds) {
paint.setStyle(SkPaint::kFill_Style);
paint.setColor(SK_ColorRED);
canvas->drawRect(sk_bounds, paint);
canvas->drawImage(SkImage::MakeFromBitmap(bitmap), 0, 0);
canvas->drawImage(SkImages::RasterFromBitmap(bitmap), 0, 0);
return recorder.finishRecordingAsPicture();
}

@ -43,7 +43,7 @@ cc::PaintImage MakeUnaccelerated(const cc::PaintImage& paint_image) {
}
// Make immutable to skip an extra copy.
bitmap.setImmutable();
sk_image = SkImage::MakeFromBitmap(bitmap);
sk_image = SkImages::RasterFromBitmap(bitmap);
}
return cc::PaintImageBuilder::WithDefault()
.set_id(cc::PaintImage::GetNextId())

@ -378,7 +378,7 @@ TEST_P(PaintPreviewRecorderUtilsSerializeAsSkPictureTest,
.set_id(cc::PaintImage::GetNextId())
.set_texture_backing(
sk_sp<FakeTextureBacking>(
new FakeTextureBacking(SkImage::MakeFromBitmap(bitmap))),
new FakeTextureBacking(SkImages::RasterFromBitmap(bitmap))),
cc::PaintImage::GetNextContentId())
.TakePaintImage();
canvas->drawImage(paint_image, 0U, 0U);
@ -405,9 +405,9 @@ TEST_P(PaintPreviewRecorderUtilsSerializeAsSkPictureTest,
bitmap.allocN32Pixels(dimensions.width(), dimensions.height());
SkCanvas sk_canvas(bitmap);
sk_canvas.drawColor(SkColors::kRed);
auto sk_image = SkImage::MakeFromBitmap(bitmap);
auto sk_image = SkImages::RasterFromBitmap(bitmap);
auto data = sk_image->encodeToData();
auto lazy_sk_image = SkImage::MakeFromEncoded(data);
auto lazy_sk_image = SkImages::DeferredFromEncodedData(data);
ASSERT_TRUE(lazy_sk_image->isLazyGenerated());
cc::PaintImage paint_image =
cc::PaintImageBuilder::WithDefault()

@ -181,7 +181,7 @@ TEST(ContextCacheControllerTest, CheckSkiaResourcePurgeAPI) {
auto image_info = SkImageInfo::MakeN32Premul(200, 200);
std::vector<uint8_t> image_data(image_info.computeMinByteSize());
SkPixmap pixmap(image_info, image_data.data(), image_info.minRowBytes());
auto image = SkImage::MakeRasterCopy(pixmap);
auto image = SkImages::RasterFromPixmapCopy(pixmap);
auto image_gpu = image->makeTextureImage(gr_context);
gr_context->flushAndSubmit();
}

@ -9,6 +9,7 @@
#include "components/viz/common/resources/resource_format_utils.h"
#include "components/viz/service/display/shared_bitmap_manager.h"
#include "third_party/skia/include/core/SkImage.h"
namespace viz {
@ -148,7 +149,7 @@ DisplayResourceProviderSoftware::ScopedReadLockSkImage::ScopedReadLockSkImage(
resource_provider->PopulateSkBitmapWithResource(&sk_bitmap, resource,
alpha_type);
sk_bitmap.setImmutable();
sk_image_ = SkImage::MakeFromBitmap(sk_bitmap);
sk_image_ = SkImages::RasterFromBitmap(sk_bitmap);
resource_provider_->resource_sk_images_[resource_id] = sk_image_;
}

@ -37,6 +37,7 @@
#include "skia/ext/opacity_filter_canvas.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkPath.h"
@ -853,7 +854,7 @@ sk_sp<SkShader> SoftwareRenderer::GetBackdropFilterShader(
if (filter_clip.IsEmpty())
return nullptr;
// Crop the source image to the backdrop_filter_bounds.
sk_sp<SkImage> cropped_image = SkImage::MakeFromBitmap(backdrop_bitmap);
sk_sp<SkImage> cropped_image = SkImages::RasterFromBitmap(backdrop_bitmap);
cropped_image =
cropped_image->makeSubset(RectToSkIRect(filter_clip), nullptr);
cropped_image->asLegacyBitmap(&backdrop_bitmap);
@ -913,7 +914,7 @@ sk_sp<SkShader> SoftwareRenderer::GetBackdropFilterShader(
canvas.drawImageRect(filtered_image, src_rect, dst_rect, SkSamplingOptions(),
&paint, SkCanvas::kStrict_SrcRectConstraint);
return SkImage::MakeFromBitmap(bitmap)->makeShader(
return SkImages::RasterFromBitmap(bitmap)->makeShader(
content_tile_mode, content_tile_mode, SkSamplingOptions(),
&filter_backdrop_transform);
}

@ -46,8 +46,10 @@
#include "gpu/vulkan/buildflags.h"
#include "skia/buildflags.h"
#include "skia/ext/legacy_display_globals.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPromiseImageTexture.h"
#include "third_party/skia/include/gpu/GrYUVABackendTextures.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/skia_conversions.h"
@ -454,7 +456,7 @@ void SkiaOutputSurfaceImpl::MakePromiseSkImage(
image_context->mailbox_holder().texture_target,
image_context->ycbcr_info());
FulfillForPlane* fulfill = new FulfillForPlane(impl);
auto image = SkImage::MakePromiseTexture(
auto image = SkImages::PromiseTextureFrom(
gr_context_thread_safe_, backend_format,
gfx::SizeToSkISize(image_context->size()), GrMipMapped::kNo,
image_context->origin(), color_type, image_context->alpha_type(),
@ -483,7 +485,7 @@ void SkiaOutputSurfaceImpl::MakePromiseSkImage(
GrYUVABackendTextureInfo yuva_backend_info(
yuva_info, formats.data(), GrMipmapped::kNo, kTopLeft_GrSurfaceOrigin);
auto image = SkImage::MakePromiseYUVATexture(
auto image = SkImages::PromiseTextureFromYUVA(
gr_context_thread_safe_, yuva_backend_info,
image_context->color_space(), Fulfill, CleanUp, fulfills);
DCHECK(image);
@ -538,7 +540,7 @@ sk_sp<SkImage> SkiaOutputSurfaceImpl::MakePromiseSkImageFromYUV(
GrYUVABackendTextureInfo yuva_backend_info(
yuva_info, formats, GrMipmapped::kNo, kTopLeft_GrSurfaceOrigin);
auto image = SkImage::MakePromiseYUVATexture(
auto image = SkImages::PromiseTextureFromYUVA(
gr_context_thread_safe_, yuva_backend_info, std::move(image_color_space),
Fulfill, CleanUp, fulfills);
DCHECK(image);
@ -793,7 +795,7 @@ sk_sp<SkImage> SkiaOutputSurfaceImpl::MakePromiseSkImageFromRenderPass(
si_format, /*plane_index=*/0, GL_TEXTURE_2D,
/*ycbcr_info=*/absl::nullopt);
FulfillForPlane* fulfill = new FulfillForPlane(image_context.get());
auto image = SkImage::MakePromiseTexture(
auto image = SkImages::PromiseTextureFrom(
gr_context_thread_safe_, backend_format,
gfx::SizeToSkISize(image_context->size()),
mipmap ? GrMipMapped::kYes : GrMipMapped::kNo, image_context->origin(),

@ -24,10 +24,12 @@
#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "gpu/command_buffer/service/shared_image/shared_image_format_utils.h"
#include "third_party/khronos/GLES2/gl2ext.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPixelRef.h"
#include "third_party/skia/include/gpu/GpuTypes.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "ui/gfx/gpu_fence_handle.h"
#include "ui/gfx/presentation_feedback.h"
@ -130,10 +132,10 @@ void FakeSkiaOutputSurface::MakePromiseSkImage(
auto sk_color_type =
ToClosestSkColorType(true /* gpu_compositing */, image_context->format());
image_context->SetImage(
SkImage::MakeFromTexture(gr_context(), backend_texture,
kTopLeft_GrSurfaceOrigin, sk_color_type,
image_context->alpha_type(),
image_context->color_space()),
SkImages::BorrowTextureFrom(gr_context(), backend_texture,
kTopLeft_GrSurfaceOrigin, sk_color_type,
image_context->alpha_type(),
image_context->color_space()),
{backend_texture.getBackendFormat()});
}

@ -437,9 +437,9 @@ bool SynchronousCompositorHost::DemandDrawSw(SkCanvas* canvas,
auto mark_bool = [](const void* pixels, void* context) {
*static_cast<bool*>(context) = true;
};
image = SkImage::MakeFromRaster(pixmap, mark_bool, &pixels_released);
image = SkImages::RasterFromPixmap(pixmap, mark_bool, &pixels_released);
} else {
image = SkImage::MakeRasterCopy(pixmap);
image = SkImages::RasterFromPixmapCopy(pixmap);
}
canvas->drawImage(image, 0, 0);
canvas->restore();

@ -844,7 +844,7 @@ void ArCoreImpl::BuildImageDatabase(
kOpaque_SkAlphaType),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas gray_canvas(canvas_bitmap);
sk_sp<SkImage> src_image = SkImage::MakeFromBitmap(src_bitmap);
sk_sp<SkImage> src_image = SkImages::RasterFromBitmap(src_bitmap);
gray_canvas.drawImage(src_image, 0, 0);
SkPixmap gray_pixmap;
if (!gray_canvas.peekPixels(&gray_pixmap)) {

@ -139,7 +139,7 @@ bool RenderIconForVisibilityAnalysis(const SkBitmap& icon,
}
rendered_icon->eraseColor(background_color);
SkCanvas offscreen(*rendered_icon, SkSurfaceProps{});
offscreen.drawImage(SkImage::MakeFromBitmap(icon), 0, 0);
offscreen.drawImage(SkImages::RasterFromBitmap(icon), 0, 0);
offscreen.drawColor(background_color, SkBlendMode::kDifference);
return true;

@ -19,6 +19,7 @@
#include "skia/ext/rgba_to_yuva.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPromiseImageTexture.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkSurface.h"
@ -27,6 +28,7 @@
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/GrYUVABackendTextures.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
namespace gpu {
@ -473,7 +475,7 @@ base::expected<void, GLError> CopySharedImageHelper::ConvertYUVAMailboxesToRGB(
src_yuv_color_space);
GrYUVABackendTextures yuva_backend_textures(yuva_info, yuva_textures.data(),
kTopLeft_GrSurfaceOrigin);
auto result_image = SkImage::MakeFromYUVATextures(
auto result_image = SkImages::TextureFromYUVATextures(
shared_context_state_->gr_context(), yuva_backend_textures,
src_rgb_color_space);
if (!result_image) {

@ -74,7 +74,7 @@ TEST_F(GrCacheControllerTest, PurgeGrCache) {
SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
ASSERT_TRUE(bm.tryAllocPixels(info));
sk_sp<SkImage> uploaded =
SkImage::MakeFromBitmap(bm)->makeTextureImage(gr_context());
SkImages::RasterFromBitmap(bm)->makeTextureImage(gr_context());
ASSERT_TRUE(uploaded);
}
EXPECT_GT(gr_context()->getResourceCachePurgeableBytes(), 0u);
@ -96,7 +96,7 @@ TEST_F(GrCacheControllerTest, ResetPurgeGrCacheOnReuse) {
SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
ASSERT_TRUE(bm.tryAllocPixels(info));
sk_sp<SkImage> uploaded =
SkImage::MakeFromBitmap(bm)->makeTextureImage(gr_context());
SkImages::RasterFromBitmap(bm)->makeTextureImage(gr_context());
ASSERT_TRUE(uploaded);
}
EXPECT_GT(gr_context()->getResourceCachePurgeableBytes(), 0u);

@ -34,6 +34,7 @@
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPromiseImageTexture.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/gpu_memory_buffer.h"
@ -483,7 +484,7 @@ class D3DImageBackingFactoryTest : public D3DImageBackingFactoryTestBase {
EXPECT_EQ(size.height(), backend_texture.height());
// Create an Sk Image from GrBackendTexture.
auto sk_image = SkImage::MakeFromTexture(
auto sk_image = SkImages::BorrowTextureFrom(
gr_context(), backend_texture, kTopLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType, kOpaque_SkAlphaType, nullptr);
@ -2277,7 +2278,7 @@ TEST_F(D3DImageBackingFactoryTest, MultiplanarUploadAndReadback) {
GrBackendTexture backend_texture = dest_surface->getBackendTexture(
SkSurface::kFlushWrite_BackendHandleAccess);
auto dst_image = SkImage::MakeFromTexture(
auto dst_image = SkImages::BorrowTextureFrom(
context_state_->gr_context(), backend_texture, kTopLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType, alpha_type, nullptr);
ASSERT_TRUE(dst_image);

@ -29,9 +29,11 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPromiseImageTexture.h"
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/color_space.h"
#include "ui/gl/buffer_format_utils.h"
@ -175,7 +177,7 @@ class EGLImageBackingFactoryThreadSafeTest
EXPECT_EQ(size.height(), backend_texture.height());
// Create an Sk Image from GrBackendTexture.
auto sk_image = SkImage::MakeFromTexture(
auto sk_image = SkImages::BorrowTextureFrom(
context_state_->gr_context(), backend_texture, kTopLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType, kOpaque_SkAlphaType, nullptr);

@ -30,6 +30,7 @@
#include "third_party/skia/include/core/SkPromiseImageTexture.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "ui/gl/buildflags.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface.h"
@ -245,7 +246,7 @@ TEST_F(ExternalVkImageBackingFactoryDawnTest, DawnWrite_SkiaVulkanRead) {
EXPECT_EQ(size.height(), backend_texture.height());
// Create an Sk Image from GrBackendTexture.
auto sk_image = SkImage::MakeFromTexture(
auto sk_image = SkImages::BorrowTextureFrom(
gr_context(), backend_texture, kTopLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType, kOpaque_SkAlphaType, nullptr);
EXPECT_TRUE(sk_image);

@ -28,6 +28,7 @@
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "ui/gl/buildflags.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface.h"
@ -124,7 +125,7 @@ class IOSurfaceImageBackingFactoryTest : public testing::Test {
EXPECT_EQ(size.height(), backend_texture.height());
// Create an Sk Image from GrBackendTexture.
auto sk_image = SkImage::MakeFromTexture(
auto sk_image = SkImages::BorrowTextureFrom(
gr_context(), backend_texture, kTopLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType, kOpaque_SkAlphaType, nullptr);

@ -12,10 +12,12 @@
#include "gpu/command_buffer/service/shared_image/shared_image_format_utils.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPromiseImageTexture.h"
#include "third_party/skia/include/gpu/GrBackendSurfaceMutableState.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/GrYUVABackendTextures.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "ui/gl/gl_fence.h"
namespace gpu {
@ -283,7 +285,7 @@ sk_sp<SkImage> SkiaImageRepresentation::ScopedReadAccess::CreateSkImage(
auto alpha_type = representation()->alpha_type();
auto color_type =
viz::ToClosestSkColorType(/*gpu_compositing=*/true, format);
return SkImage::MakeFromTexture(
return SkImages::BorrowTextureFrom(
context, promise_image_texture()->backendTexture(), surface_origin,
color_type, alpha_type, sk_color_space, texture_release_proc,
release_context);
@ -307,9 +309,9 @@ sk_sp<SkImage> SkiaImageRepresentation::ScopedReadAccess::CreateSkImage(
ToSkYUVASubsampling(format), yuv_color_space);
GrYUVABackendTextures yuva_backend_textures(yuva_info, yuva_textures.data(),
surface_origin);
return SkImage::MakeFromYUVATextures(context, yuva_backend_textures,
sk_color_space, texture_release_proc,
release_context);
return SkImages::TextureFromYUVATextures(
context, yuva_backend_textures, sk_color_space, texture_release_proc,
release_context);
}
}
@ -325,7 +327,7 @@ sk_sp<SkImage> SkiaImageRepresentation::ScopedReadAccess::CreateSkImageForPlane(
auto alpha_type = SkAlphaType::kOpaque_SkAlphaType;
auto color_type =
viz::ToClosestSkColorType(/*gpu_compositing=*/true, format, plane_index);
return SkImage::MakeFromTexture(
return SkImages::BorrowTextureFrom(
context, promise_image_texture(plane_index)->backendTexture(),
surface_origin, color_type, alpha_type, /*sk_color_space=*/nullptr);
}

@ -9,8 +9,10 @@
#include "gpu/command_buffer/service/shared_image/shared_image_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPromiseImageTexture.h"
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "ui/gfx/geometry/size.h"
namespace gpu {
@ -41,7 +43,7 @@ std::vector<uint8_t> ReadPixels(
EXPECT_EQ(size.height(), backend_texture.height());
// Create an Sk Image from GrBackendTexture.
auto sk_image = SkImage::MakeFromTexture(
auto sk_image = SkImages::BorrowTextureFrom(
context_state->gr_context(), promise_texture->backendTexture(),
kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kOpaque_SkAlphaType,
nullptr);

@ -24,8 +24,10 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkColorType.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPromiseImageTexture.h"
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_surface.h"
@ -226,7 +228,7 @@ TEST_P(WrappedSkImageBackingFactoryTest, Upload) {
// Readback via Skia API and verify it's the same pixels that were uploaded.
SkColorType color_type = ToClosestSkColorType(true, format, plane);
auto sk_image = SkImage::MakeFromTexture(
auto sk_image = SkImages::BorrowTextureFrom(
context_state_->gr_context(), promise_texture->backendTexture(),
kSurfaceOrigin, color_type, kAlphaType, nullptr);
ASSERT_TRUE(sk_image);

@ -26,6 +26,8 @@ typedef unsigned int GLenum;
typedef unsigned int GLuint;
class GrBackendTexture;
class GrContextThreadSafeProxy;
class SkImage;
namespace gfx {
class Size;

@ -31,6 +31,7 @@
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkYUVAPixmaps.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "ui/gfx/gpu_memory_buffer.h"
@ -154,13 +155,13 @@ bool ReadbackTexturePlaneToMemorySyncSkImage(const VideoFrame& src_frame,
gl_texture_info.fFormat = texture_format;
GrBackendTexture texture(width, height, GrMipMapped::kNo, gl_texture_info);
auto image =
SkImage::MakeFromTexture(gr_context, texture,
src_frame.metadata().texture_origin_is_top_left
? kTopLeft_GrSurfaceOrigin
: kBottomLeft_GrSurfaceOrigin,
sk_color_type, sk_alpha_type,
/*colorSpace=*/nullptr);
auto image = SkImages::BorrowTextureFrom(
gr_context, texture,
src_frame.metadata().texture_origin_is_top_left
? kTopLeft_GrSurfaceOrigin
: kBottomLeft_GrSurfaceOrigin,
sk_color_type, sk_alpha_type,
/*colorSpace=*/nullptr);
if (!image) {
DLOG(ERROR) << "Can't create SkImage from texture plane " << src_plane;
return false;

@ -44,6 +44,7 @@
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/skia_conversions.h"
@ -203,7 +204,7 @@ sk_sp<SkImage> WrapGLTexture(
texture_info.fFormat = GL_RGBA8_OES;
GrBackendTexture backend_texture(size.width(), size.height(),
GrMipMapped::kNo, texture_info);
return SkImage::MakeFromAdoptedTexture(
return SkImages::AdoptTextureFrom(
raster_context_provider->GrContext(), backend_texture,
texture_origin_is_top_left ? kTopLeft_GrSurfaceOrigin
: kBottomLeft_GrSurfaceOrigin,
@ -911,8 +912,8 @@ class VideoTextureBacking : public cc::TextureBacking {
DLOG(ERROR) << "VideoTextureBacking::GetSkImageViaReadback failed.";
return nullptr;
}
return SkImage::MakeRasterData(sk_image_info_, std::move(image_pixels),
sk_image_info_.minRowBytes());
return SkImages::RasterFromData(sk_image_info_, std::move(image_pixels),
sk_image_info_.minRowBytes());
}
bool readPixels(const SkImageInfo& dst_info,

@ -20,6 +20,7 @@
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "ui/gfx/gpu_memory_buffer.h"
namespace {
@ -67,7 +68,7 @@ class ScopedAcceleratedSkImage {
SkColorType color_type = viz::ResourceFormatToClosestSkColorType(
/*gpu_compositing=*/true, format);
sk_sp<SkImage> sk_image = SkImage::MakeFromTexture(
sk_sp<SkImage> sk_image = SkImages::BorrowTextureFrom(
gr_context, backend_texture, surface_origin, color_type,
kOpaque_SkAlphaType, color_space.ToSkColorSpace());
if (!sk_image) {

@ -19,6 +19,7 @@
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkYUVAPixmaps.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
namespace media {
@ -199,8 +200,8 @@ sk_sp<SkImage> VideoFrameYUVMailboxesHolder::VideoFrameToSkImage(
: video_frame->ColorSpace().GetAsFullRangeRGB().ToSkColorSpace();
DCHECK(yuva_backend_textures.isValid());
auto result = SkImage::MakeFromYUVATextures(gr_context, yuva_backend_textures,
rgb_color_space);
auto result = SkImages::TextureFromYUVATextures(
gr_context, yuva_backend_textures, rgb_color_space);
DCHECK(result);
return result;
}

@ -874,7 +874,7 @@ class PDFiumPageThumbnailTest : public PDFiumTestBase {
ASSERT_GT(stride, 0);
ASSERT_EQ(image_info.minRowBytes(), static_cast<size_t>(stride));
std::vector<uint8_t> data = thumbnail.TakeData();
sk_sp<SkImage> image = SkImage::MakeRasterCopy(
sk_sp<SkImage> image = SkImages::RasterFromPixmapCopy(
SkPixmap(image_info, data.data(), image_info.minRowBytes()));
ASSERT_TRUE(image);

@ -112,7 +112,7 @@ ChildFrameCompositingHelper::PaintContentsToDisplayList() {
auto image = cc::PaintImageBuilder::WithDefault()
.set_id(cc::PaintImage::GetNextId())
.set_image(SkImage::MakeFromBitmap(*sad_bitmap),
.set_image(SkImages::RasterFromBitmap(*sad_bitmap),
cc::PaintImage::GetNextContentId())
.TakePaintImage();
display_list->push<cc::DrawImageOp>(image, x, y);

@ -46,6 +46,7 @@
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_std.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkSwizzle.h"
@ -340,8 +341,8 @@ scoped_refptr<StaticBitmapImage> ScaleImage(
resized_pixmap.setColorSpace(GetSkImageInfo(image).refColorSpace());
auto resized_sk_image =
SkImage::MakeRasterData(resized_pixmap.info(), std::move(image_pixels),
resized_pixmap.rowBytes());
SkImages::RasterFromData(resized_pixmap.info(), std::move(image_pixels),
resized_pixmap.rowBytes());
if (!resized_sk_image)
return nullptr;
return UnacceleratedStaticBitmapImage::Create(
@ -593,7 +594,7 @@ ImageBitmap::ImageBitmap(ImageElementBase* image,
paint_image = PaintImageBuilder::WithDefault()
.set_id(paint_image.stable_id())
.set_image(SkImage::MakeFromBitmap(bitmap),
.set_image(SkImages::RasterFromBitmap(bitmap),
paint_image.GetContentIdForFrame(0u))
.TakePaintImage();
}
@ -693,7 +694,7 @@ ImageBitmap::ImageBitmap(OffscreenCanvas* offscreen_canvas,
ImageBitmap::ImageBitmap(const SkPixmap& pixmap,
bool is_image_bitmap_origin_clean,
ImageOrientationEnum image_orientation) {
sk_sp<SkImage> raster_copy = SkImage::MakeRasterCopy(pixmap);
sk_sp<SkImage> raster_copy = SkImages::RasterFromPixmapCopy(pixmap);
if (!raster_copy)
return;
image_ = UnacceleratedStaticBitmapImage::Create(std::move(raster_copy));

@ -20,6 +20,7 @@
#include "third_party/blink/renderer/platform/graphics/image_data_buffer.h"
#include "third_party/blink/renderer/platform/wtf/text/base64.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/skia/include/core/SkImage.h"
#include "ui/gfx/geometry/size.h"
namespace blink {
@ -55,7 +56,7 @@ bool EncodeAsImage(char* body,
Vector<unsigned char> pixel_storage(
base::checked_cast<wtf_size_t>(info.computeByteSize(row_bytes)));
SkPixmap pixmap(info, pixel_storage.data(), row_bytes);
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
sk_sp<SkImage> image = SkImages::RasterFromBitmap(bitmap);
if (!image || !image->readPixels(pixmap, 0, 0))
return false;

@ -13,6 +13,7 @@
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h"
#include "third_party/blink/renderer/platform/blob/blob_data.h"
#include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h"
#include "third_party/skia/include/core/SkImage.h"
namespace blink {
@ -115,7 +116,7 @@ BlinkTransferableMessage& BlinkTransferableMessage::operator=(
scoped_refptr<StaticBitmapImage> ToStaticBitmapImage(
const SkBitmap& sk_bitmap) {
sk_sp<SkImage> image = SkImage::MakeFromBitmap(sk_bitmap);
sk_sp<SkImage> image = SkImages::RasterFromBitmap(sk_bitmap);
if (!image)
return nullptr;

@ -166,7 +166,7 @@ TEST(DragImageTest, InterpolationNone) {
test_bitmap.eraseArea(SkIRect::MakeXYWH(1, 1, 1, 1), 0xFFFFFFFF);
scoped_refptr<TestImage> test_image =
TestImage::Create(SkImage::MakeFromBitmap(test_bitmap));
TestImage::Create(SkImages::RasterFromBitmap(test_bitmap));
std::unique_ptr<DragImage> drag_image = DragImage::Create(
test_image.get(), kRespectImageOrientation, kInterpolationNone);
ASSERT_TRUE(drag_image);

@ -145,6 +145,7 @@
#include "third_party/blink/renderer/platform/text/text_direction.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/skia/include/core/SkImage.h"
#include "ui/accessibility/ax_common.h"
#include "ui/accessibility/ax_role_properties.h"
#include "ui/events/keycodes/dom/dom_code.h"
@ -2628,8 +2629,9 @@ String AXNodeObject::ImageDataUrl(const gfx::Size& max_size) const {
Vector<char> pixel_storage(
base::checked_cast<wtf_size_t>(info.computeByteSize(row_bytes)));
SkPixmap pixmap(info, pixel_storage.data(), row_bytes);
if (!SkImage::MakeFromBitmap(bitmap)->readPixels(pixmap, 0, 0))
if (!SkImages::RasterFromBitmap(bitmap)->readPixels(pixmap, 0, 0)) {
return String();
}
// Encode as a PNG and return as a data url.
std::unique_ptr<ImageDataBuffer> buffer = ImageDataBuffer::Create(pixmap);

@ -52,7 +52,7 @@ void ImageBitmapRenderingContextBase::ResetInternalBitmapToBlackTransparent(
SkBitmap black_bitmap;
if (black_bitmap.tryAllocN32Pixels(width, height)) {
black_bitmap.eraseARGB(0, 0, 0, 0);
auto image = SkImage::MakeFromBitmap(black_bitmap);
auto image = SkImages::RasterFromBitmap(black_bitmap);
if (image) {
image_layer_bridge_->SetImage(
UnacceleratedStaticBitmapImage::Create(image));

@ -106,7 +106,7 @@ class CanvasCaptureHandlerTest
testBitmap.allocPixels(info);
testBitmap.eraseARGB(opaque ? 255 : kTestAlphaValue, 30, 60, 200);
return UnacceleratedStaticBitmapImage::Create(
SkImage::MakeFromBitmap(testBitmap));
SkImages::RasterFromBitmap(testBitmap));
}
void OnVerifyDeliveredFrame(

@ -16,6 +16,7 @@
#include "third_party/blink/renderer/platform/image-decoders/segment_reader.h"
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkYUVAPixmaps.h"
namespace blink {
@ -213,7 +214,7 @@ std::unique_ptr<ImageDecoderCore::ImageDecodeResult> ImageDecoderCore::Decode(
// Prefer FinalizePixelsAndGetImage() since that will mark the underlying
// bitmap as immutable, which allows copies to be avoided.
auto sk_image = is_complete ? image->FinalizePixelsAndGetImage()
: SkImage::MakeFromBitmap(image->Bitmap());
: SkImages::RasterFromBitmap(image->Bitmap());
if (!sk_image) {
NOTREACHED() << "Failed to retrieve SkImage for decoded image.";
result->status = Status::kDecodeError;

@ -134,6 +134,7 @@
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
#include "third_party/skia/include/core/SkImage.h"
#include "ui/gfx/geometry/size.h"
// Populates parameters from texImage2D except for border, width, height, and
@ -5632,7 +5633,7 @@ void WebGLRenderingContextBase::TexImageHelperImageData(TexImageParams params,
}
auto pixmap = pixels->GetSkPixmap();
auto image = SkImage::MakeFromRaster(pixmap, nullptr, nullptr);
auto image = SkImages::RasterFromPixmap(pixmap, nullptr, nullptr);
TexImageSkImage(params, std::move(image), /*image_has_flip_y=*/false);
}

@ -27,6 +27,7 @@
#include "third_party/blink/renderer/platform/graphics/gpu/webgpu_texture_alpha_clearer.h"
#include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/skia/include/core/SkImage.h"
namespace blink {
@ -267,7 +268,7 @@ ImageBitmap* GPUCanvasContext::TransferToImageBitmap(
return MakeGarbageCollected<ImageBitmap>(
UnacceleratedStaticBitmapImage::Create(
SkImage::MakeFromBitmap(black_bitmap)));
SkImages::RasterFromBitmap(black_bitmap)));
};
// If the canvas configuration is invalid, WebGPU requires that we give a

@ -27,6 +27,7 @@
#include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
namespace blink {
@ -339,7 +340,7 @@ void AcceleratedStaticBitmapImage::InitializeTextureBacking(
release_ctx->texture_id = shared_context_texture_id;
release_ctx->context_provider_wrapper = context_provider_wrapper;
sk_sp<SkImage> sk_image = SkImage::MakeFromTexture(
sk_sp<SkImage> sk_image = SkImages::BorrowTextureFrom(
shared_gr_context, backend_texture, origin, sk_image_info_.colorType(),
sk_image_info_.alphaType(), sk_image_info_.refColorSpace(),
&ReleaseTexture, release_ctx);

@ -216,7 +216,7 @@ sk_sp<SkImage> HibernationHandler::GetImage() {
base::TimeTicks before = base::TimeTicks::Now();
// Note: not discarding the encoded image.
auto image = SkImage::MakeFromEncoded(encoded_)->makeRasterImage();
auto image = SkImages::DeferredFromEncodedData(encoded_)->makeRasterImage();
base::TimeTicks after = base::TimeTicks::Now();
UMA_HISTOGRAM_TIMES(
"Blink.Canvas.2DLayerBridge.Compression.DecompressionTime",

@ -74,6 +74,7 @@
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
@ -163,7 +164,7 @@ class ImageTrackingDecodeCache : public cc::StubDecodeCache {
SkBitmap bitmap;
bitmap.allocPixelsFlags(SkImageInfo::MakeN32Premul(10, 10),
SkBitmap::kZeroPixels_AllocFlag);
sk_sp<SkImage> sk_image = SkImage::MakeFromBitmap(bitmap);
sk_sp<SkImage> sk_image = SkImages::RasterFromBitmap(bitmap);
return cc::DecodedDrawImage(
sk_image, nullptr, SkSize::Make(0, 0), SkSize::Make(1, 1),
cc::PaintFlags::FilterQuality::kLow, !budget_exceeded_);

@ -39,6 +39,7 @@
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_gpu.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/color_space.h"
@ -301,7 +302,7 @@ scoped_refptr<StaticBitmapImage> CanvasResourceSharedBitmap::Bitmap() {
SkPixmap pixmap(image_info, shared_mapping_.memory(),
image_info.minRowBytes());
AddRef();
sk_sp<SkImage> sk_image = SkImage::MakeFromRaster(
sk_sp<SkImage> sk_image = SkImages::RasterFromPixmap(
pixmap,
[](const void*, SkImage::ReleaseContext resource_to_unref) {
static_cast<CanvasResourceSharedBitmap*>(resource_to_unref)->Release();
@ -644,7 +645,7 @@ scoped_refptr<StaticBitmapImage> CanvasResourceRasterSharedImage::Bitmap() {
SkPixmap pixmap(CreateSkImageInfo(), gpu_memory_buffer_->memory(0),
gpu_memory_buffer_->stride(0));
auto sk_image = SkImage::MakeRasterCopy(pixmap);
auto sk_image = SkImages::RasterFromPixmapCopy(pixmap);
gpu_memory_buffer_->Unmap();
return sk_image ? UnacceleratedStaticBitmapImage::Create(sk_image)
: nullptr;

@ -19,9 +19,10 @@ namespace blink {
namespace {
sk_sp<SkImage> CreateFrameAtIndex(DeferredImageDecoder* decoder, size_t index) {
return SkImage::MakeFromGenerator(std::make_unique<SkiaPaintImageGenerator>(
decoder->CreateGenerator(), index,
cc::PaintImage::kDefaultGeneratorClientId));
return SkImages::DeferredFromGenerator(
std::make_unique<SkiaPaintImageGenerator>(
decoder->CreateGenerator(), index,
cc::PaintImage::kDefaultGeneratorClientId));
}
} // namespace

@ -30,6 +30,7 @@
#include "third_party/blink/renderer/platform/graphics/paint/paint_canvas.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_record.h"
#include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/effects/SkColorMatrixFilter.h"
#include "third_party/skia/include/effects/SkTableColorFilter.h"
#include "ui/gfx/geometry/skia_conversions.h"
@ -132,7 +133,7 @@ sk_sp<PaintFilter> BuildBoxReflectFilter(const BoxReflection& reflection,
canvas.drawPicture(std::move(mask_record));
PaintImage image = PaintImageBuilder::WithDefault()
.set_id(PaintImage::GetNextId())
.set_image(SkImage::MakeFromBitmap(bitmap),
.set_image(SkImages::RasterFromBitmap(bitmap),
PaintImage::GetNextContentId())
.TakePaintImage();

@ -69,6 +69,7 @@
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPixmap.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
@ -464,7 +465,7 @@ DrawingBuffer::GetUnacceleratedStaticBitmapImage(bool flip_y) {
if (!bitmap.tryAllocN32Pixels(size_.width(), size_.height()))
return nullptr;
ReadFramebufferIntoBitmapPixels(static_cast<uint8_t*>(bitmap.getPixels()));
auto sk_image = SkImage::MakeFromBitmap(bitmap);
auto sk_image = SkImages::RasterFromBitmap(bitmap);
bool origin_top_left =
flip_y ? opengl_flip_y_extension_ : !opengl_flip_y_extension_;
@ -698,7 +699,7 @@ scoped_refptr<StaticBitmapImage> DrawingBuffer::TransferToStaticBitmapImage() {
if (!black_bitmap.tryAllocN32Pixels(size_.width(), size_.height()))
return nullptr;
black_bitmap.eraseARGB(0, 0, 0, 0);
sk_sp<SkImage> black_image = SkImage::MakeFromBitmap(black_bitmap);
sk_sp<SkImage> black_image = SkImages::RasterFromBitmap(black_bitmap);
if (!black_image)
return nullptr;
return UnacceleratedStaticBitmapImage::Create(black_image);

@ -3809,7 +3809,7 @@ WebGLImageConversion::ImageExtractor::ImageExtractor(
// TODO(fmalita): Partial frames are not supported currently: only fully
// decoded frames make it through. We could potentially relax this and
// use SkImage::MakeFromBitmap(bitmap) to make a copy.
// use SkImages::RasterFromBitmap(bitmap) to make a copy.
skia_image = frame->FinalizePixelsAndGetImage();
}
}

@ -42,6 +42,7 @@
#include "third_party/blink/renderer/platform/wtf/text/base64.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkSwizzle.h"
#include "third_party/skia/include/encode/SkJpegEncoder.h"
@ -94,7 +95,7 @@ ImageDataBuffer::ImageDataBuffer(scoped_refptr<StaticBitmapImage> image) {
return;
}
MSAN_CHECK_MEM_IS_INITIALIZED(pixmap_.addr(), pixmap_.computeByteSize());
retained_image_ = SkImage::MakeRasterData(info, std::move(data), rowBytes);
retained_image_ = SkImages::RasterFromData(info, std::move(data), rowBytes);
} else {
retained_image_ = paint_image.GetSwSkImage();
if (!retained_image_->peekPixels(&pixmap_))

@ -8,6 +8,7 @@
#include "third_party/blink/renderer/platform/graphics/mailbox_ref.h"
#include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h"
#include "third_party/blink/renderer/platform/graphics/web_graphics_context_3d_provider_wrapper.h"
#include "third_party/skia/include/core/SkImage.h"
namespace blink {
@ -76,8 +77,8 @@ sk_sp<SkImage> MailboxTextureBacking::GetSkImageViaReadback() {
static_cast<GLuint>(sk_image_info_.minRowBytes()),
0, 0, /*plane_index=*/0, writable_pixels);
return SkImage::MakeRasterData(sk_image_info_, std::move(image_pixels),
sk_image_info_.minRowBytes());
return SkImages::RasterFromData(sk_image_info_, std::move(image_pixels),
sk_image_info_.minRowBytes());
} else if (sk_image_) {
return sk_image_->makeNonTextureImage();
}

@ -32,7 +32,7 @@ scoped_refptr<StaticBitmapImage> StaticBitmapImage::Create(
const SkImageInfo& info,
ImageOrientation orientation) {
return UnacceleratedStaticBitmapImage::Create(
SkImage::MakeRasterData(info, std::move(data), info.minRowBytes()),
SkImages::RasterFromData(info, std::move(data), info.minRowBytes()),
orientation);
}

@ -141,7 +141,7 @@ bool ImageFrame::AllocatePixelData(int new_width,
sk_sp<SkImage> ImageFrame::FinalizePixelsAndGetImage() {
DCHECK_EQ(kFrameComplete, status_);
bitmap_.setImmutable();
return SkImage::MakeFromBitmap(bitmap_);
return SkImages::RasterFromBitmap(bitmap_);
}
void ImageFrame::SetHasAlpha(bool alpha) {
@ -188,7 +188,7 @@ static void BlendRGBAF16Buffer(ImageFrame::PixelDataF16* dst,
SkPixmap src_pixmap(info.makeAlphaType(kUnpremul_SkAlphaType), src,
info.minRowBytes());
sk_sp<SkImage> src_image =
SkImage::MakeFromRaster(src_pixmap, nullptr, nullptr);
SkImages::RasterFromPixmap(src_pixmap, nullptr, nullptr);
surface->getCanvas()->drawImage(src_image, 0, 0);
surface->flushAndSubmit();

@ -147,7 +147,7 @@ class PLATFORM_EXPORT ImageFrame final {
// Create SkImage from Bitmap() and return it. This should be called only
// if frame is complete. The bitmap is set immutable before creating
// SkImage to avoid copying bitmap in SkImage::MakeFromBitmap(bitmap_).
// SkImage to avoid copying bitmap in SkImages::RasterFromBitmap(bitmap_).
sk_sp<SkImage> FinalizePixelsAndGetImage();
// Returns true if the pixels changed, but the bitmap has not yet been