Revert[2] SkDraw and all Blitters to use pixmap instead of bitmapi
This reverts commit b3f0ec9f9967da2f80f0d842cb7fd53617b48de3.
BUG=skia:
Review URL: https://codereview.chromium.org/1168303006
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp
index 21fbcb3..3c7648a 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp
@@ -354,14 +354,12 @@
SkIRect pathBounds = SkIRect::MakeWH(devPathBounds.width(),
devPathBounds.height());
- SkBitmap bmp;
- const SkImageInfo bmImageInfo = SkImageInfo::MakeA8(pathBounds.fRight,
- pathBounds.fBottom);
- if (!bmp.tryAllocPixels(bmImageInfo)) {
+ SkAutoPixmapStorage dst;
+ if (!dst.tryAlloc(SkImageInfo::MakeA8(pathBounds.width(),
+ pathBounds.height()))) {
return false;
}
-
- sk_bzero(bmp.getPixels(), bmp.getSafeSize());
+ sk_bzero(dst.writable_addr(), dst.getSafeSize());
// rasterize path
SkPaint paint;
@@ -388,7 +386,7 @@
draw.fRC = &rasterClip;
draw.fClip = &rasterClip.bwRgn();
draw.fMatrix = &drawMatrix;
- draw.fBitmap = &bmp;
+ draw.fDst = dst;
draw.drawPathCoverage(path, paint);
@@ -400,13 +398,9 @@
SkAutoSMalloc<1024> dfStorage(width * height * sizeof(unsigned char));
// Generate signed distance field
- {
- SkAutoLockPixels alp(bmp);
-
- SkGenerateDistanceFieldFromA8Image((unsigned char*)dfStorage.get(),
- (const unsigned char*)bmp.getPixels(),
- bmp.width(), bmp.height(), bmp.rowBytes());
- }
+ SkGenerateDistanceFieldFromA8Image((unsigned char*)dfStorage.get(),
+ (const unsigned char*)dst.addr(),
+ dst.width(), dst.height(), dst.rowBytes());
// add to atlas
SkIPoint16 atlasLocation;
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index c13d2d8..9b9865e 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -146,7 +146,8 @@
if (kBlitter_CompressionMode == fCompressionMode) {
SkASSERT(fCompressedBuffer.get());
blitter = SkTextureCompressor::CreateBlitterForFormat(
- fBM.width(), fBM.height(), fCompressedBuffer.get(), &allocator, fCompressedFormat);
+ fPixels.width(), fPixels.height(), fCompressedBuffer.get(), &allocator,
+ fCompressedFormat);
}
if (SkRegion::kReplace_Op == op && 0xFF == alpha) {
@@ -202,28 +203,26 @@
}
}
+ sk_bzero(&fDraw, sizeof(fDraw));
+
// If we don't have a custom blitter, then we either need a bitmap to compress
// from or a bitmap that we're going to use as a texture. In any case, we should
// allocate the pixels for a bitmap
const SkImageInfo bmImageInfo = SkImageInfo::MakeA8(cmpWidth, cmpHeight);
if (kBlitter_CompressionMode != fCompressionMode) {
- if (!fBM.tryAllocPixels(bmImageInfo)) {
+ if (!fPixels.tryAlloc(bmImageInfo)) {
return false;
}
-
- sk_bzero(fBM.getPixels(), fBM.getSafeSize());
+ fPixels.erase(0);
} else {
// Otherwise, we just need to remember how big the buffer is...
- fBM.setInfo(bmImageInfo);
+ fPixels.reset(bmImageInfo);
}
-
- sk_bzero(&fDraw, sizeof(fDraw));
-
+ fDraw.fDst = fPixels;
fRasterClip.setRect(bounds);
- fDraw.fRC = &fRasterClip;
- fDraw.fClip = &fRasterClip.bwRgn();
- fDraw.fMatrix = &fMatrix;
- fDraw.fBitmap = &fBM;
+ fDraw.fRC = &fRasterClip;
+ fDraw.fClip = &fRasterClip.bwRgn();
+ fDraw.fMatrix = &fMatrix;
return true;
}
@@ -232,8 +231,8 @@
*/
GrTexture* GrSWMaskHelper::createTexture() {
GrSurfaceDesc desc;
- desc.fWidth = fBM.width();
- desc.fHeight = fBM.height();
+ desc.fWidth = fPixels.width();
+ desc.fHeight = fPixels.height();
desc.fConfig = kAlpha_8_GrPixelConfig;
if (kNone_CompressionMode != fCompressionMode) {
@@ -273,7 +272,8 @@
SkASSERT(GrPixelConfigIsCompressed(desc.fConfig));
SkASSERT(fmt_to_config(fCompressedFormat) == desc.fConfig);
- SkAutoDataUnref cmpData(SkTextureCompressor::CompressBitmapToFormat(fBM, fCompressedFormat));
+ SkAutoDataUnref cmpData(SkTextureCompressor::CompressBitmapToFormat(fPixels,
+ fCompressedFormat));
SkASSERT(cmpData);
this->sendTextureData(texture, desc, cmpData->data(), 0);
@@ -283,17 +283,15 @@
* Move the result of the software mask generation back to the gpu
*/
void GrSWMaskHelper::toTexture(GrTexture *texture) {
- SkAutoLockPixels alp(fBM);
-
GrSurfaceDesc desc;
- desc.fWidth = fBM.width();
- desc.fHeight = fBM.height();
+ desc.fWidth = fPixels.width();
+ desc.fHeight = fPixels.height();
desc.fConfig = texture->config();
// First see if we should compress this texture before uploading.
switch (fCompressionMode) {
case kNone_CompressionMode:
- this->sendTextureData(texture, desc, fBM.getPixels(), fBM.rowBytes());
+ this->sendTextureData(texture, desc, fPixels.addr(), fPixels.rowBytes());
break;
case kCompress_CompressionMode:
@@ -311,10 +309,8 @@
* Convert mask generation results to a signed distance field
*/
void GrSWMaskHelper::toSDF(unsigned char* sdf) {
- SkAutoLockPixels alp(fBM);
-
- SkGenerateDistanceFieldFromA8Image(sdf, (const unsigned char*)fBM.getPixels(),
- fBM.width(), fBM.height(), fBM.rowBytes());
+ SkGenerateDistanceFieldFromA8Image(sdf, (const unsigned char*)fPixels.addr(),
+ fPixels.width(), fPixels.height(), fPixels.rowBytes());
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrSWMaskHelper.h b/src/gpu/GrSWMaskHelper.h
index a69e4be..b90205b 100644
--- a/src/gpu/GrSWMaskHelper.h
+++ b/src/gpu/GrSWMaskHelper.h
@@ -69,7 +69,7 @@
// Reset the internal bitmap
void clear(uint8_t alpha) {
- fBM.eraseColor(SkColorSetARGB(alpha, alpha, alpha, alpha));
+ fPixels.erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF));
}
// Canonical usage utility that draws a single path and uploads it
@@ -105,7 +105,7 @@
GrContext* fContext;
SkMatrix fMatrix;
- SkBitmap fBM;
+ SkAutoPixmapStorage fPixels;
SkDraw fDraw;
SkRasterClip fRasterClip;
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 8bd5b5e..edb887c 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -277,6 +277,15 @@
return fLegacyBitmap;
}
+bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) {
+ DO_DEFERRED_CLEAR();
+ // For compatibility with clients the know we're backed w/ a bitmap, and want to inspect its
+ // genID. When we can hide/remove that fact, we can eliminate this call to notify.
+ // ... ugh.
+ fLegacyBitmap.notifyPixelsChanged();
+ return false;
+}
+
void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) {
INHERITED::onAttachToCanvas(canvas);
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index d1070e5..c06cdc2 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -125,6 +125,7 @@
void onDetachFromCanvas() override;
const SkBitmap& onAccessBitmap() override;
+ bool onAccessPixels(SkPixmap*) override;
bool canHandleImageFilter(const SkImageFilter*) override;
virtual bool filterImage(const SkImageFilter*, const SkBitmap&,