4241f5e0a8
This reverts commit e1af44498b
.
Reason for revert: breaking google3?
Original change's description:
> add guard to switch to SkPathTypes
>
> Change-Id: I44d8b5ae8a5172d11a6d4cd9d994373dd3816d6f
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/241278
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Mike Reed <reed@google.com>
TBR=robertphillips@google.com,kjlubick@google.com,fmalita@chromium.org,reed@google.com
Change-Id: If1fffb6310921ee6f213af000da793afcf62ab0b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/241560
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
69 lines
2.4 KiB
C++
69 lines
2.4 KiB
C++
|
|
/*
|
|
* Copyright 2012 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/SkCanvas.h"
|
|
#include "include/core/SkColor.h"
|
|
#include "include/core/SkPath.h"
|
|
#include "include/core/SkPicture.h"
|
|
#include "include/core/SkPictureRecorder.h"
|
|
#include "include/core/SkRect.h"
|
|
#include "include/core/SkRefCnt.h"
|
|
#include "include/core/SkScalar.h"
|
|
#include "include/core/SkSize.h"
|
|
#include "include/core/SkString.h"
|
|
|
|
namespace skiagm {
|
|
|
|
class DistantClipGM : public GM {
|
|
SkString onShortName() override { return SkString("distantclip"); }
|
|
|
|
SkISize onISize() override { return {100, 100}; }
|
|
|
|
void onDraw(SkCanvas* canvas) override {
|
|
constexpr SkScalar kOffset = 35000.0f;
|
|
constexpr SkScalar kExtents = 1000.0f;
|
|
|
|
SkPictureRecorder recorder;
|
|
// We record a picture of huge vertical extents in which we clear the canvas to red, create
|
|
// a 'extents' by 'extents' round rect clip at a vertical offset of 'offset', then draw
|
|
// green into that.
|
|
SkCanvas* rec = recorder.beginRecording(kExtents, kOffset + kExtents, nullptr, 0);
|
|
rec->drawColor(SK_ColorRED);
|
|
rec->save();
|
|
SkRect r = SkRect::MakeXYWH(-kExtents, kOffset - kExtents, 2 * kExtents, 2 * kExtents);
|
|
SkPath p;
|
|
p.addRoundRect(r, 5, 5);
|
|
rec->clipPath(p, true);
|
|
rec->drawColor(SK_ColorGREEN);
|
|
rec->restore();
|
|
sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
|
|
|
|
// Next we play that picture into another picture of the same size.
|
|
pict->playback(recorder.beginRecording(pict->cullRect().width(),
|
|
pict->cullRect().height(),
|
|
nullptr, 0));
|
|
sk_sp<SkPicture> pict2(recorder.finishRecordingAsPicture());
|
|
|
|
// Finally we play the part of that second picture that should be green into the canvas.
|
|
canvas->save();
|
|
canvas->translate(kExtents / 2, -(kOffset - kExtents / 2));
|
|
pict2->playback(canvas);
|
|
canvas->restore();
|
|
|
|
// If the image is red, we erroneously decided the clipPath was empty and didn't record
|
|
// the green drawColor, if it's green we're all good.
|
|
}
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
DEF_GM( return new DistantClipGM; )
|
|
|
|
}
|