c0bd9f9fe5
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>
74 lines
2.3 KiB
C++
74 lines
2.3 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 "include/core/SkCanvas.h"
|
|
#include "include/core/SkPaint.h"
|
|
#include "include/core/SkShader.h"
|
|
#include "include/utils/SkRandom.h"
|
|
#include "samplecode/Sample.h"
|
|
|
|
/**
|
|
* Animated sample used to develop a predecessor of GrDrawOp combining.
|
|
*/
|
|
class ManyRectsView : public Sample {
|
|
private:
|
|
enum {
|
|
N = 1000,
|
|
};
|
|
|
|
public:
|
|
ManyRectsView() {}
|
|
|
|
protected:
|
|
bool onQuery(Sample::Event* evt) override {
|
|
if (Sample::TitleQ(*evt)) {
|
|
Sample::TitleR(evt, "ManyRects");
|
|
return true;
|
|
}
|
|
return this->INHERITED::onQuery(evt);
|
|
}
|
|
|
|
void onDrawContent(SkCanvas* canvas) override {
|
|
SkISize dsize = canvas->getBaseLayerSize();
|
|
canvas->clear(0xFFF0E0F0);
|
|
|
|
for (int i = 0; i < N; ++i) {
|
|
SkRect rect = SkRect::MakeWH(SkIntToScalar(fRandom.nextRangeU(10, 100)),
|
|
SkIntToScalar(fRandom.nextRangeU(10, 100)));
|
|
int x = fRandom.nextRangeU(0, dsize.fWidth);
|
|
int y = fRandom.nextRangeU(0, dsize.fHeight);
|
|
canvas->save();
|
|
|
|
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
|
|
// Uncomment to test rotated rect draw combining.
|
|
if (false) {
|
|
SkMatrix rotate;
|
|
rotate.setRotate(fRandom.nextUScalar1() * 360,
|
|
SkIntToScalar(x) + SkScalarHalf(rect.fRight),
|
|
SkIntToScalar(y) + SkScalarHalf(rect.fBottom));
|
|
canvas->concat(rotate);
|
|
}
|
|
SkRect clipRect = rect;
|
|
// This clip will always contain the entire rect. It's here to give the GPU op combining
|
|
// code a little more challenge.
|
|
clipRect.outset(10, 10);
|
|
canvas->clipRect(clipRect);
|
|
SkPaint paint;
|
|
paint.setColor(fRandom.nextU());
|
|
canvas->drawRect(rect, paint);
|
|
canvas->restore();
|
|
}
|
|
}
|
|
|
|
private:
|
|
SkRandom fRandom;
|
|
typedef Sample INHERITED;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
DEF_SAMPLE( return new ManyRectsView(); )
|