skia2/gm/pathopsskpclip.cpp
Mike Klein c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00

72 lines
1.8 KiB
C++

/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkPath.h"
#include "include/core/SkPicture.h"
#include "include/core/SkPictureRecorder.h"
#include "include/core/SkRect.h"
#include "include/pathops/SkPathOps.h"
#include "src/core/SkClipStack.h"
namespace skiagm {
class PathOpsSkpClipGM : public GM {
public:
PathOpsSkpClipGM() {
}
protected:
SkString onShortName() override {
return SkString("pathopsskpclip");
}
SkISize onISize() override {
return SkISize::Make(1200, 900);
}
void onDraw(SkCanvas* canvas) override {
SkPictureRecorder recorder;
SkCanvas* rec = recorder.beginRecording(1200, 900, nullptr, 0);
SkPath p;
SkRect r = {
SkIntToScalar(100),
SkIntToScalar(200),
SkIntToScalar(400),
SkIntToScalar(700)
};
p.addRoundRect(r, SkIntToScalar(50), SkIntToScalar(50));
rec->clipPath(p, true);
rec->translate(SkIntToScalar(250), SkIntToScalar(250));
rec->clipPath(p, true);
rec->drawColor(0xffff0000);
sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
canvas->setAllowSimplifyClip(true);
canvas->save();
canvas->drawPicture(pict);
canvas->restore();
canvas->setAllowSimplifyClip(false);
canvas->save();
canvas->translate(SkIntToScalar(1200 / 2), 0);
canvas->drawPicture(pict);
canvas->restore();
}
private:
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
DEF_GM( return new PathOpsSkpClipGM; )
}