Pass alpha type to GrSurfaceContext::read/writePixels and remove flags.
We deduce whether to premul or unpremul based on the the input/output
alpha types. This means we also now support unpremuling on write and
premuling on read.
Class-ify former struct GrPixelInfo. Remove origin and instead pass a
flip bool to GrConvertPixels.
Unifies read/write methods on GrSurfaceContext via automatic conversion
of SkImageInfo to GrPixelInfo and making GrDirectContext an optional
parameter.
Bug: skia:7580
Change-Id: I42f6997852b4b902fb81264c6de68ca9537606aa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/224281
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 6c22e5c..e4a0fdf 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -265,11 +265,9 @@
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
SkASSERT(surface);
- int bpp = GrColorTypeBytesPerPixel(dstColorType);
- if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height(), bpp,
- &left, &top, &width, &height,
- &buffer,
- &rowBytes)) {
+ auto subRect = SkIRect::MakeXYWH(left, top, width, height);
+ auto bounds = SkIRect::MakeWH(surface->width(), surface->height());
+ if (!bounds.contains(subRect)) {
return false;
}
@@ -293,8 +291,8 @@
if (1 == mipLevelCount) {
// We require that if we are not mipped, then the write region is contained in the surface
- SkIRect subRect = SkIRect::MakeXYWH(left, top, width, height);
- SkIRect bounds = SkIRect::MakeWH(surface->width(), surface->height());
+ auto subRect = SkIRect::MakeXYWH(left, top, width, height);
+ auto bounds = SkIRect::MakeWH(surface->width(), surface->height());
if (!bounds.contains(subRect)) {
return false;
}