summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-05 19:24:23 +0000
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-05 19:24:23 +0000
commit54e55c5fa25d524d596c838b6e1dcd88a0b94eaf (patch)
tree53ddba83365cc4f7b205e71a79622ee0eff9ae5f
parentd0ea8772b73c1be1cc5f4c53233ee13d8bbe299f (diff)
downloadsrc-54e55c5fa25d524d596c838b6e1dcd88a0b94eaf.tar.gz
Revert r14571 (Infrastructure changes to support pull saveLayers forward task - https://codereview.chromium.org/266203003) due to breaking Android unit tests
git-svn-id: http://skia.googlecode.com/svn/trunk/src@14578 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--core/SkPaintPriv.cpp21
-rw-r--r--core/SkPaintPriv.h7
-rw-r--r--core/SkPicture.cpp23
-rw-r--r--gpu/GrPictureUtils.cpp43
-rw-r--r--gpu/GrPictureUtils.h23
-rw-r--r--gpu/SkGpuDevice.cpp49
6 files changed, 72 insertions, 94 deletions
diff --git a/core/SkPaintPriv.cpp b/core/SkPaintPriv.cpp
index 65fd0e75..ce053890 100644
--- a/core/SkPaintPriv.cpp
+++ b/core/SkPaintPriv.cpp
@@ -76,24 +76,3 @@ bool isPaintOpaque(const SkPaint* paint,
}
return false;
}
-
-bool NeedsDeepCopy(const SkPaint& paint) {
- /*
- * These fields are known to be immutable, and so can be shallow-copied
- *
- * getTypeface()
- * getAnnotation()
- * paint.getColorFilter()
- * getXfermode()
- * getPathEffect()
- * getMaskFilter()
- */
-
- return paint.getShader() ||
-#ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API
- paint.getRasterizer() ||
-#endif
- paint.getLooper() || // needs to hide its addLayer...
- paint.getImageFilter();
-}
-
diff --git a/core/SkPaintPriv.h b/core/SkPaintPriv.h
index 9668fef1..38c9063e 100644
--- a/core/SkPaintPriv.h
+++ b/core/SkPaintPriv.h
@@ -22,11 +22,4 @@ class SkPaint;
*/
bool isPaintOpaque(const SkPaint* paint,
const SkBitmap* bmpReplacesShader = NULL);
-
-/** Returns true if the provided paint has fields which are not
- immutable (and will thus require deep copying).
- @param paint the paint to be analyzed
- @return true if the paint requires a deep copy
-*/
-bool NeedsDeepCopy(const SkPaint& paint);
#endif
diff --git a/core/SkPicture.cpp b/core/SkPicture.cpp
index 68434303..3b04906e 100644
--- a/core/SkPicture.cpp
+++ b/core/SkPicture.cpp
@@ -15,7 +15,6 @@
#include "SkBitmapDevice.h"
#include "SkCanvas.h"
#include "SkChunkAlloc.h"
-#include "SkPaintPriv.h"
#include "SkPicture.h"
#include "SkRegion.h"
#include "SkStream.h"
@@ -218,6 +217,26 @@ SkPicture* SkPicture::clone() const {
return clonedPicture;
}
+static bool needs_deep_copy(const SkPaint& paint) {
+ /*
+ * These fields are known to be immutable, and so can be shallow-copied
+ *
+ * getTypeface()
+ * getAnnotation()
+ * paint.getColorFilter()
+ * getXfermode()
+ * getPathEffect()
+ * getMaskFilter()
+ */
+
+ return paint.getShader() ||
+#ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API
+ paint.getRasterizer() ||
+#endif
+ paint.getLooper() || // needs to hide its addLayer...
+ paint.getImageFilter();
+}
+
void SkPicture::clone(SkPicture* pictures, int count) const {
SkPictCopyInfo copyInfo;
SkPictInfo info;
@@ -263,7 +282,7 @@ void SkPicture::clone(SkPicture* pictures, int count) const {
SkDEBUGCODE(int heapSize = SafeCount(fPlayback->fBitmapHeap.get());)
for (int i = 0; i < paintCount; i++) {
- if (NeedsDeepCopy(fPlayback->fPaints->at(i))) {
+ if (needs_deep_copy(fPlayback->fPaints->at(i))) {
copyInfo.paintData[i] =
SkFlatData::Create<SkPaint::FlatteningTraits>(&copyInfo.controller,
fPlayback->fPaints->at(i), 0);
diff --git a/gpu/GrPictureUtils.cpp b/gpu/GrPictureUtils.cpp
index d8e4161c..e8c3b504 100644
--- a/gpu/GrPictureUtils.cpp
+++ b/gpu/GrPictureUtils.cpp
@@ -7,8 +7,6 @@
#include "GrPictureUtils.h"
#include "SkDevice.h"
-#include "SkDraw.h"
-#include "SkPaintPriv.h"
// The GrGather device performs GPU-backend-specific preprocessing on
// a picture. The results are stored in a GPUAccelData.
@@ -22,17 +20,12 @@ class GrGatherDevice : public SkBaseDevice {
public:
SK_DECLARE_INST_COUNT(GrGatherDevice)
- GrGatherDevice(int width, int height, SkPicture* picture, GPUAccelData* accelData,
- int saveLayerDepth) {
+ GrGatherDevice(int width, int height, SkPicture* picture, GPUAccelData* accelData) {
fPicture = picture;
- fSaveLayerDepth = saveLayerDepth;
- fInfo.fValid = true;
fInfo.fSize.set(width, height);
- fInfo.fPaint = NULL;
fInfo.fSaveLayerOpID = fPicture->EXPERIMENTAL_curOpID();
fInfo.fRestoreOpID = 0;
fInfo.fHasNestedLayers = false;
- fInfo.fIsNested = (2 == fSaveLayerDepth);
fEmptyBitmap.setConfig(SkImageInfo::Make(fInfo.fSize.fWidth,
fInfo.fSize.fHeight,
@@ -117,8 +110,7 @@ protected:
const SkPaint& paint) SK_OVERRIDE {
}
virtual void drawDevice(const SkDraw& draw, SkBaseDevice* deviceIn, int x, int y,
- const SkPaint& paint) SK_OVERRIDE {
- // deviceIn is the one that is being "restored" back to its parent
+ const SkPaint&) SK_OVERRIDE {
GrGatherDevice* device = static_cast<GrGatherDevice*>(deviceIn);
if (device->fAlreadyDrawn) {
@@ -126,29 +118,6 @@ protected:
}
device->fInfo.fRestoreOpID = fPicture->EXPERIMENTAL_curOpID();
- device->fInfo.fCTM = *draw.fMatrix;
- device->fInfo.fCTM.postTranslate(SkIntToScalar(-device->getOrigin().fX),
- SkIntToScalar(-device->getOrigin().fY));
-
- // We need the x & y values that will yield 'getOrigin' when transformed
- // by 'draw.fMatrix'.
- device->fInfo.fOffset.iset(device->getOrigin());
-
- SkMatrix invMatrix;
- if (draw.fMatrix->invert(&invMatrix)) {
- invMatrix.mapPoints(&device->fInfo.fOffset, 1);
- } else {
- device->fInfo.fValid = false;
- }
-
- if (NeedsDeepCopy(paint)) {
- // This NULL acts as a signal that the paint was uncopyable (for now)
- device->fInfo.fPaint = NULL;
- device->fInfo.fValid = false;
- } else {
- device->fInfo.fPaint = SkNEW_ARGS(SkPaint, (paint));
- }
-
fAccelData->addSaveLayerInfo(device->fInfo);
device->fAlreadyDrawn = true;
}
@@ -189,9 +158,6 @@ private:
// The information regarding the saveLayer call this device represents.
GPUAccelData::SaveLayerInfo fInfo;
- // The depth of this device in the saveLayer stack
- int fSaveLayerDepth;
-
virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRIDE {
NotSupported();
}
@@ -201,8 +167,7 @@ private:
SkASSERT(kSaveLayer_Usage == usage);
fInfo.fHasNestedLayers = true;
- return SkNEW_ARGS(GrGatherDevice, (info.width(), info.height(), fPicture,
- fAccelData, fSaveLayerDepth+1));
+ return SkNEW_ARGS(GrGatherDevice, (info.width(), info.height(), fPicture, fAccelData));
}
virtual void flush() SK_OVERRIDE {}
@@ -274,7 +239,7 @@ void GatherGPUInfo(SkPicture* pict, GPUAccelData* accelData) {
return ;
}
- GrGatherDevice device(pict->width(), pict->height(), pict, accelData, 0);
+ GrGatherDevice device(pict->width(), pict->height(), pict, accelData);
GrGatherCanvas canvas(&device, pict);
canvas.gather();
diff --git a/gpu/GrPictureUtils.h b/gpu/GrPictureUtils.h
index 5ca41320..6b4d901c 100644
--- a/gpu/GrPictureUtils.h
+++ b/gpu/GrPictureUtils.h
@@ -17,21 +17,8 @@ class GPUAccelData : public SkPicture::AccelData {
public:
// Information about a given saveLayer in an SkPicture
struct SaveLayerInfo {
- // True if the SaveLayerInfo is valid. False if either 'fOffset' is
- // invalid (due to a non-invertible CTM) or 'fPaint' is NULL (due
- // to a non-copyable paint).
- bool fValid;
// The size of the saveLayer
SkISize fSize;
- // The CTM in which this layer's draws must occur. It already incorporates
- // the translation needed to map the layer's top-left point to the origin.
- SkMatrix fCTM;
- // The offset that needs to be passed to drawBitmap to correctly
- // position the pre-rendered layer.
- SkPoint fOffset;
- // The paint to use on restore. NULL if the paint was not copyable (and
- // thus that this layer should not be pulled forward).
- const SkPaint* fPaint;
// The ID of this saveLayer in the picture. 0 is an invalid ID.
size_t fSaveLayerOpID;
// The ID of the matching restore in the picture. 0 is an invalid ID.
@@ -39,8 +26,6 @@ public:
// True if this saveLayer has at least one other saveLayer nested within it.
// False otherwise.
bool fHasNestedLayers;
- // True if this saveLayer is nested within another. False otherwise.
- bool fIsNested;
};
GPUAccelData(Key key) : INHERITED(key) { }
@@ -58,14 +43,6 @@ public:
return fSaveLayerInfo[index];
}
- // We may, in the future, need to pass in the GPUDevice in order to
- // incorporate the clip and matrix state into the key
- static SkPicture::AccelData::Key ComputeAccelDataKey() {
- static const SkPicture::AccelData::Key gGPUID = SkPicture::AccelData::GenerateDomain();
-
- return gGPUID;
- }
-
protected:
SkTDArray<SaveLayerInfo> fSaveLayerInfo;
diff --git a/gpu/SkGpuDevice.cpp b/gpu/SkGpuDevice.cpp
index 3119a9e7..714a6da6 100644
--- a/gpu/SkGpuDevice.cpp
+++ b/gpu/SkGpuDevice.cpp
@@ -1910,8 +1910,16 @@ SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) {
return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples());
}
+// In the future this may not be a static method if we need to incorporate the
+// clip and matrix state into the key
+SkPicture::AccelData::Key SkGpuDevice::ComputeAccelDataKey() {
+ static const SkPicture::AccelData::Key gGPUID = SkPicture::AccelData::GenerateDomain();
+
+ return gGPUID;
+}
+
void SkGpuDevice::EXPERIMENTAL_optimize(SkPicture* picture) {
- SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey();
+ SkPicture::AccelData::Key key = ComputeAccelDataKey();
GPUAccelData* data = SkNEW_ARGS(GPUAccelData, (key));
@@ -1926,7 +1934,7 @@ void SkGpuDevice::EXPERIMENTAL_purge(SkPicture* picture) {
bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture) {
- SkPicture::AccelData::Key key = GPUAccelData::ComputeAccelDataKey();
+ SkPicture::AccelData::Key key = ComputeAccelDataKey();
const SkPicture::AccelData* data = picture->EXPERIMENTAL_getAccelData(key);
if (NULL == data) {
@@ -1935,6 +1943,27 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture)
const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data);
+//#define SK_PRINT_PULL_FORWARD_INFO 1
+
+#ifdef SK_PRINT_PULL_FORWARD_INFO
+ static bool gPrintedAccelData = false;
+
+ if (!gPrintedAccelData) {
+ for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
+ const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i);
+
+ SkDebugf("%d: Width: %d Height: %d SL: %d R: %d hasNestedLayers: %s\n",
+ i,
+ info.fSize.fWidth,
+ info.fSize.fHeight,
+ info.fSaveLayerOpID,
+ info.fRestoreOpID,
+ info.fHasNestedLayers ? "T" : "F");
+ }
+ gPrintedAccelData = true;
+ }
+#endif
+
SkAutoTArray<bool> pullForward(gpuData->numSaveLayers());
for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
pullForward[i] = false;
@@ -1955,6 +1984,10 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture)
const SkPicture::OperationList& ops = picture->EXPERIMENTAL_getActiveOps(clip);
+#ifdef SK_PRINT_PULL_FORWARD_INFO
+ SkDebugf("rect: %d %d %d %d\n", clip.fLeft, clip.fTop, clip.fRight, clip.fBottom);
+#endif
+
for (int i = 0; i < ops.numOps(); ++i) {
for (int j = 0; j < gpuData->numSaveLayers(); ++j) {
const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(j);
@@ -1965,5 +1998,17 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture)
}
}
+#ifdef SK_PRINT_PULL_FORWARD_INFO
+ SkDebugf("Need SaveLayers: ");
+ for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
+ if (pullForward[i]) {
+ const GrCachedLayer* layer = fContext->getLayerCache()->findLayerOrCreate(picture, i);
+
+ SkDebugf("%d (%d), ", i, layer->layerID());
+ }
+ }
+ SkDebugf("\n");
+#endif
+
return false;
}