a1f4fa7230
Reason for revert: Das roll ist gebusted: https://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_ng/builds/214775/steps/compile%20%28with%20patch%29/logs/stdio FAILED: /b/build/slave/cache/cipd/goma/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/third_party/WebKit/Source/platform/graphics/paint/blink_platform_unittests.PaintArtifactToSkCanvasTest.o.d -DV8_DEPRECATION_WARNINGS -DCLD_VERSION=2 -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -DCHROMIUM_BUILD -DCR_CLANG_REVISION=266460-1 -DUSE_LIBJPEG_TURBO=1 -DENABLE_WEBRTC=1 -DENABLE_MEDIA_ROUTER=1 -DUSE_PROPRIETARY_CODECS -DENABLE_PEPPER_CDMS -DENABLE_NOTIFICATIONS -DENABLE_TOPCHROME_MD=1 -DDCHECK_ALWAYS_ON=1 -DFIELDTRIAL_TESTING_ENABLED -DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 -DENABLE_PDF=1 -DENABLE_PLUGIN_INSTALLATION=1 -DENABLE_PLUGINS=1 -DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_AUTOFILL_DIALOG=1 -DENABLE_PRINTING=1 -DENABLE_BASIC_PRINTING=1 -DENABLE_PRINT_PREVIEW=1 -DENABLE_SPELLCHECK=1 -DUSE_BROWSER_SPELLCHECKER=1 -DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_APP_LIST=1 -DENABLE_SETTINGS_APP=1 -DENABLE_SUPERVISED_USERS=1 -DENABLE_SERVICE_DISCOVERY=1 -DV8_USE_EXTERNAL_STARTUP_DATA -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DINSIDE_BLINK -DMOJO_USE_SYSTEM_IMPL -DGTEST_HAS_POSIX_RE=0 -DGTEST_LANG_CXX11=0 -DUNIT_TEST -DGTEST_HAS_RTTI=0 -DENABLE_LAYOUT_UNIT_IN_INLINE_BOXES=0 -DENABLE_OILPAN=1 -DWTF_USE_CONCATENATED_IMPULSE_RESPONSES=1 -DENABLE_INPUT_MULTIPLE_FIELDS_UI=1 -DWTF_USE_ICCJPEG=1 -DWTF_USE_QCMSLIB=1 -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_NOEXCEPT= -DU_STATIC_IMPLEMENTATION -DSK_SUPPORT_GPU=1 -DSK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS -DCHROME_PNG_WRITE_SUPPORT -DPNG_USER_CONFIG -DUSE_LIBPCI=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -D_FORTIFY_SOURCE=2 -Igen -Igen/blink -I../.. -I../../skia/config -I../../third_party/WebKit/Source -I../../third_party/khronos -I../../gpu -Igen/angle -I../../third_party/WebKit -Igen/third_party/WebKit -I../../testing/gmock/include -I../../testing/gtest/include -I../../third_party/icu/source/i18n -I../../third_party/icu/source/common -I../../third_party/skia/include/core -I../../third_party/skia/include/effects -I../../third_party/skia/include/pdf -I../../third_party/skia/include/gpu -I../../third_party/skia/include/lazy -I../../third_party/skia/include/pathops -I../../third_party/skia/include/pipe -I../../third_party/skia/include/ports -I../../third_party/skia/include/utils -I../../third_party/skia/include/utils/mac -I../../skia/ext -I../../third_party/harfbuzz-ng/src -I../../third_party/qcms/src -I../../third_party/libpng -I../../third_party/zlib -I../../third_party/libwebp -I../../third_party/ots/include -I../../v8/include -I../../third_party/iccjpeg -I../../third_party/libjpeg_turbo -isysroot /Applications/Xcode5.1.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -O2 -fvisibility=hidden -Werror -mmacosx-version-min=10.7 -arch x86_64 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-selector-type-mismatch -Wpartial-availability -Wheader-hygiene -Wno-char-subscripts -Wno-unneeded-internal-declaration -Wno-covered-switch-default -Wstring-conversion -Wno-c++11-narrowing -Wno-deprecated-register -Wno-inconsistent-missing-override -Wno-shift-negative-value -std=c++11 -stdlib=libc++ -fno-rtti -fno-exceptions -fvisibility-inlines-hidden -fno-threadsafe-statics -Xclang -load -Xclang /b/build/slave/mac/build/src/third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-templates -Xclang -plugin-arg-find-bad-constructs -Xclang follow-macro-expansion -Xclang -plugin-arg-find-bad-constructs -Xclang check-implicit-copy-ctors -fcolor-diagnostics -fno-strict-aliasing -Xclang -load -Xclang /b/build/slave/mac/build/src/third_party/llvm-build/Release+Asserts/lib/libBlinkGCPlugin.dylib -Xclang -add-plugin -Xclang blink-gc-plugin -Xclang -plugin-arg-blink-gc-plugin -Xclang enable-oilpan -Xclang -plugin-arg-blink-gc-plugin -Xclang warn-raw-ptr -c ../../third_party/WebKit/Source/platform/graphics/paint/PaintArtifactToSkCanvasTest.cpp -o obj/third_party/WebKit/Source/platform/graphics/paint/blink_platform_unittests.PaintArtifactToSkCanvasTest.o ../../third_party/WebKit/Source/platform/graphics/paint/PaintArtifactToSkCanvasTest.cpp:201:22: error: 'LayerIter' is a protected member of 'SkCanvas' return SkCanvas::LayerIter(canvas, false).clip(); ^ ../../third_party/skia/include/core/SkCanvas.h:1230:18: note: declared protected here class SK_API LayerIter /*: SkNoncopyable*/ { ^ 1 error generated. ninja: build stopped: subcommand failed. Original issue's description: > Hide SkCanvas::LayerIter > > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1897863008 > > Committed: https://skia.googlesource.com/skia/+/a814000cbb0e90624a410b4359fff7f3ec66f0e0 TBR=reed@google.com,robertphillips@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/1906573003
309 lines
8.0 KiB
C++
309 lines
8.0 KiB
C++
/*
|
|
* Copyright 2011 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "SampleCode.h"
|
|
#include "SkView.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkBlurMaskFilter.h"
|
|
#include "SkCamera.h"
|
|
#include "SkColorFilter.h"
|
|
#include "SkColorPriv.h"
|
|
#include "SkDevice.h"
|
|
#include "SkGradientShader.h"
|
|
#include "SkImage.h"
|
|
#include "SkInterpolator.h"
|
|
#include "SkMaskFilter.h"
|
|
#include "SkPath.h"
|
|
#include "SkRegion.h"
|
|
#include "SkShader.h"
|
|
#include "SkTime.h"
|
|
#include "SkTypeface.h"
|
|
#include "SkUtils.h"
|
|
#include "SkKey.h"
|
|
#include "SkXfermode.h"
|
|
#include "SkDrawFilter.h"
|
|
|
|
static void make_paint(SkPaint* paint, const SkMatrix& localMatrix) {
|
|
SkColor colors[] = { 0, SK_ColorWHITE };
|
|
SkPoint pts[] = { { 0, 0 }, { 0, SK_Scalar1*20 } };
|
|
paint->setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2,
|
|
SkShader::kClamp_TileMode, 0, &localMatrix));
|
|
paint->setXfermodeMode(SkXfermode::kDstIn_Mode);
|
|
}
|
|
|
|
static void dump_layers(const char label[], SkCanvas* canvas) {
|
|
SkDebugf("Dump Layers(%s)\n", label);
|
|
|
|
SkCanvas::LayerIter iter(canvas, true);
|
|
int index = 0;
|
|
while (!iter.done()) {
|
|
SkImageInfo info = iter.device()->imageInfo();
|
|
const SkIRect& clip = iter.clip().getBounds();
|
|
SkDebugf("Layer[%d] bitmap [%d %d] X=%d Y=%d clip=[%d %d %d %d] alpha=%d\n", index++,
|
|
info.width(), info.height(), iter.x(), iter.y(),
|
|
clip.fLeft, clip.fTop, clip.fRight, clip.fBottom,
|
|
iter.paint().getAlpha());
|
|
iter.next();
|
|
}
|
|
}
|
|
|
|
// test drawing with strips of fading gradient above and below
|
|
static void test_fade(SkCanvas* canvas) {
|
|
SkAutoCanvasRestore ar(canvas, true);
|
|
|
|
SkRect r;
|
|
|
|
SkPaint p;
|
|
p.setAlpha(0x88);
|
|
|
|
SkAutoCanvasRestore ar2(canvas, false);
|
|
|
|
// create the layers
|
|
|
|
r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100));
|
|
canvas->clipRect(r);
|
|
|
|
r.fBottom = SkIntToScalar(20);
|
|
canvas->saveLayer(&r, nullptr);
|
|
|
|
r.fTop = SkIntToScalar(80);
|
|
r.fBottom = SkIntToScalar(100);
|
|
canvas->saveLayer(&r, nullptr);
|
|
|
|
// now draw the "content"
|
|
|
|
if (true) {
|
|
r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100));
|
|
|
|
canvas->saveLayerAlpha(&r, 0x80);
|
|
|
|
SkPaint p;
|
|
p.setColor(SK_ColorRED);
|
|
p.setAntiAlias(true);
|
|
canvas->drawOval(r, p);
|
|
|
|
dump_layers("inside layer alpha", canvas);
|
|
|
|
canvas->restore();
|
|
} else {
|
|
r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100));
|
|
|
|
SkPaint p;
|
|
p.setColor(SK_ColorRED);
|
|
p.setAntiAlias(true);
|
|
canvas->drawOval(r, p);
|
|
}
|
|
|
|
// return;
|
|
|
|
dump_layers("outside layer alpha", canvas);
|
|
|
|
// now apply an effect
|
|
SkMatrix m;
|
|
m.setScale(SK_Scalar1, -SK_Scalar1);
|
|
m.postTranslate(0, SkIntToScalar(100));
|
|
|
|
SkPaint paint;
|
|
make_paint(&paint, m);
|
|
r.set(0, 0, SkIntToScalar(100), SkIntToScalar(20));
|
|
// SkDebugf("--------- draw top grad\n");
|
|
canvas->drawRect(r, paint);
|
|
|
|
r.fTop = SkIntToScalar(80);
|
|
r.fBottom = SkIntToScalar(100);
|
|
// SkDebugf("--------- draw bot grad\n");
|
|
canvas->drawRect(r, paint);
|
|
}
|
|
|
|
class RedFilter : public SkDrawFilter {
|
|
public:
|
|
bool filter(SkPaint* p, SkDrawFilter::Type) override {
|
|
fColor = p->getColor();
|
|
if (fColor == SK_ColorRED) {
|
|
p->setColor(SK_ColorGREEN);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private:
|
|
SkColor fColor;
|
|
};
|
|
|
|
class LayersView : public SkView {
|
|
public:
|
|
LayersView() {}
|
|
|
|
protected:
|
|
// overrides from SkEventSink
|
|
bool onQuery(SkEvent* evt) override {
|
|
if (SampleCode::TitleQ(*evt)) {
|
|
SampleCode::TitleR(evt, "Layers");
|
|
return true;
|
|
}
|
|
return this->INHERITED::onQuery(evt);
|
|
}
|
|
|
|
void drawBG(SkCanvas* canvas) {
|
|
canvas->drawColor(SK_ColorGRAY);
|
|
}
|
|
|
|
void onDraw(SkCanvas* canvas) override {
|
|
this->drawBG(canvas);
|
|
|
|
if (true) {
|
|
SkRect r;
|
|
r.set(SkIntToScalar(0), SkIntToScalar(0),
|
|
SkIntToScalar(220), SkIntToScalar(120));
|
|
SkPaint p;
|
|
canvas->saveLayer(&r, &p);
|
|
canvas->drawColor(0xFFFF0000);
|
|
p.setAlpha(0); // or 0
|
|
p.setXfermodeMode(SkXfermode::kSrc_Mode);
|
|
canvas->drawOval(r, p);
|
|
canvas->restore();
|
|
return;
|
|
}
|
|
|
|
if (false) {
|
|
SkRect r;
|
|
r.set(SkIntToScalar(0), SkIntToScalar(0),
|
|
SkIntToScalar(220), SkIntToScalar(120));
|
|
SkPaint p;
|
|
p.setAlpha(0x88);
|
|
p.setAntiAlias(true);
|
|
|
|
if (true) {
|
|
canvas->saveLayer(&r, &p);
|
|
p.setColor(0xFFFF0000);
|
|
canvas->drawOval(r, p);
|
|
canvas->restore();
|
|
}
|
|
|
|
p.setColor(0xFF0000FF);
|
|
r.offset(SkIntToScalar(20), SkIntToScalar(50));
|
|
canvas->drawOval(r, p);
|
|
}
|
|
|
|
if (false) {
|
|
SkPaint p;
|
|
p.setAlpha(0x88);
|
|
p.setAntiAlias(true);
|
|
|
|
canvas->translate(SkIntToScalar(300), 0);
|
|
|
|
SkRect r;
|
|
r.set(SkIntToScalar(0), SkIntToScalar(0),
|
|
SkIntToScalar(220), SkIntToScalar(60));
|
|
|
|
canvas->saveLayer(&r, &p);
|
|
|
|
r.set(SkIntToScalar(0), SkIntToScalar(0),
|
|
SkIntToScalar(220), SkIntToScalar(120));
|
|
p.setColor(SK_ColorBLUE);
|
|
canvas->drawOval(r, p);
|
|
canvas->restore();
|
|
return;
|
|
}
|
|
|
|
test_fade(canvas);
|
|
}
|
|
|
|
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
|
this->inval(nullptr);
|
|
|
|
return this->INHERITED::onFindClickHandler(x, y, modi);
|
|
}
|
|
|
|
bool onClick(Click* click) override {
|
|
return this->INHERITED::onClick(click);
|
|
}
|
|
|
|
virtual bool handleKey(SkKey) {
|
|
this->inval(nullptr);
|
|
return true;
|
|
}
|
|
|
|
private:
|
|
typedef SkView INHERITED;
|
|
};
|
|
DEF_SAMPLE( return new LayersView; )
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "SkBlurImageFilter.h"
|
|
#include "SkMatrixConvolutionImageFilter.h"
|
|
#include "SkMorphologyImageFilter.h"
|
|
|
|
#include "Resources.h"
|
|
#include "SkAnimTimer.h"
|
|
|
|
class BackdropView : public SampleView {
|
|
SkPoint fCenter;
|
|
SkScalar fAngle;
|
|
sk_sp<SkImage> fImage;
|
|
sk_sp<SkImageFilter> fFilter;
|
|
public:
|
|
BackdropView() {
|
|
fCenter.set(200, 150);
|
|
fAngle = 0;
|
|
fImage = GetResourceAsImage("mandrill_512.png");
|
|
fFilter = SkDilateImageFilter::Make(8, 8, nullptr);
|
|
}
|
|
|
|
protected:
|
|
// overrides from SkEventSink
|
|
bool onQuery(SkEvent* evt) override {
|
|
if (SampleCode::TitleQ(*evt)) {
|
|
SampleCode::TitleR(evt, "Backdrop");
|
|
return true;
|
|
}
|
|
return this->INHERITED::onQuery(evt);
|
|
}
|
|
|
|
void onDrawContent(SkCanvas* canvas) override {
|
|
canvas->drawImage(fImage.get(), 0, 0, nullptr);
|
|
|
|
const SkScalar w = 250;
|
|
const SkScalar h = 150;
|
|
SkPath path;
|
|
path.addOval(SkRect::MakeXYWH(-w/2, -h/2, w, h));
|
|
SkMatrix m;
|
|
m.setRotate(fAngle);
|
|
m.postTranslate(fCenter.x(), fCenter.y());
|
|
path.transform(m);
|
|
|
|
canvas->clipPath(path, SkRegion::kIntersect_Op, true);
|
|
const SkRect bounds = path.getBounds();
|
|
|
|
SkPaint paint;
|
|
paint.setAlpha(0xCC);
|
|
canvas->saveLayer({ &bounds, &paint, fFilter.get(), 0 });
|
|
|
|
canvas->restore();
|
|
}
|
|
|
|
bool onAnimate(const SkAnimTimer& timer) override {
|
|
fAngle = SkDoubleToScalar(fmod(timer.secs() * 360 / 5, 360));
|
|
return true;
|
|
}
|
|
|
|
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
|
this->inval(nullptr);
|
|
return new Click(this);
|
|
}
|
|
|
|
bool onClick(Click* click) override {
|
|
this->inval(nullptr);
|
|
fCenter = click->fCurr;
|
|
return this->INHERITED::onClick(click);
|
|
}
|
|
|
|
private:
|
|
typedef SampleView INHERITED;
|
|
};
|
|
DEF_SAMPLE( return new BackdropView; )
|