diff options
author | vjiaoblack <vjiaoblack@google.com> | 2016-07-21 09:24:16 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-21 09:24:16 -0700 |
commit | 33d325890e549c113a258248002246b46e8040b2 (patch) | |
tree | edb97ce0fe48078a14d82b2d1e8b3b5194025032 /tools | |
parent | 5fa7f30331585f78cf0f81ac185abbff1fee1152 (diff) |
Revert of Creating framework for drawShadowedPicture (patchset #14 id:260001 of https://codereview.chromium.org/2146073003/ )
Reason for revert:
Decided to re-wait for a final LGTM.
Already found a bug in variable naming to fix.
Original issue's description:
> Creating framework for drawShadowedPicture
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2146073003
>
> Committed: https://skia.googlesource.com/skia/+/0ae097d116f4332be02a135ffc99c162473dee6a
TBR=reed@google.com,robertphillips@google.com,bsalomon@google.com,jvanverth@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review-Url: https://codereview.chromium.org/2167223002
Diffstat (limited to 'tools')
-rw-r--r-- | tools/debugger/SkDebugCanvas.cpp | 21 | ||||
-rw-r--r-- | tools/debugger/SkDebugCanvas.h | 58 | ||||
-rw-r--r-- | tools/debugger/SkDrawCommand.cpp | 76 | ||||
-rw-r--r-- | tools/debugger/SkDrawCommand.h | 31 |
4 files changed, 18 insertions, 168 deletions
diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp index d5297ed980..062445ba0a 100644 --- a/tools/debugger/SkDebugCanvas.cpp +++ b/tools/debugger/SkDebugCanvas.cpp @@ -58,16 +58,6 @@ protected: this->SkCanvas::onDrawPicture(picture, matrix, paint); } - void onDrawShadowedPicture(const SkPicture* picture, - const SkMatrix* matrix, - const SkPaint* paint) { -#ifdef SK_EXPERIMENTAL_SHADOWING - this->SkCanvas::onDrawShadowedPicture(picture, matrix, paint); -#else - this->SkCanvas::onDrawPicture(picture, matrix, paint); -#endif - } - private: sk_sp<SkXfermode> fOverdrawXfermode; @@ -613,15 +603,6 @@ void SkDebugCanvas::onDrawPicture(const SkPicture* picture, this->addDrawCommand(new SkEndDrawPictureCommand(SkToBool(matrix) || SkToBool(paint))); } -void SkDebugCanvas::onDrawShadowedPicture(const SkPicture* picture, - const SkMatrix* matrix, - const SkPaint* paint) { - this->addDrawCommand(new SkBeginDrawShadowedPictureCommand(picture, matrix, paint)); - SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect()); - picture->playback(this); - this->addDrawCommand(new SkEndDrawShadowedPictureCommand(SkToBool(matrix) || SkToBool(paint))); -} - void SkDebugCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint) { this->addDrawCommand(new SkDrawPointsCommand(mode, count, pts, paint)); @@ -710,10 +691,8 @@ void SkDebugCanvas::didSetMatrix(const SkMatrix& matrix) { } void SkDebugCanvas::didTranslateZ(SkScalar z) { -#ifdef SK_EXPERIMENTAL_SHADOWING this->addDrawCommand(new SkTranslateZCommand(z)); this->INHERITED::didTranslateZ(z); -#endif } void SkDebugCanvas::toggleCommand(int index, bool toggle) { diff --git a/tools/debugger/SkDebugCanvas.h b/tools/debugger/SkDebugCanvas.h index 9f785ef7f3..4264f55200 100644 --- a/tools/debugger/SkDebugCanvas.h +++ b/tools/debugger/SkDebugCanvas.h @@ -24,27 +24,23 @@ class SkNWayCanvas; class SK_API SkDebugCanvas : public SkCanvas { public: SkDebugCanvas(int width, int height); - virtual ~SkDebugCanvas(); void toggleFilter(bool toggle) { fFilter = toggle; } void setMegaVizMode(bool megaVizMode) { fMegaVizMode = megaVizMode; } - bool getMegaVizMode() const { return fMegaVizMode; } /** * Enable or disable overdraw visualization */ void setOverdrawViz(bool overdrawViz); - bool getOverdrawViz() const { return fOverdrawViz; } /** * Set the color of the clip visualization. An alpha of zero renders the clip invisible. */ void setClipVizColor(SkColor clipVizColor) { this->fClipVizColor = clipVizColor; } - SkColor getClipVizColor() const { return fClipVizColor; } void setDrawGpuBatchBounds(bool drawGpuBatchBounds) { @@ -55,7 +51,7 @@ public: bool getAllowSimplifyClip() const { return fAllowSimplifyClip; } - void setPicture(SkPicture *picture) { fPicture = picture; } + void setPicture(SkPicture* picture) { fPicture = picture; } /** * Enable or disable texure filtering override @@ -66,7 +62,7 @@ public: Executes all draw calls to the canvas. @param canvas The canvas being drawn to */ - void draw(SkCanvas *canvas); + void draw(SkCanvas* canvas); /** Executes the draw calls up to the specified index. @@ -74,19 +70,19 @@ public: @param index The index of the final command being executed @param m an optional Mth gpu batch to highlight, or -1 */ - void drawTo(SkCanvas *canvas, int index, int m = -1); + void drawTo(SkCanvas* canvas, int index, int m = -1); /** Returns the most recently calculated transformation matrix */ - const SkMatrix &getCurrentMatrix() { + const SkMatrix& getCurrentMatrix() { return fMatrix; } /** Returns the most recently calculated clip */ - const SkIRect &getCurrentClip() { + const SkIRect& getCurrentClip() { return fClip; } @@ -105,20 +101,20 @@ public: Returns the draw command at the given index. @param index The index of the command */ - SkDrawCommand *getDrawCommandAt(int index); + SkDrawCommand* getDrawCommandAt(int index); /** Sets the draw command for a given index. @param index The index to overwrite @param command The new command */ - void setDrawCommandAt(int index, SkDrawCommand *command); + void setDrawCommandAt(int index, SkDrawCommand* command); /** Returns information about the command at the given index. @param index The index of the command */ - const SkTDArray<SkString *> *getCommandInfo(int index) const; + const SkTDArray<SkString*>* getCommandInfo(int index) const; /** Returns the visibility of the command at the given index. @@ -130,13 +126,13 @@ public: Returns the vector of draw commands */ SK_ATTR_DEPRECATED("please use getDrawCommandAt and getSize instead") - const SkTDArray<SkDrawCommand *> &getDrawCommands() const; + const SkTDArray<SkDrawCommand*>& getDrawCommands() const; /** Returns the vector of draw commands. Do not use this entry point - it is going away! */ - SkTDArray<SkDrawCommand *> &getDrawCommands(); + SkTDArray<SkDrawCommand*>& getDrawCommands(); /** Returns length of draw command vector. @@ -162,9 +158,9 @@ public: SkDebugCanvas::getSize(). The encoder may use the UrlDataManager to store binary data such as images, referring to them via URLs embedded in the JSON. */ - Json::Value toJSON(UrlDataManager &urlDataManager, int n, SkCanvas *); + Json::Value toJSON(UrlDataManager& urlDataManager, int n, SkCanvas*); - Json::Value toJSONBatchList(int n, SkCanvas *); + Json::Value toJSONBatchList(int n, SkCanvas*); //////////////////////////////////////////////////////////////////////////////// // Inherited from SkCanvas @@ -174,10 +170,8 @@ public: static const int kVizImageWidth = 256; bool isClipEmpty() const override { return false; } - bool isClipRect() const override { return true; } - - bool getClipBounds(SkRect *bounds) const override { + bool getClipBounds(SkRect* bounds) const override { if (bounds) { bounds->setXYWH(0, 0, SkIntToScalar(this->imageInfo().width()), @@ -185,8 +179,7 @@ public: } return true; } - - bool getClipDeviceBounds(SkIRect *bounds) const override { + bool getClipDeviceBounds(SkIRect* bounds) const override { if (bounds) { bounds->setLargest(); } @@ -195,20 +188,13 @@ public: protected: void willSave() override; - - SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec &) override; - + SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; void willRestore() override; - void didConcat(const SkMatrix &) override; - - void didSetMatrix(const SkMatrix &) override; + void didConcat(const SkMatrix&) override; + void didSetMatrix(const SkMatrix&) override; -#ifdef SK_EXPERIMENTAL_SHADOWING void didTranslateZ(SkScalar) override; -#else - void didTranslateZ(SkScalar); -#endif void onDrawAnnotation(const SkRect&, const char[], SkData*) override; void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; @@ -254,16 +240,6 @@ protected: void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override; -#ifdef SK_EXPERIMENTAL_SHADOWING - void onDrawShadowedPicture(const SkPicture*, - const SkMatrix*, - const SkPaint*) override; -#else - void onDrawShadowedPicture(const SkPicture*, - const SkMatrix*, - const SkPaint*); -#endif - void markActiveCommands(int index); private: diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp index 51eb96706a..8f42cb70ec 100644 --- a/tools/debugger/SkDrawCommand.cpp +++ b/tools/debugger/SkDrawCommand.cpp @@ -180,7 +180,6 @@ SkDrawCommand::~SkDrawCommand() { const char* SkDrawCommand::GetCommandString(OpType type) { switch (type) { case kBeginDrawPicture_OpType: return "BeginDrawPicture"; - case kBeginDrawShadowedPicture_OpType: return "BeginDrawShadowedPicture"; case kClipPath_OpType: return "ClipPath"; case kClipRegion_OpType: return "ClipRegion"; case kClipRect_OpType: return "ClipRect"; @@ -209,7 +208,6 @@ const char* SkDrawCommand::GetCommandString(OpType type) { case kDrawTextRSXform_OpType: return "DrawTextRSXform"; case kDrawVertices_OpType: return "DrawVertices"; case kEndDrawPicture_OpType: return "EndDrawPicture"; - case kEndDrawShadowedPicture_OpType: return "EndDrawShadowedPicture"; case kRestore_OpType: return "Restore"; case kSave_OpType: return "Save"; case kSaveLayer_OpType: return "SaveLayer"; @@ -272,9 +270,8 @@ SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url INSTALL_FACTORY(Save); INSTALL_FACTORY(SaveLayer); INSTALL_FACTORY(SetMatrix); -#ifdef SK_EXPERIMENTAL_SHADOWING + INSTALL_FACTORY(TranslateZ); -#endif } SkString name = SkString(command[SKDEBUGCANVAS_ATTRIBUTE_COMMAND].asCString()); FROM_JSON* factory = factories.find(name); @@ -1494,13 +1491,10 @@ static void extract_json_matrix(Json::Value& matrix, SkMatrix* result) { result->set9(values); } -#ifdef SK_EXPERIMENTAL_SHADOWING -// somehow this is only used in shadows... static void extract_json_scalar(Json::Value& scalar, SkScalar* result) { SkScalar value = scalar.asFloat(); *result = value; } -#endif static void extract_json_path(Json::Value& path, SkPath* result) { const char* fillType = path[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE].asCString(); @@ -2387,68 +2381,6 @@ void SkEndDrawPictureCommand::execute(SkCanvas* canvas) const { } } -SkBeginDrawShadowedPictureCommand::SkBeginDrawShadowedPictureCommand(const SkPicture* picture, - const SkMatrix* matrix, - const SkPaint* paint) - : INHERITED(kBeginDrawShadowedPicture_OpType) - , fPicture(SkRef(picture)) { - - SkString* str = new SkString; - str->appendf("SkPicture: L: %f T: %f R: %f B: %f", - picture->cullRect().fLeft, picture->cullRect().fTop, - picture->cullRect().fRight, picture->cullRect().fBottom); - fInfo.push(str); - - if (matrix) { - fMatrix.set(*matrix); - fInfo.push(SkObjectParser::MatrixToString(*matrix)); - } - - if (paint) { - fPaint.set(*paint); - fInfo.push(SkObjectParser::PaintToString(*paint)); - } -} - -void SkBeginDrawShadowedPictureCommand::execute(SkCanvas* canvas) const { - if (fPaint.isValid()) { - SkRect bounds = fPicture->cullRect(); - if (fMatrix.isValid()) { - fMatrix.get()->mapRect(&bounds); - } - canvas->saveLayer(&bounds, fPaint.get()); - } - - if (fMatrix.isValid()) { - if (!fPaint.isValid()) { - canvas->save(); - } - canvas->concat(*fMatrix.get()); - } -} - -bool SkBeginDrawShadowedPictureCommand::render(SkCanvas* canvas) const { - canvas->clear(0xFFFFFFFF); - canvas->save(); - - xlate_and_scale_to_bounds(canvas, fPicture->cullRect()); - - canvas->drawPicture(fPicture.get()); - - canvas->restore(); - - return true; -} - -SkEndDrawShadowedPictureCommand::SkEndDrawShadowedPictureCommand(bool restore) - : INHERITED(kEndDrawShadowedPicture_OpType) , fRestore(restore) { } - -void SkEndDrawShadowedPictureCommand::execute(SkCanvas* canvas) const { - if (fRestore) { - canvas->restore(); - } -} - SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint) : INHERITED(kDrawPoints_OpType) { @@ -3385,9 +3317,7 @@ SkTranslateZCommand::SkTranslateZCommand(SkScalar z) } void SkTranslateZCommand::execute(SkCanvas* canvas) const { -#ifdef SK_EXPERIMENTAL_SHADOWING canvas->translateZ(fZTranslate); -#endif } Json::Value SkTranslateZCommand::toJSON(UrlDataManager& urlDataManager) const { @@ -3399,10 +3329,6 @@ Json::Value SkTranslateZCommand::toJSON(UrlDataManager& urlDataManager) const { SkTranslateZCommand* SkTranslateZCommand::fromJSON(Json::Value& command, UrlDataManager& urlDataManager) { SkScalar z; -#ifdef SK_EXPERIMENTAL_SHADOWING extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS], &z); -#else - z = 0; -#endif return new SkTranslateZCommand(z); } diff --git a/tools/debugger/SkDrawCommand.h b/tools/debugger/SkDrawCommand.h index 14a7af5882..a7e6c73802 100644 --- a/tools/debugger/SkDrawCommand.h +++ b/tools/debugger/SkDrawCommand.h @@ -24,7 +24,6 @@ class SK_API SkDrawCommand { public: enum OpType { kBeginDrawPicture_OpType, - kBeginDrawShadowedPicture_OpType, kClipPath_OpType, kClipRegion_OpType, kClipRect_OpType, @@ -53,7 +52,6 @@ public: kDrawTextRSXform_OpType, kDrawVertices_OpType, kEndDrawPicture_OpType, - kEndDrawShadowedPicture_OpType, kRestore_OpType, kSave_OpType, kSaveLayer_OpType, @@ -457,35 +455,6 @@ private: typedef SkDrawCommand INHERITED; }; -class SkBeginDrawShadowedPictureCommand : public SkDrawCommand { -public: - SkBeginDrawShadowedPictureCommand(const SkPicture* picture, - const SkMatrix* matrix, - const SkPaint* paint); - - void execute(SkCanvas* canvas) const override; - bool render(SkCanvas* canvas) const override; - -private: - SkAutoTUnref<const SkPicture> fPicture; - SkTLazy<SkMatrix> fMatrix; - SkTLazy<SkPaint> fPaint; - - typedef SkDrawCommand INHERITED; -}; - -class SkEndDrawShadowedPictureCommand : public SkDrawCommand { -public: - SkEndDrawShadowedPictureCommand(bool restore); - - void execute(SkCanvas* canvas) const override; - -private: - bool fRestore; - - typedef SkDrawCommand INHERITED; -}; - class SkDrawPointsCommand : public SkDrawCommand { public: SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[], |