Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: src/gpu/GrPictureUtils.cpp

Issue 266203003: Infrastructure changes to support pull saveLayers forward task (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fixed Android error Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrPictureUtils.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrPictureUtils.cpp
===================================================================
--- src/gpu/GrPictureUtils.cpp (revision 14579)
+++ src/gpu/GrPictureUtils.cpp (working copy)
@@ -7,7 +7,15 @@
#include "GrPictureUtils.h"
#include "SkDevice.h"
+#include "SkDraw.h"
+#include "SkPaintPriv.h"
+SkPicture::AccelData::Key GPUAccelData::ComputeAccelDataKey() {
+ static const SkPicture::AccelData::Key gGPUID = SkPicture::AccelData::GenerateDomain();
+
+ return gGPUID;
+}
+
// The GrGather device performs GPU-backend-specific preprocessing on
// a picture. The results are stored in a GPUAccelData.
//
@@ -20,12 +28,17 @@
public:
SK_DECLARE_INST_COUNT(GrGatherDevice)
- GrGatherDevice(int width, int height, SkPicture* picture, GPUAccelData* accelData) {
+ GrGatherDevice(int width, int height, SkPicture* picture, GPUAccelData* accelData,
+ int saveLayerDepth) {
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,
@@ -110,7 +123,8 @@
const SkPaint& paint) SK_OVERRIDE {
}
virtual void drawDevice(const SkDraw& draw, SkBaseDevice* deviceIn, int x, int y,
- const SkPaint&) SK_OVERRIDE {
+ const SkPaint& paint) SK_OVERRIDE {
+ // deviceIn is the one that is being "restored" back to its parent
GrGatherDevice* device = static_cast<GrGatherDevice*>(deviceIn);
if (device->fAlreadyDrawn) {
@@ -118,6 +132,29 @@
}
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;
}
@@ -158,6 +195,9 @@
// 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();
}
@@ -167,7 +207,8 @@
SkASSERT(kSaveLayer_Usage == usage);
fInfo.fHasNestedLayers = true;
- return SkNEW_ARGS(GrGatherDevice, (info.width(), info.height(), fPicture, fAccelData));
+ return SkNEW_ARGS(GrGatherDevice, (info.width(), info.height(), fPicture,
+ fAccelData, fSaveLayerDepth+1));
}
virtual void flush() SK_OVERRIDE {}
@@ -239,7 +280,7 @@
return ;
}
- GrGatherDevice device(pict->width(), pict->height(), pict, accelData);
+ GrGatherDevice device(pict->width(), pict->height(), pict, accelData, 0);
GrGatherCanvas canvas(&device, pict);
canvas.gather();
« no previous file with comments | « src/gpu/GrPictureUtils.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698