Don't make promises about rowbytes
Since we just rely on SkBitmap to manage rowbytes, we don't need to separately track it in the surface. Bug: 1038304 Change-Id: Iea2d486019bf4c5bf4f2a87eabc5f00ad71949fc Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266219 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
cce65006ad
commit
11b05bc11f
@ -55,7 +55,7 @@ public:
|
|||||||
|
|
||||||
Pixel buffer size should be info height times computed rowBytes.
|
Pixel buffer size should be info height times computed rowBytes.
|
||||||
Pixels are not initialized.
|
Pixels are not initialized.
|
||||||
To access pixels after drawing, call flush() or peekPixels().
|
To access pixels after drawing, peekPixels() or readPixels().
|
||||||
|
|
||||||
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
|
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
|
||||||
of raster surface; width and height must be greater than zero
|
of raster surface; width and height must be greater than zero
|
||||||
@ -109,8 +109,7 @@ public:
|
|||||||
info contains SkColorType and SkAlphaType supported by raster surface;
|
info contains SkColorType and SkAlphaType supported by raster surface;
|
||||||
rowBytes is large enough to contain info width pixels of SkColorType, or is zero.
|
rowBytes is large enough to contain info width pixels of SkColorType, or is zero.
|
||||||
|
|
||||||
If rowBytes is not zero, subsequent images returned by makeImageSnapshot()
|
If rowBytes is zero, a suitable value will be chosen internally.
|
||||||
have the same rowBytes.
|
|
||||||
|
|
||||||
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
|
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
|
||||||
of raster surface; width and height must be greater than zero
|
of raster surface; width and height must be greater than zero
|
||||||
|
@ -29,7 +29,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SkBitmap fBitmap;
|
SkBitmap fBitmap;
|
||||||
size_t fRowBytes;
|
|
||||||
bool fWeOwnThePixels;
|
bool fWeOwnThePixels;
|
||||||
|
|
||||||
typedef SkSurface_Base INHERITED;
|
typedef SkSurface_Base INHERITED;
|
||||||
@ -74,7 +73,6 @@ SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t
|
|||||||
: INHERITED(info, props)
|
: INHERITED(info, props)
|
||||||
{
|
{
|
||||||
fBitmap.installPixels(info, pixels, rb, releaseProc, context);
|
fBitmap.installPixels(info, pixels, rb, releaseProc, context);
|
||||||
fRowBytes = 0; // don't need to track the rowbytes
|
|
||||||
fWeOwnThePixels = false; // We are "Direct"
|
fWeOwnThePixels = false; // We are "Direct"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +81,6 @@ SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, sk_sp<SkPixelRef> pr
|
|||||||
: INHERITED(pr->width(), pr->height(), props)
|
: INHERITED(pr->width(), pr->height(), props)
|
||||||
{
|
{
|
||||||
fBitmap.setInfo(info, pr->rowBytes());
|
fBitmap.setInfo(info, pr->rowBytes());
|
||||||
fRowBytes = pr->rowBytes(); // we track this, so that subsequent re-allocs will match
|
|
||||||
fBitmap.setPixelRef(std::move(pr), 0, 0);
|
fBitmap.setPixelRef(std::move(pr), 0, 0);
|
||||||
fWeOwnThePixels = true;
|
fWeOwnThePixels = true;
|
||||||
}
|
}
|
||||||
@ -151,7 +148,6 @@ void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
|
|||||||
SkASSERT(prev.rowBytes() == fBitmap.rowBytes());
|
SkASSERT(prev.rowBytes() == fBitmap.rowBytes());
|
||||||
memcpy(fBitmap.getPixels(), prev.getPixels(), fBitmap.computeByteSize());
|
memcpy(fBitmap.getPixels(), prev.getPixels(), fBitmap.computeByteSize());
|
||||||
}
|
}
|
||||||
SkASSERT(fBitmap.rowBytes() == fRowBytes); // be sure we always use the same value
|
|
||||||
|
|
||||||
// Now fBitmap is a deep copy of itself (and therefore different from
|
// Now fBitmap is a deep copy of itself (and therefore different from
|
||||||
// what is being used by the image. Next we update the canvas to use
|
// what is being used by the image. Next we update the canvas to use
|
||||||
|
Loading…
Reference in New Issue
Block a user