diff --git a/engine/core/core.gni b/engine/core/core.gni index fab3211c3a98625f73fb4b59a76e0332c49842f0..85e6052628b627346c93b3f3f499274c9d9973f3 100644 --- a/engine/core/core.gni +++ b/engine/core/core.gni @@ -1169,6 +1169,7 @@ core_idl_files = get_path_info([ core_dart_files = get_path_info([ "painting/Color.dart", "painting/ColorFilter.dart", + "painting/DrawLooperLayerInfo.dart", "painting/Gradient.dart", "painting/MaskFilter.dart", "painting/PaintingStyle.dart", diff --git a/engine/core/painting/DrawLooperLayerInfo.dart b/engine/core/painting/DrawLooperLayerInfo.dart new file mode 100644 index 0000000000000000000000000000000000000000..6f7647c1a87411687bf3b3cfb96cbf6fc8fa41ba --- /dev/null +++ b/engine/core/painting/DrawLooperLayerInfo.dart @@ -0,0 +1,23 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +part of dart.sky; + +/// Paint masks for DrawLooperLayerInfo.setPaintBits. These specify which +/// aspects of the layer's paint should replace the corresponding aspects on +/// the draw's paint. +/// +/// PaintBits.all means use the layer's paint completely. +/// 0 means ignore the layer's paint... except for colorMode, which is +/// always applied. +class PaintBits { + static const int style = 0x1; + static const int testSkewx = 0x2; + static const int pathEffect = 0x4; + static const int maskFilter = 0x8; + static const int shader = 0x10; + static const int colorFilter = 0x20; + static const int xfermode = 0x40; + static const int all = 0xFFFFFFFF; +} diff --git a/engine/core/painting/DrawLooperLayerInfo.idl b/engine/core/painting/DrawLooperLayerInfo.idl index 75614b61b2debcdaed6bc784ba09a990c8164fcd..5fed53d5c75a23bc8e64ae5c7ac69f53568ff972 100644 --- a/engine/core/painting/DrawLooperLayerInfo.idl +++ b/engine/core/painting/DrawLooperLayerInfo.idl @@ -5,23 +5,9 @@ [ Constructor(), ] interface DrawLooperLayerInfo { - // Bits specifies which aspects of the layer's paint should replace the - // corresponding aspects on the draw's paint. - // ENTIRE_PAINT_BITS means use the layer's paint completely. - // 0 means ignore the layer's paint... except for colorMode, which is - // always applied. - // TODO(mpcomplete): maybe these should each be functions (e.g. useStyle()). - // TODO(mpcomplete): the IDL compiler doesn't use these for anything? - // TODO(mpcomplete): dart style says to name these like 'styleBit'. - const unsigned long STYLE_BIT = 0x1; - const unsigned long TEXT_SKEWX_BIT = 0x2; - const unsigned long PATH_EFFECT_BIT = 0x4; - const unsigned long MASK_FILTER_BIT = 0x8; - const unsigned long SHADER_BIT = 0x10; - const unsigned long COLOR_FILTER_BIT = 0x20; - const unsigned long XFERMODE_BIT = 0x40; - const unsigned long ENTIRE_PAINT_BITS = -1; - + // Specifies which aspects of the layer's paint should replace the + // corresponding aspects on the draw's paint. Use PaintBits, defined in + // DrawLooperLayerInfo.dart. void setPaintBits(unsigned long bits); void setColorMode(TransferMode mode); // TODO(eseidel): Offset should be a Size not a Point. diff --git a/examples/raw/painting.sky b/examples/raw/painting.sky index 03d2d02fd6ab8d2c608c4f84703724246db29ab4..61e43a9cdcf60974c01a951273ae61fd189f10fa 100644 --- a/examples/raw/painting.sky +++ b/examples/raw/painting.sky @@ -51,7 +51,7 @@ void main() { new DrawLooperLayerInfo() ..setOffset(const Point(150.0, 0.0)) ..setColorMode(TransferMode.srcMode) - ..setPaintBits(-1), + ..setPaintBits(PaintBits.all), (Paint layerPaint) { layerPaint.color = const Color.fromARGB(128, 255, 255, 0); layerPaint.setColorFilter( @@ -64,13 +64,16 @@ void main() { new DrawLooperLayerInfo() ..setOffset(const Point(75.0, 75.0)) ..setColorMode(TransferMode.srcMode) - ..setPaintBits(-1), + ..setPaintBits(PaintBits.shader), (Paint layerPaint) { Gradient redYellow = new Gradient.radial( new Point(0.0, 0.0), radius/3.0, [const Color(0xFFFFFF00), const Color(0xFFFF0000)], null, TileMode.mirror); layerPaint.setShader(redYellow); + // Since we're don't set PaintBits.maskFilter, this has no effect. + layerPaint.setMaskFilter( + new MaskFilter.blur(BlurStyle.normal, 50.0, highQuality: true)); }) ..addLayerOnTop( new DrawLooperLayerInfo()..setOffset(const Point(225.0, 75.0)), diff --git a/examples/raw/shadow.dart b/examples/raw/shadow.dart index 32c401aba51256ac3228d27216187ec925740ea9..d613dfc7f50717c6bdcd7546da25562691d510b5 100644 --- a/examples/raw/shadow.dart +++ b/examples/raw/shadow.dart @@ -15,7 +15,7 @@ void beginFrame(double timeStamp) { // Shadow layer. ..addLayerOnTop( new DrawLooperLayerInfo() - ..setPaintBits(-1) + ..setPaintBits(PaintBits.all) ..setOffset(const Point(5.0, 5.0)) ..setColorMode(TransferMode.srcInMode), (Paint layerPaint) { diff --git a/sdk/lib/framework/painting/shadows.dart b/sdk/lib/framework/painting/shadows.dart index 7919f62071beefb7fff1ee885e179b733dc0ba69..27acccc4506d10bacf4f8784652a4edb9c8ec93a 100644 --- a/sdk/lib/framework/painting/shadows.dart +++ b/sdk/lib/framework/painting/shadows.dart @@ -12,7 +12,7 @@ class ShadowDrawLooperBuilder { void addShadow(sky.Size offset, sky.Color color, double blur) { builder_.addLayerOnTop( new sky.DrawLooperLayerInfo() - ..setPaintBits(-1) + ..setPaintBits(PaintBits.all) ..setOffset(offset.toPoint()) ..setColorMode(sky.TransferMode.srcMode), (sky.Paint layerPaint) {