Add GrDirectContext arg to SkImage::readPixels
Note: The polarity of the staging flag is inverted from usual because
a G3 dependency with no SkUserConfig.h relies on the legacy API.
Once this lands, we will migrate them and others, then remove the
staging API. The inverted staging flag is kind of nice, actually - I may
use that pattern in the future. It means less total CLs and it's just as
easy to flip the bit on or off during debugging.
Bug: skia:104662
Change-Id: I48cba1eeae3e2e6f79918c6d243e0666e68ec71b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310656
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
diff --git a/docs/examples/Bitmap_writePixels.cpp b/docs/examples/Bitmap_writePixels.cpp
index 19c31c2..be77bf2 100644
--- a/docs/examples/Bitmap_writePixels.cpp
+++ b/docs/examples/Bitmap_writePixels.cpp
@@ -10,7 +10,7 @@
srcPixels.resize(height * width * 4);
SkPixmap pixmap(SkImageInfo::MakeN32Premul(width, height), (const void*) &srcPixels.front(),
width * 4);
- image->readPixels(pixmap, 0, 0);
+ image->readPixels(nullptr, pixmap, 0, 0);
canvas->scale(.5f, .5f);
width /= 4;
height /= 4;
diff --git a/docs/examples/Image_MakeRasterData.cpp b/docs/examples/Image_MakeRasterData.cpp
index 02959d7..bbb513b 100644
--- a/docs/examples/Image_MakeRasterData.cpp
+++ b/docs/examples/Image_MakeRasterData.cpp
@@ -8,7 +8,7 @@
sk_sp<SkData> data = SkData::MakeUninitialized(rowBytes * image->height());
SkImageInfo dstInfo = SkImageInfo::MakeN32(image->width(), image->height(),
kPremul_SkAlphaType);
- image->readPixels(dstInfo, data->writable_data(), rowBytes, 0, 0, SkImage::kAllow_CachingHint);
+ image->readPixels(nullptr, dstInfo, data->writable_data(), rowBytes, 0, 0, SkImage::kAllow_CachingHint);
sk_sp<SkImage> raw = SkImage::MakeRasterData(dstInfo.makeColorType(kRGBA_8888_SkColorType),
data, rowBytes);
canvas->drawImage(image, 0, 0);
diff --git a/docs/examples/Image_readPixels.cpp b/docs/examples/Image_readPixels.cpp
index ebd9349..e3d31c0 100644
--- a/docs/examples/Image_readPixels.cpp
+++ b/docs/examples/Image_readPixels.cpp
@@ -12,7 +12,7 @@
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
for (int y = 0; y < 512; y += height ) {
for (int x = 0; x < 512; x += width ) {
- if (image->readPixels(info, &dstPixels.front(), width * 4, x, y)) {
+ if (image->readPixels(nullptr, info, &dstPixels.front(), width * 4, x, y)) {
SkPixmap dstPixmap(info, &dstPixels.front(), width * 4);
SkBitmap bitmap;
bitmap.installPixels(dstPixmap);
diff --git a/docs/examples/Image_readPixels_2.cpp b/docs/examples/Image_readPixels_2.cpp
index 3a96042..018710e 100644
--- a/docs/examples/Image_readPixels_2.cpp
+++ b/docs/examples/Image_readPixels_2.cpp
@@ -14,7 +14,7 @@
SkPixmap pixmap(SkImageInfo::MakeN32Premul(quarterWidth, quarterHeight),
&srcPixels.front() + x * image->height() * quarterWidth +
y * quarterWidth, rowBytes);
- image->readPixels(pixmap, x * quarterWidth, y * quarterHeight);
+ image->readPixels(nullptr, pixmap, x * quarterWidth, y * quarterHeight);
}
}
canvas->scale(.5f, .5f);
diff --git a/docs/examples/Pixmap_addr.cpp b/docs/examples/Pixmap_addr.cpp
index 171c5fb..8e2fd2a 100644
--- a/docs/examples/Pixmap_addr.cpp
+++ b/docs/examples/Pixmap_addr.cpp
@@ -8,7 +8,7 @@
pixels.resize(image->height() * image->width() * 4);
SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
- image->readPixels(pixmap, 0, 0);
+ image->readPixels(nullptr, pixmap, 0, 0);
SkDebugf("pixels address: 0x%llx\n", pixmap.addr());
SkPixmap inset;
if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) {
diff --git a/docs/examples/Pixmap_extractSubset.cpp b/docs/examples/Pixmap_extractSubset.cpp
index 5ca8223..51e6ed4 100644
--- a/docs/examples/Pixmap_extractSubset.cpp
+++ b/docs/examples/Pixmap_extractSubset.cpp
@@ -8,7 +8,7 @@
pixels.resize(image->height() * image->width() * 4);
SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
- image->readPixels(pixmap, 0, 0);
+ image->readPixels(nullptr, pixmap, 0, 0);
SkPixmap inset;
if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) {
SkBitmap bitmap;
diff --git a/docs/examples/Pixmap_info.cpp b/docs/examples/Pixmap_info.cpp
index 3cdddaa..01d3d28 100644
--- a/docs/examples/Pixmap_info.cpp
+++ b/docs/examples/Pixmap_info.cpp
@@ -8,7 +8,7 @@
pixels.resize(image->height() * image->width() * 4);
SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
- image->readPixels(pixmap, 0, 0);
+ image->readPixels(nullptr, pixmap, 0, 0);
SkPixmap inset;
if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) {
const SkImageInfo& info = inset.info();
diff --git a/docs/examples/Pixmap_readPixels_2.cpp b/docs/examples/Pixmap_readPixels_2.cpp
index eb00616..f08d8f0 100644
--- a/docs/examples/Pixmap_readPixels_2.cpp
+++ b/docs/examples/Pixmap_readPixels_2.cpp
@@ -9,7 +9,7 @@
const int rowBytes = image->width() * 4;
srcPixels.resize(image->height() * rowBytes);
SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes);
- image->readPixels(pixmap, 0, 0);
+ image->readPixels(nullptr, pixmap, 0, 0);
for (int offset : { 32, 64, 96 } ) {
std::vector<int32_t> dstPixels;
dstPixels.resize(image->height() * rowBytes);
diff --git a/docs/examples/Pixmap_readPixels_3.cpp b/docs/examples/Pixmap_readPixels_3.cpp
index 9b8110b..45779e6 100644
--- a/docs/examples/Pixmap_readPixels_3.cpp
+++ b/docs/examples/Pixmap_readPixels_3.cpp
@@ -9,7 +9,7 @@
const int rowBytes = image->width() * 4;
srcPixels.resize(image->height() * rowBytes);
SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes);
- image->readPixels(pixmap, 0, 0);
+ image->readPixels(nullptr, pixmap, 0, 0);
for (int offset : { 32, 64, 96 } ) {
std::vector<int32_t> dstPixels;
dstPixels.resize(image->height() * rowBytes);
diff --git a/docs/examples/Pixmap_readPixels_4.cpp b/docs/examples/Pixmap_readPixels_4.cpp
index fdbc5ff..7645ef4 100644
--- a/docs/examples/Pixmap_readPixels_4.cpp
+++ b/docs/examples/Pixmap_readPixels_4.cpp
@@ -9,7 +9,7 @@
const int rowBytes = image->width() * 4;
srcPixels.resize(image->height() * rowBytes);
SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes);
- image->readPixels(pixmap, 0, 0);
+ image->readPixels(nullptr, pixmap, 0, 0);
for (int index = 0; index < 3; ++index ) {
std::vector<int32_t> dstPixels;
dstPixels.resize(image->height() * rowBytes);
diff --git a/docs/examples/Pixmap_reset_2.cpp b/docs/examples/Pixmap_reset_2.cpp
index fac026e..b143485 100644
--- a/docs/examples/Pixmap_reset_2.cpp
+++ b/docs/examples/Pixmap_reset_2.cpp
@@ -8,7 +8,7 @@
pixels.resize(image->height() * image->width() * 4);
SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
- image->readPixels(pixmap, 0, 0);
+ image->readPixels(nullptr, pixmap, 0, 0);
int x = 0;
for (auto colorType : { kRGBA_8888_SkColorType, kBGRA_8888_SkColorType } ) {
pixmap.reset(SkImageInfo::Make(image->width(), image->height(), colorType,
diff --git a/docs/examples/Pixmap_scalePixels.cpp b/docs/examples/Pixmap_scalePixels.cpp
index 9e57d8e..22c5f4f 100644
--- a/docs/examples/Pixmap_scalePixels.cpp
+++ b/docs/examples/Pixmap_scalePixels.cpp
@@ -9,7 +9,7 @@
int rowBytes = image->width() * 4;
srcPixels.resize(image->height() * rowBytes);
SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes);
- image->readPixels(pixmap, 0, 0);
+ image->readPixels(nullptr, pixmap, 0, 0);
for (int offset : { 32, 64, 96 } ) {
info = SkImageInfo::MakeN32Premul(image->width() + offset, image->height());
rowBytes = info.width() * 4;
diff --git a/docs/examples/Pixmap_writable_addr32.cpp b/docs/examples/Pixmap_writable_addr32.cpp
index 73039c5..41886de 100644
--- a/docs/examples/Pixmap_writable_addr32.cpp
+++ b/docs/examples/Pixmap_writable_addr32.cpp
@@ -8,7 +8,7 @@
pixels.resize(image->height() * image->width() * 4);
SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
- image->readPixels(pixmap, 0, 0);
+ image->readPixels(nullptr, pixmap, 0, 0);
for (int y = 0; y < pixmap.height() / 2; ++y) {
for (int x = 0; x < pixmap.width(); ++x) {
if ((x & 4) == (y & 4)) {