diff --git a/sky/engine/bindings/dart_ui.cc b/sky/engine/bindings/dart_ui.cc index b7e71288c282ead76666f03417e40dcbe5aff48c..7387929cd29fdea0186ca9cec15b65a92240b791 100644 --- a/sky/engine/bindings/dart_ui.cc +++ b/sky/engine/bindings/dart_ui.cc @@ -8,6 +8,8 @@ #include "sky/engine/bindings/dart_runtime_hooks.h" #include "sky/engine/core/compositing/Scene.h" #include "sky/engine/core/compositing/SceneBuilder.h" +#include "sky/engine/core/painting/DrawLooperLayerInfo.h" +#include "sky/engine/core/painting/LayerDrawLooperBuilder.h" #include "sky/engine/core/painting/painting.h" #include "sky/engine/core/text/Paragraph.h" #include "sky/engine/core/text/ParagraphBuilder.h" @@ -42,6 +44,8 @@ void DartUI::InitForIsolate() { if (!g_natives) { g_natives = new DartLibraryNatives(); DartRuntimeHooks::RegisterNatives(g_natives); + DrawLooperLayerInfo::RegisterNatives(g_natives); + LayerDrawLooperBuilder::RegisterNatives(g_natives); Painting::RegisterNatives(g_natives); Paragraph::RegisterNatives(g_natives); ParagraphBuilder::RegisterNatives(g_natives); diff --git a/sky/engine/core/core.gni b/sky/engine/core/core.gni index 32225c9e696cfd20d11baaac1c412b5955a9781e..6eb3e383a0dbe5eefdd5cb189a9ce52651675bde 100644 --- a/sky/engine/core/core.gni +++ b/sky/engine/core/core.gni @@ -236,12 +236,9 @@ sky_core_files = [ core_idl_files = get_path_info([ "painting/Canvas.idl", "painting/ColorFilter.idl", - "painting/DrawLooper.idl", - "painting/DrawLooperLayerInfo.idl", "painting/Gradient.idl", "painting/Image.idl", "painting/ImageShader.idl", - "painting/LayerDrawLooperBuilder.idl", "painting/MaskFilter.idl", "painting/Path.idl", "painting/Picture.idl", @@ -261,7 +258,6 @@ core_dart_files = get_path_info([ "dart/window.dart", "painting/Color.dart", "painting/ColorFilter.dart", - "painting/DrawLooperLayerInfo.dart", "painting/FilterQuality.dart", "painting/Gradient.dart", "painting/ImageShader.dart", diff --git a/sky/engine/core/dart/painting.dart b/sky/engine/core/dart/painting.dart index a63fa9405dfe2b8a4f3dee8309ed2cd3d4dca06b..f2e8d7dc341d74100c7f3ab9410048b29ff214cf 100644 --- a/sky/engine/core/dart/painting.dart +++ b/sky/engine/core/dart/painting.dart @@ -11,3 +11,42 @@ void decodeImageFromDataPipe(int handle, _ImageDecoderCallback callback) void decodeImageFromList(Uint8List list, _ImageDecoderCallback callback) native "decodeImageFromList"; + +abstract class DrawLooper extends NativeFieldWrapperClass2 { +} + +/// 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; +} + +class DrawLooperLayerInfo extends NativeFieldWrapperClass2 { + void _constructor() native "DrawLooperLayerInfo_constructor"; + DrawLooperLayerInfo() { _constructor(); } + + void setPaintBits(int bits) native "DrawLooperLayerInfo_setPaintBits"; + void setColorMode(TransferMode mode) native "DrawLooperLayerInfo_setColorMode"; + void setOffset(Offset offset) native "DrawLooperLayerInfo_setOffset"; + void setPostTranslate(bool postTranslate) native "DrawLooperLayerInfo_setPostTranslate"; +} + +class LayerDrawLooperBuilder extends NativeFieldWrapperClass2 { + void _constructor() native "LayerDrawLooperBuilder_constructor"; + LayerDrawLooperBuilder() { _constructor(); } + + DrawLooper build() native "LayerDrawLooperBuilder_build"; + void addLayerOnTop(DrawLooperLayerInfo info, Paint paint) native "LayerDrawLooperBuilder_addLayerOnTop"; +} diff --git a/sky/engine/core/painting/DrawLooper.cpp b/sky/engine/core/painting/DrawLooper.cpp index 64c0041ca541644a021a42136fb0a320e2d0db47..c65c4ec35c85af7c2c9678a4c25e49f7e668f497 100644 --- a/sky/engine/core/painting/DrawLooper.cpp +++ b/sky/engine/core/painting/DrawLooper.cpp @@ -6,6 +6,8 @@ namespace blink { +IMPLEMENT_WRAPPERTYPEINFO(DrawLooper); + DrawLooper::DrawLooper(PassRefPtr looper) : looper_(looper) { } diff --git a/sky/engine/core/painting/DrawLooper.idl b/sky/engine/core/painting/DrawLooper.idl deleted file mode 100644 index 8fbda9d1f82e171b595c0d03c1eb0dc652f24f23..0000000000000000000000000000000000000000 --- a/sky/engine/core/painting/DrawLooper.idl +++ /dev/null @@ -1,6 +0,0 @@ -// 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. - -interface DrawLooper { -}; diff --git a/sky/engine/core/painting/DrawLooperLayerInfo.cpp b/sky/engine/core/painting/DrawLooperLayerInfo.cpp index 32494e2799f57b23f894d0264e5468d18bc4195c..785d0dbda36d2dc9e4b6203debfe916046684b3c 100644 --- a/sky/engine/core/painting/DrawLooperLayerInfo.cpp +++ b/sky/engine/core/painting/DrawLooperLayerInfo.cpp @@ -3,9 +3,34 @@ // found in the LICENSE file. #include "sky/engine/core/painting/DrawLooperLayerInfo.h" +#include "sky/engine/tonic/dart_args.h" +#include "sky/engine/tonic/dart_binding_macros.h" +#include "sky/engine/tonic/dart_converter.h" +#include "sky/engine/tonic/dart_library_natives.h" namespace blink { +static void DrawLooperLayerInfo_constructor(Dart_NativeArguments args) { + DartCallConstructor(&DrawLooperLayerInfo::create, args); +} + +IMPLEMENT_WRAPPERTYPEINFO(DrawLooperLayerInfo); + +#define FOR_EACH_BINDING(V) \ + V(DrawLooperLayerInfo, setPaintBits) \ + V(DrawLooperLayerInfo, setColorMode) \ + V(DrawLooperLayerInfo, setOffset) \ + V(DrawLooperLayerInfo, setPostTranslate) + +FOR_EACH_BINDING(DART_NATIVE_CALLBACK) + +void DrawLooperLayerInfo::RegisterNatives(DartLibraryNatives* natives) { + natives->Register({ + { "DrawLooperLayerInfo_constructor", DrawLooperLayerInfo_constructor, 1, true }, +FOR_EACH_BINDING(DART_REGISTER_NATIVE) + }); +} + DrawLooperLayerInfo::DrawLooperLayerInfo() { } diff --git a/sky/engine/core/painting/DrawLooperLayerInfo.dart b/sky/engine/core/painting/DrawLooperLayerInfo.dart deleted file mode 100644 index 625e0339e4987ea3c1ef939f4885646bf410c2cf..0000000000000000000000000000000000000000 --- a/sky/engine/core/painting/DrawLooperLayerInfo.dart +++ /dev/null @@ -1,23 +0,0 @@ -// 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_ui; - -/// 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/sky/engine/core/painting/DrawLooperLayerInfo.h b/sky/engine/core/painting/DrawLooperLayerInfo.h index 4879357761e526e46bbea33263700dc74239209a..fc131cbb6079ac951708e73d4268fa43fc078345 100644 --- a/sky/engine/core/painting/DrawLooperLayerInfo.h +++ b/sky/engine/core/painting/DrawLooperLayerInfo.h @@ -13,6 +13,7 @@ #include "third_party/skia/include/effects/SkLayerDrawLooper.h" namespace blink { +class DartLibraryNatives; class DrawLooperLayerInfo : public RefCounted, public DartWrappable { @@ -25,12 +26,14 @@ class DrawLooperLayerInfo : public RefCounted, ~DrawLooperLayerInfo() override; void setPaintBits(unsigned bits) { layer_info_.fPaintBits = bits; } - void setColorMode(SkXfermode::Mode mode) { layer_info_.fColorMode = mode; } + void setColorMode(TransferMode mode) { layer_info_.fColorMode = mode; } void setOffset(Offset offset) { layer_info_.fOffset = SkPoint::Make(offset.sk_size.width(), offset.sk_size.height()); } void setPostTranslate(bool val) { layer_info_.fPostTranslate = val; } const SkLayerDrawLooper::LayerInfo& layer_info() const { return layer_info_; } + static void RegisterNatives(DartLibraryNatives* natives); + private: DrawLooperLayerInfo(); diff --git a/sky/engine/core/painting/DrawLooperLayerInfo.idl b/sky/engine/core/painting/DrawLooperLayerInfo.idl deleted file mode 100644 index c90b9eeddb025ca0b5d634c4df32a5c5221297f3..0000000000000000000000000000000000000000 --- a/sky/engine/core/painting/DrawLooperLayerInfo.idl +++ /dev/null @@ -1,15 +0,0 @@ -// 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. - -[ - Constructor(), -] interface DrawLooperLayerInfo { - // 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); - void setOffset(Offset offset); - void setPostTranslate(boolean postTranslate); -}; diff --git a/sky/engine/core/painting/LayerDrawLooperBuilder.cpp b/sky/engine/core/painting/LayerDrawLooperBuilder.cpp index 64b6efa91ac2151e26d85f650e23296a80edc0ba..27f2b85816aab50f7b6fd0a8548341d7df49b1e1 100644 --- a/sky/engine/core/painting/LayerDrawLooperBuilder.cpp +++ b/sky/engine/core/painting/LayerDrawLooperBuilder.cpp @@ -7,10 +7,33 @@ #include "sky/engine/core/painting/DrawLooper.h" #include "sky/engine/core/painting/DrawLooperLayerInfo.h" #include "sky/engine/core/painting/Paint.h" +#include "sky/engine/tonic/dart_args.h" +#include "sky/engine/tonic/dart_binding_macros.h" +#include "sky/engine/tonic/dart_converter.h" +#include "sky/engine/tonic/dart_library_natives.h" #include "third_party/skia/include/core/SkColorFilter.h" namespace blink { +static void LayerDrawLooperBuilder_constructor(Dart_NativeArguments args) { + DartCallConstructor(&LayerDrawLooperBuilder::create, args); +} + +IMPLEMENT_WRAPPERTYPEINFO(LayerDrawLooperBuilder); + +#define FOR_EACH_BINDING(V) \ + V(LayerDrawLooperBuilder, build) \ + V(LayerDrawLooperBuilder, addLayerOnTop) + +FOR_EACH_BINDING(DART_NATIVE_CALLBACK) + +void LayerDrawLooperBuilder::RegisterNatives(DartLibraryNatives* natives) { + natives->Register({ + { "LayerDrawLooperBuilder_constructor", LayerDrawLooperBuilder_constructor, 1, true }, +FOR_EACH_BINDING(DART_REGISTER_NATIVE) + }); +} + LayerDrawLooperBuilder::LayerDrawLooperBuilder() { } diff --git a/sky/engine/core/painting/LayerDrawLooperBuilder.h b/sky/engine/core/painting/LayerDrawLooperBuilder.h index a77f7034ae1e15e59f088f0dcdb83c3a8c63395b..662389a2e176afb28bbe04006112d5152409ed63 100644 --- a/sky/engine/core/painting/LayerDrawLooperBuilder.h +++ b/sky/engine/core/painting/LayerDrawLooperBuilder.h @@ -12,7 +12,7 @@ #include "third_party/skia/include/effects/SkLayerDrawLooper.h" namespace blink { - +class DartLibraryNatives; class DrawLooper; class DrawLooperLayerInfo; @@ -28,6 +28,8 @@ class LayerDrawLooperBuilder : public RefCounted, PassRefPtr build(); void addLayerOnTop(DrawLooperLayerInfo* layer_info, const Paint& paint); + static void RegisterNatives(DartLibraryNatives* natives); + private: LayerDrawLooperBuilder(); diff --git a/sky/engine/core/painting/LayerDrawLooperBuilder.idl b/sky/engine/core/painting/LayerDrawLooperBuilder.idl deleted file mode 100644 index b92a71e543f3c4fe58debcbcd8daa7eea3f55cff..0000000000000000000000000000000000000000 --- a/sky/engine/core/painting/LayerDrawLooperBuilder.idl +++ /dev/null @@ -1,12 +0,0 @@ -// 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. -[ - Constructor() -] interface LayerDrawLooperBuilder { - // Returns a DrawLooper based on the construction operations, and resets the - // builder back to a default state. - DrawLooper build(); - - void addLayerOnTop(DrawLooperLayerInfo info, Paint paint); -}; diff --git a/sky/engine/core/painting/Paint.cpp b/sky/engine/core/painting/Paint.cpp index f518e3fc9cdadcc50efa950cc2a1a83556e4a679..73f1ef64e7cffef2c4ee3c1e6e17c18ef826aeb0 100644 --- a/sky/engine/core/painting/Paint.cpp +++ b/sky/engine/core/painting/Paint.cpp @@ -102,9 +102,9 @@ Paint DartConverter::FromDart(Dart_Handle dart_paint) { return result; } -Paint DartConverter::FromArgumentsWithNullCheck(Dart_NativeArguments args, - int index, - Dart_Handle& exception) { +Paint DartConverter::FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { Dart_Handle dart_rect = Dart_GetNativeArgument(args, index); DCHECK(!LogIfError(dart_rect)); return FromDart(dart_rect); diff --git a/sky/engine/core/painting/Paint.h b/sky/engine/core/painting/Paint.h index d5b83c786e63f8d34f7b678e1ff124934883ee13..d89e1d492bef5f3d07646402524ed395b8545479 100644 --- a/sky/engine/core/painting/Paint.h +++ b/sky/engine/core/painting/Paint.h @@ -33,9 +33,14 @@ class Paint { template <> struct DartConverter { static Paint FromDart(Dart_Handle handle); + static Paint FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception); static Paint FromArgumentsWithNullCheck(Dart_NativeArguments args, int index, - Dart_Handle& exception); + Dart_Handle& exception) { + return FromArguments(args, index, exception); + } }; class StrokeCap {};