Alter SkCanvas::drawPicture (devirtualize, take const SkPicture, take pointer)
R=reed@google.com, bsalomon@google.com, mtklein@google.com
Author: robertphillips@google.com
Review URL: https://codereview.chromium.org/313613004
diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp
index 0621aac..f6377bf 100644
--- a/src/gpu/GrLayerCache.cpp
+++ b/src/gpu/GrLayerCache.cpp
@@ -66,7 +66,7 @@
fAtlasMgr.free();
}
-GrCachedLayer* GrLayerCache::createLayer(SkPicture* picture, int layerID) {
+GrCachedLayer* GrLayerCache::createLayer(const SkPicture* picture, int layerID) {
GrCachedLayer* layer = fLayerPool.alloc();
SkASSERT(picture->uniqueID() != SK_InvalidGenID);
@@ -76,7 +76,7 @@
}
-GrCachedLayer* GrLayerCache::findLayerOrCreate(SkPicture* picture, int layerID) {
+GrCachedLayer* GrLayerCache::findLayerOrCreate(const SkPicture* picture, int layerID) {
SkASSERT(picture->uniqueID() != SK_InvalidGenID);
GrCachedLayer* layer = fLayerHash.find(PictureLayerKey(picture->uniqueID(), layerID));
if (NULL == layer) {
diff --git a/src/gpu/GrLayerCache.h b/src/gpu/GrLayerCache.h
index 414b87d..a957e78 100644
--- a/src/gpu/GrLayerCache.h
+++ b/src/gpu/GrLayerCache.h
@@ -102,7 +102,7 @@
void freeAll();
- GrCachedLayer* findLayerOrCreate(SkPicture* picture, int id);
+ GrCachedLayer* findLayerOrCreate(const SkPicture* picture, int id);
private:
SkAutoTUnref<GrGpu> fGpu;
@@ -113,7 +113,7 @@
GrTAllocPool<GrCachedLayer> fLayerPool;
void init();
- GrCachedLayer* createLayer(SkPicture* picture, int id);
+ GrCachedLayer* createLayer(const SkPicture* picture, int id);
};
diff --git a/src/gpu/GrPictureUtils.cpp b/src/gpu/GrPictureUtils.cpp
index f8c2d31..5166bb1 100644
--- a/src/gpu/GrPictureUtils.cpp
+++ b/src/gpu/GrPictureUtils.cpp
@@ -29,7 +29,7 @@
public:
SK_DECLARE_INST_COUNT(GrGatherDevice)
- GrGatherDevice(int width, int height, SkPicture* picture, GPUAccelData* accelData,
+ GrGatherDevice(int width, int height, const SkPicture* picture, GPUAccelData* accelData,
int saveLayerDepth) {
fPicture = picture;
fSaveLayerDepth = saveLayerDepth;
@@ -172,7 +172,7 @@
private:
// The picture being processed
- SkPicture *fPicture;
+ const SkPicture *fPicture;
SkBitmap fEmptyBitmap; // legacy -- need to remove
@@ -223,7 +223,7 @@
// which is all just to fill in 'accelData'
class SK_API GrGatherCanvas : public SkCanvas {
public:
- GrGatherCanvas(GrGatherDevice* device, SkPicture* pict)
+ GrGatherCanvas(GrGatherDevice* device, const SkPicture* pict)
: INHERITED(device)
, fPicture(pict) {
}
@@ -236,20 +236,9 @@
this->clipRect(SkRect::MakeWH(SkIntToScalar(fPicture->width()),
SkIntToScalar(fPicture->height())),
SkRegion::kIntersect_Op, false);
- this->drawPicture(*fPicture);
+ this->drawPicture(fPicture);
}
- virtual void drawPicture(SkPicture& picture) SK_OVERRIDE {
- // BBH-based rendering doesn't re-issue many of the operations the gather
- // process cares about (e.g., saves and restores) so it must be disabled.
- if (NULL != picture.fPlayback) {
- picture.fPlayback->setUseBBH(false);
- }
- picture.draw(this);
- if (NULL != picture.fPlayback) {
- picture.fPlayback->setUseBBH(true);
- }
- }
protected:
// disable aa for speed
virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
@@ -266,15 +255,27 @@
this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
}
+ virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE {
+ // BBH-based rendering doesn't re-issue many of the operations the gather
+ // process cares about (e.g., saves and restores) so it must be disabled.
+ if (NULL != picture->fPlayback) {
+ picture->fPlayback->setUseBBH(false);
+ }
+ picture->draw(this);
+ if (NULL != picture->fPlayback) {
+ picture->fPlayback->setUseBBH(true);
+ }
+ }
+
private:
- SkPicture* fPicture;
+ const SkPicture* fPicture;
typedef SkCanvas INHERITED;
};
// GatherGPUInfo is only intended to be called within the context of SkGpuDevice's
// EXPERIMENTAL_optimize method.
-void GatherGPUInfo(SkPicture* pict, GPUAccelData* accelData) {
+void GatherGPUInfo(const SkPicture* pict, GPUAccelData* accelData) {
if (0 == pict->width() || 0 == pict->height()) {
return ;
}
diff --git a/src/gpu/GrPictureUtils.h b/src/gpu/GrPictureUtils.h
index a280a16..a730697 100644
--- a/src/gpu/GrPictureUtils.h
+++ b/src/gpu/GrPictureUtils.h
@@ -74,6 +74,6 @@
typedef SkPicture::AccelData INHERITED;
};
-void GatherGPUInfo(SkPicture* pict, GPUAccelData* accelData);
+void GatherGPUInfo(const SkPicture* pict, GPUAccelData* accelData);
#endif // GrPictureUtils_DEFINED
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index b05cd33..7514359 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1816,7 +1816,7 @@
return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples());
}
-void SkGpuDevice::EXPERIMENTAL_optimize(SkPicture* picture) {
+void SkGpuDevice::EXPERIMENTAL_optimize(const SkPicture* picture) {
SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey();
const SkPicture::AccelData* existing = picture->EXPERIMENTAL_getAccelData(key);
@@ -1837,11 +1837,11 @@
result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref();
}
-void SkGpuDevice::EXPERIMENTAL_purge(SkPicture* picture) {
+void SkGpuDevice::EXPERIMENTAL_purge(const SkPicture* picture) {
}
-bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture) {
+bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* picture) {
SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey();