From 85670ba03d1d3213d410f229cb95fc571266bd2f Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Thu, 11 Jun 2015 15:41:12 -0400 Subject: [PATCH] Expose and use constants for DrawLooperLayerInfo.setPaintBits to dart. R=abarth@chromium.org Review URL: https://codereview.chromium.org/1175403002. --- engine/core/core.gni | 1 + engine/core/painting/DrawLooperLayerInfo.dart | 23 +++++++++++++++++++ engine/core/painting/DrawLooperLayerInfo.idl | 20 +++------------- examples/raw/painting.sky | 7 ++++-- examples/raw/shadow.dart | 2 +- sdk/lib/framework/painting/shadows.dart | 2 +- 6 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 engine/core/painting/DrawLooperLayerInfo.dart diff --git a/engine/core/core.gni b/engine/core/core.gni index fab3211c3a..85e6052628 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 0000000000..6f7647c1a8 --- /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 75614b61b2..5fed53d5c7 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 03d2d02fd6..61e43a9cdc 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 32c401aba5..d613dfc7f5 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 7919f62071..27acccc450 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) { -- GitLab