From c081845efc1887d855a73baa3d9a86ff09ebbab4 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 5 May 2016 19:56:41 -0700 Subject: [PATCH] Remove Dart_GetField from Canvas interface (#2653) These Dart_GetField calls show up on traces. This patch removes almost all of them from the Canvas interface. We still have a few in drawAltas and drawVertices, which will be removed in a later patch. --- sky/engine/core/core.gni | 2 - sky/engine/core/dart/painting.dart | 133 +++++++++++++++++-- sky/engine/core/painting/Canvas.cpp | 113 +++++++++++----- sky/engine/core/painting/Canvas.h | 70 +++++++--- sky/engine/core/painting/FilterQuality.h | 26 ---- sky/engine/core/painting/Paint.cpp | 12 +- sky/engine/core/painting/Paint.dart | 10 +- sky/engine/core/painting/Paint.h | 8 -- sky/engine/core/painting/PaintingStyle.h | 26 ---- sky/engine/core/painting/PictureRecorder.cpp | 4 +- sky/engine/core/painting/PictureRecorder.h | 2 +- sky/engine/core/text/Paragraph.cpp | 6 +- sky/engine/core/text/Paragraph.h | 2 +- 13 files changed, 274 insertions(+), 140 deletions(-) delete mode 100644 sky/engine/core/painting/FilterQuality.h delete mode 100644 sky/engine/core/painting/PaintingStyle.h diff --git a/sky/engine/core/core.gni b/sky/engine/core/core.gni index 9263783f820..dd5a98de52a 100644 --- a/sky/engine/core/core.gni +++ b/sky/engine/core/core.gni @@ -30,7 +30,6 @@ sky_core_files = [ "painting/CanvasPath.h", "painting/ColorFilter.cpp", "painting/ColorFilter.h", - "painting/FilterQuality.h", "painting/ImageFilter.cpp", "painting/ImageFilter.h", "painting/ImageShader.cpp", @@ -45,7 +44,6 @@ sky_core_files = [ "painting/painting.h", "painting/Paint.cpp", "painting/Paint.h", - "painting/PaintingStyle.h", "painting/Picture.cpp", "painting/Picture.h", "painting/PictureRecorder.cpp", diff --git a/sky/engine/core/dart/painting.dart b/sky/engine/core/dart/painting.dart index c7f421f4565..9b987acf19c 100644 --- a/sky/engine/core/dart/painting.dart +++ b/sky/engine/core/dart/painting.dart @@ -356,9 +356,13 @@ class Canvas extends NativeFieldWrapperClass2 { if (recorder.isRecording) throw new ArgumentError('The given PictureRecorder is already associated with another Canvas.'); // TODO(ianh): throw if recorder is defunct (https://github.com/flutter/flutter/issues/2531) - _constructor(recorder, cullRect); + _constructor(recorder, cullRect.left, cullRect.top, cullRect.right, cullRect.bottom); } - void _constructor(PictureRecorder recorder, Rect cullRect) native "Canvas_constructor"; + void _constructor(PictureRecorder recorder, + double left, + double top, + double right, + double bottom) native "Canvas_constructor"; /// Saves a copy of the current transform and clip on the save stack. /// @@ -380,7 +384,19 @@ class Canvas extends NativeFieldWrapperClass2 { /// /// Call [restore] to pop the save stack and apply the paint to the /// group. - void saveLayer(Rect bounds, Paint paint) native "Canvas_saveLayer"; // TODO(jackson): Paint should be optional, but making it optional causes crash + void saveLayer(Rect bounds, Paint paint) { + if (bounds == null) + _saveLayerWithoutBounds(paint); + else + _saveLayer(bounds.left, bounds.top, bounds.right, bounds.bottom, paint); + } + void _saveLayerWithoutBounds(Paint paint) native "Canvas_saveLayerWithoutBounds"; + // TODO(jackson): Paint should be optional, but making it optional causes crash + void _saveLayer(double left, + double top, + double right, + double bottom, + Paint paint) native "Canvas_saveLayer"; /// Pops the current save stack, if there is anything to pop. /// Otherwise, does nothing. @@ -416,27 +432,113 @@ class Canvas extends NativeFieldWrapperClass2 { void _setMatrix(Float64List matrix4) native "Canvas_setMatrix"; Float64List getTotalMatrix() native "Canvas_getTotalMatrix"; - void clipRect(Rect rect) native "Canvas_clipRect"; + void clipRect(Rect rect) { + _clipRect(rect.left, rect.top, rect.right, rect.bottom); + } + void _clipRect(double left, + double top, + double right, + double bottom) native "Canvas_clipRect"; + void clipRRect(RRect rrect) native "Canvas_clipRRect"; + void clipPath(Path path) native "Canvas_clipPath"; - void drawColor(Color color, TransferMode transferMode) native "Canvas_drawColor"; - void drawLine(Point p1, Point p2, Paint paint) native "Canvas_drawLine"; + + void drawColor(Color color, TransferMode transferMode) { + _drawColor(color.value, transferMode.index); + } + void _drawColor(int color, int transferMode) native "Canvas_drawColor"; + + void drawLine(Point p1, Point p2, Paint paint) { + _drawLine(p1.x, p1.y, p2.x, p2.y, paint); + } + void _drawLine(double x1, double y1, double x2, double y2, Paint paint) native "Canvas_drawLine"; + void drawPaint(Paint paint) native "Canvas_drawPaint"; - void drawRect(Rect rect, Paint paint) native "Canvas_drawRect"; + + void drawRect(Rect rect, Paint paint) { + _drawRect(rect.left, rect.top, rect.right, rect.bottom, paint); + } + void _drawRect(double left, + double top, + double right, + double bottom, + Paint paint) native "Canvas_drawRect"; + void drawRRect(RRect rrect, Paint paint) native "Canvas_drawRRect"; + void drawDRRect(RRect outer, RRect inner, Paint paint) native "Canvas_drawDRRect"; - void drawOval(Rect rect, Paint paint) native "Canvas_drawOval"; - void drawCircle(Point c, double radius, Paint paint) native "Canvas_drawCircle"; + + void drawOval(Rect rect, Paint paint) { + _drawOval(rect.left, rect.top, rect.right, rect.bottom, paint); + } + void _drawOval(double left, + double top, + double right, + double bottom, + Paint paint) native "Canvas_drawOval"; + + void drawCircle(Point c, double radius, Paint paint) { + _drawCircle(c.x, c.y, radius, paint); + } + void _drawCircle(double x, double y, double radius, Paint paint) native "Canvas_drawCircle"; + void drawPath(Path path, Paint paint) native "Canvas_drawPath"; - void drawImage(Image image, Point p, Paint paint) native "Canvas_drawImage"; + + void drawImage(Image image, Point p, Paint paint) { + _drawImage(image, p.x, p.y, paint); + } + void _drawImage(Image image, double x, double y, Paint paint) native "Canvas_drawImage"; /// Draws the src rect from the image into the canvas as dst rect. /// /// Might sample from outside the src rect by half the width of an applied /// filter. - void drawImageRect(Image image, Rect src, Rect dst, Paint paint) native "Canvas_drawImageRect"; + void drawImageRect(Image image, Rect src, Rect dst, Paint paint) { + _drawImageRect(image, + src.left, + src.top, + src.right, + src.bottom, + dst.left, + dst.top, + dst.right, + dst.bottom, + paint); + } + void _drawImageRect(Image image, + double srcLeft, + double srcTop, + double srcRight, + double srcBottom, + double dstLeft, + double dstTop, + double dstRight, + double dstBottom, + Paint paint) native "Canvas_drawImageRect"; - void drawImageNine(Image image, Rect center, Rect dst, Paint paint) native "Canvas_drawImageNine"; + void drawImageNine(Image image, Rect center, Rect dst, Paint paint) { + _drawImageNine(image, + center.left, + center.top, + center.right, + center.bottom, + dst.left, + dst.top, + dst.right, + dst.bottom, + paint); + } + void _drawImageNine(Image image, + double centerLeft, + double centerTop, + double centerRight, + double centerBottom, + double dstLeft, + double dstTop, + double dstRight, + double dstBottom, + Paint paint) native "Canvas_drawImageNine"; /// Draw the given picture onto the canvas. To create a picture, see /// [PictureRecorder]. @@ -445,7 +547,10 @@ class Canvas extends NativeFieldWrapperClass2 { /// Draws the text in the given paragraph into this canvas at the given offset. /// /// Valid only after [Paragraph.layout] has been called on the paragraph. - void drawParagraph(Paragraph paragraph, Offset offset) native "Canvas_drawParagraph"; + void drawParagraph(Paragraph paragraph, Offset offset) { + _drawParagraph(paragraph, offset.dx, offset.dy); + } + void _drawParagraph(Paragraph paragraph, double x, double y) native "Canvas_drawParagraph"; void drawVertices(VertexMode vertexMode, List vertices, @@ -469,6 +574,7 @@ class Canvas extends NativeFieldWrapperClass2 { } _drawVertices(vertexMode.index, vertices, textureCoordinates, colors, transferMode, indicies, paint); } + // TODO(abarth): Convert to primitives. void _drawVertices(int vertexMode, List vertices, List textureCoordinates, @@ -498,6 +604,7 @@ class Canvas extends NativeFieldWrapperClass2 { } _drawAtlas(image, transforms, rects, colors, mode, cullRect, paint); } + // TODO(abarth): Convert to primitives. void _drawAtlas(Image image, List transforms, List rects, diff --git a/sky/engine/core/painting/Canvas.cpp b/sky/engine/core/painting/Canvas.cpp index dfaaf3950e9..2e9b072b0f8 100644 --- a/sky/engine/core/painting/Canvas.cpp +++ b/sky/engine/core/painting/Canvas.cpp @@ -27,6 +27,7 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Canvas); #define FOR_EACH_BINDING(V) \ V(Canvas, save) \ + V(Canvas, saveLayerWithoutBounds) \ V(Canvas, saveLayer) \ V(Canvas, restore) \ V(Canvas, getSaveCount) \ @@ -67,10 +68,14 @@ FOR_EACH_BINDING(DART_REGISTER_NATIVE) } PassRefPtr Canvas::create(PictureRecorder* recorder, - Rect& bounds) { + double left, + double top, + double right, + double bottom) { ASSERT(recorder); ASSERT(!recorder->isRecording()); - PassRefPtr canvas = adoptRef(new Canvas(recorder->beginRecording(bounds))); + PassRefPtr canvas = adoptRef(new Canvas(recorder->beginRecording( + SkRect::MakeLTRB(left, top, right, bottom)))); recorder->set_canvas(canvas.get()); return canvas; } @@ -91,12 +96,22 @@ void Canvas::save() m_canvas->save(); } -void Canvas::saveLayer(const Rect& bounds, const Paint& paint) +void Canvas::saveLayerWithoutBounds(const Paint& paint) { + if (!m_canvas) + return; + m_canvas->saveLayer(nullptr, paint.paint()); +} + +void Canvas::saveLayer(double left, + double top, + double right, + double bottom, + const Paint& paint) { if (!m_canvas) return; - m_canvas->saveLayer(!bounds.is_null ? &bounds.sk_rect : nullptr, - paint.paint()); + SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom); + m_canvas->saveLayer(&bounds, paint.paint()); } void Canvas::restore() @@ -113,28 +128,28 @@ int Canvas::getSaveCount() return m_canvas->getSaveCount(); } -void Canvas::translate(float dx, float dy) +void Canvas::translate(double dx, double dy) { if (!m_canvas) return; m_canvas->translate(dx, dy); } -void Canvas::scale(float sx, float sy) +void Canvas::scale(double sx, double sy) { if (!m_canvas) return; m_canvas->scale(sx, sy); } -void Canvas::rotate(float radians) +void Canvas::rotate(double radians) { if (!m_canvas) return; m_canvas->rotate(radians * 180.0/M_PI); } -void Canvas::skew(float sx, float sy) +void Canvas::skew(double sx, double sy) { if (!m_canvas) return; @@ -164,11 +179,14 @@ Float64List Canvas::getTotalMatrix() return toMatrix4(sk_matrix); } -void Canvas::clipRect(const Rect& rect) +void Canvas::clipRect(double left, + double top, + double right, + double bottom) { if (!m_canvas) return; - m_canvas->clipRect(rect.sk_rect); + m_canvas->clipRect(SkRect::MakeLTRB(left, top, right, bottom)); } void Canvas::clipRRect(const RRect& rrect) @@ -185,18 +203,19 @@ void Canvas::clipPath(const CanvasPath* path) m_canvas->clipPath(path->path(), SkRegion::kIntersect_Op); } -void Canvas::drawColor(CanvasColor color, TransferMode transferMode) +void Canvas::drawColor(int color, int transferMode) { if (!m_canvas) return; - m_canvas->drawColor(color, transferMode); + m_canvas->drawColor(static_cast(color), + static_cast(transferMode)); } -void Canvas::drawLine(const Point& p1, const Point& p2, const Paint& paint) +void Canvas::drawLine(double x1, double y1, double x2, double y2, const Paint& paint) { if (!m_canvas) return; - m_canvas->drawLine(p1.sk_point.x(), p1.sk_point.y(), p2.sk_point.x(), p2.sk_point.y(), paint.sk_paint); + m_canvas->drawLine(x1, y1, x2, y2, paint.sk_paint); } void Canvas::drawPaint(const Paint& paint) @@ -206,11 +225,15 @@ void Canvas::drawPaint(const Paint& paint) m_canvas->drawPaint(paint.sk_paint); } -void Canvas::drawRect(const Rect& rect, const Paint& paint) +void Canvas::drawRect(double left, + double top, + double right, + double bottom, + const Paint& paint) { if (!m_canvas) return; - m_canvas->drawRect(rect.sk_rect, paint.sk_paint); + m_canvas->drawRect(SkRect::MakeLTRB(left, top, right, bottom), paint.sk_paint); } void Canvas::drawRRect(const RRect& rrect, const Paint& paint) @@ -227,18 +250,22 @@ void Canvas::drawDRRect(const RRect& outer, const RRect& inner, const Paint& pai m_canvas->drawDRRect(outer.sk_rrect, inner.sk_rrect, paint.sk_paint); } -void Canvas::drawOval(const Rect& rect, const Paint& paint) +void Canvas::drawOval(double left, + double top, + double right, + double bottom, + const Paint& paint) { if (!m_canvas) return; - m_canvas->drawOval(rect.sk_rect, paint.sk_paint); + m_canvas->drawOval(SkRect::MakeLTRB(left, top, right, bottom), paint.sk_paint); } -void Canvas::drawCircle(const Point& c, float radius, const Paint& paint) +void Canvas::drawCircle(double x, double y, double radius, const Paint& paint) { if (!m_canvas) return; - m_canvas->drawCircle(c.sk_point.x(), c.sk_point.y(), radius, paint.sk_paint); + m_canvas->drawCircle(x, y, radius, paint.sk_paint); } void Canvas::drawPath(const CanvasPath* path, const Paint& paint) @@ -249,27 +276,53 @@ void Canvas::drawPath(const CanvasPath* path, const Paint& paint) m_canvas->drawPath(path->path(), paint.sk_paint); } -void Canvas::drawImage(const CanvasImage* image, const Point& p, const Paint& paint) { +void Canvas::drawImage(const CanvasImage* image, double x, double y, const Paint& paint) { if (!m_canvas) return; ASSERT(image); - m_canvas->drawImage(image->image(), p.sk_point.x(), p.sk_point.y(), paint.paint()); + m_canvas->drawImage(image->image(), x, y, paint.paint()); } -void Canvas::drawImageRect(const CanvasImage* image, Rect& src, Rect& dst, const Paint& paint) { +void Canvas::drawImageRect(const CanvasImage* image, + double srcLeft, + double srcTop, + double srcRight, + double srcBottom, + double dstLeft, + double dstTop, + double dstRight, + double dstBottom, + const Paint& paint) { if (!m_canvas) return; ASSERT(image); - m_canvas->drawImageRect(image->image(), src.sk_rect, dst.sk_rect, paint.paint(), SkCanvas::kFast_SrcRectConstraint); + m_canvas->drawImageRect(image->image(), + SkRect::MakeLTRB(srcLeft, srcTop, srcRight, srcBottom), + SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom), + paint.paint(), + SkCanvas::kFast_SrcRectConstraint); } -void Canvas::drawImageNine(const CanvasImage* image, Rect& center, Rect& dst, const Paint& paint) { +void Canvas::drawImageNine(const CanvasImage* image, + double centerLeft, + double centerTop, + double centerRight, + double centerBottom, + double dstLeft, + double dstTop, + double dstRight, + double dstBottom, + const Paint& paint) { if (!m_canvas) return; ASSERT(image); + SkRect center = SkRect::MakeLTRB(centerLeft, centerTop, centerRight, centerBottom); SkIRect icenter; - center.sk_rect.round(&icenter); - m_canvas->drawImageNine(image->image(), icenter, dst.sk_rect, paint.paint()); + center.round(&icenter); + m_canvas->drawImageNine(image->image(), + icenter, + SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom), + paint.paint()); } void Canvas::drawPicture(Picture* picture) @@ -280,11 +333,11 @@ void Canvas::drawPicture(Picture* picture) m_canvas->drawPicture(picture->toSkia().get()); } -void Canvas::drawParagraph(Paragraph* paragraph, const Offset& offset) { +void Canvas::drawParagraph(Paragraph* paragraph, double x, double y) { if (!m_canvas) return; ASSERT(paragraph); - paragraph->paint(this, offset); + paragraph->paint(this, x, y); } void Canvas::drawVertices(SkCanvas::VertexMode vertexMode, diff --git a/sky/engine/core/painting/Canvas.h b/sky/engine/core/painting/Canvas.h index 9c3b28b4f71..43fc289dc4e 100644 --- a/sky/engine/core/painting/Canvas.h +++ b/sky/engine/core/painting/Canvas.h @@ -32,42 +32,80 @@ struct DartConverter : public DartConverterInteger, public DartWrappable { DEFINE_WRAPPERTYPEINFO(); public: - static PassRefPtr create(PictureRecorder* recorder, Rect& bounds); + static PassRefPtr create(PictureRecorder* recorder, + double left, + double top, + double right, + double bottom); ~Canvas() override; void save(); - void saveLayer(const Rect& bounds, const Paint& paint); + void saveLayerWithoutBounds(const Paint& paint); + void saveLayer(double left, + double top, + double right, + double bottom, + const Paint& paint); void restore(); int getSaveCount(); - void translate(float dx, float dy); - void scale(float sx, float sy); - void rotate(float radians); - void skew(float sx, float sy); + void translate(double dx, double dy); + void scale(double sx, double sy); + void rotate(double radians); + void skew(double sx, double sy); void transform(const Float64List& matrix4); void setMatrix(const Float64List& matrix4); Float64List getTotalMatrix(); - void clipRect(const Rect& rect); + void clipRect(double left, + double top, + double right, + double bottom); void clipRRect(const RRect& rrect); void clipPath(const CanvasPath* path); - void drawColor(CanvasColor color, TransferMode transferMode); - void drawLine(const Point& p1, const Point& p2, const Paint& paint); + void drawColor(int color, int transferMode); + void drawLine(double x1, double y1, double x2, double y2, const Paint& paint); void drawPaint(const Paint& paint); - void drawRect(const Rect& rect, const Paint& paint); + void drawRect(double left, + double top, + double right, + double bottom, + const Paint& paint); void drawRRect(const RRect& rrect, const Paint& paint); void drawDRRect(const RRect& outer, const RRect& inner, const Paint& paint); - void drawOval(const Rect& rect, const Paint& paint); - void drawCircle(const Point& c, float radius, const Paint& paint); + void drawOval(double left, + double top, + double right, + double bottom, + const Paint& paint); + void drawCircle(double x, double y, double radius, const Paint& paint); void drawPath(const CanvasPath* path, const Paint& paint); - void drawImage(const CanvasImage* image, const Point& p, const Paint& paint); - void drawImageRect(const CanvasImage* image, Rect& src, Rect& dst, const Paint& paint); - void drawImageNine(const CanvasImage* image, Rect& center, Rect& dst, const Paint& paint); + void drawImage(const CanvasImage* image, double x, double y, const Paint& paint); + void drawImageRect(const CanvasImage* image, + double srcLeft, + double srcTop, + double srcRight, + double srcBottom, + double dstLeft, + double dstTop, + double dstRight, + double dstBottom, + const Paint& paint); + void drawImageNine(const CanvasImage* image, + double centerLeft, + double centerTop, + double centerRight, + double centerBottom, + double dstLeft, + double dstTop, + double dstRight, + double dstBottom, + const Paint& paint); void drawPicture(Picture* picture); - void drawParagraph(Paragraph* paragraph, const Offset& offset); + void drawParagraph(Paragraph* paragraph, double x, double y); void drawVertices(SkCanvas::VertexMode vertexMode, const std::vector& vertices, diff --git a/sky/engine/core/painting/FilterQuality.h b/sky/engine/core/painting/FilterQuality.h deleted file mode 100644 index adef85a81c8..00000000000 --- a/sky/engine/core/painting/FilterQuality.h +++ /dev/null @@ -1,26 +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. - -#ifndef SKY_ENGINE_CORE_PAINTING_FILTERQUALITY_H_ -#define SKY_ENGINE_CORE_PAINTING_FILTERQUALITY_H_ - -#include "sky/engine/tonic/dart_converter.h" -#include "third_party/skia/include/core/SkXfermode.h" - -namespace blink { - -class FilterQuality {}; - -template <> -struct DartConverter - : public DartConverterEnum {}; - -// If this fails, it's because SkFilterQuality has changed. We need to change -// FilterQuality.dart to ensure the FilterQuality enum is in sync with the C++ -// values. -COMPILE_ASSERT(SkFilterQuality::kHigh_SkFilterQuality == 3, Need_to_update_FilterQuality_dart); - -} // namespace blink - -#endif // SKY_ENGINE_CORE_PAINTING_FILTERQUALITY_H_ diff --git a/sky/engine/core/painting/Paint.cpp b/sky/engine/core/painting/Paint.cpp index f9bb4265250..24f4d31c30e 100644 --- a/sky/engine/core/painting/Paint.cpp +++ b/sky/engine/core/painting/Paint.cpp @@ -6,9 +6,7 @@ #include "sky/engine/core/painting/CanvasColor.h" #include "sky/engine/core/painting/ColorFilter.h" -#include "sky/engine/core/painting/FilterQuality.h" #include "sky/engine/core/painting/MaskFilter.h" -#include "sky/engine/core/painting/PaintingStyle.h" #include "sky/engine/core/painting/Shader.h" #include "sky/engine/core/painting/TransferMode.h" #include "sky/engine/core/script/ui_dart_state.h" @@ -76,23 +74,23 @@ Paint DartConverter::FromDart(Dart_Handle dart_paint) { SkPaint& paint = result.sk_paint; if (!Dart_IsNull(values[kStyle])) - paint.setStyle(DartConverter::FromDart(values[kStyle])); + paint.setStyle(static_cast(DartConverter::FromDart(values[kStyle]))); if (!Dart_IsNull(values[kStrokeWidth])) paint.setStrokeWidth(DartConverter::FromDart(values[kStrokeWidth])); if (!Dart_IsNull(values[kStrokeCap])) - paint.setStrokeCap(DartConverter::FromDart(values[kStrokeCap])); + paint.setStrokeCap(static_cast(DartConverter::FromDart(values[kStrokeCap]))); if (!Dart_IsNull(values[kIsAntiAlias])) paint.setAntiAlias(DartConverter::FromDart(values[kIsAntiAlias])); if (!Dart_IsNull(values[kColor])) - paint.setColor(DartConverter::FromDart(values[kColor])); + paint.setColor(static_cast(DartConverter::FromDart(values[kColor]))); if (!Dart_IsNull(values[kTransferMode])) - paint.setXfermodeMode(DartConverter::FromDart(values[kTransferMode])); + paint.setXfermodeMode(static_cast(DartConverter::FromDart(values[kTransferMode]))); if (!Dart_IsNull(values[kColorFilter])) paint.setColorFilter(DartConverter::FromDart(values[kColorFilter])->filter()); if (!Dart_IsNull(values[kMaskFilter])) paint.setMaskFilter(DartConverter::FromDart(values[kMaskFilter])->filter()); if (!Dart_IsNull(values[kFilterQuality])) - paint.setFilterQuality(DartConverter::FromDart(values[kFilterQuality])); + paint.setFilterQuality(static_cast(DartConverter::FromDart(values[kFilterQuality]))); if (!Dart_IsNull(values[kShader])) paint.setShader(DartConverter::FromDart(values[kShader])->shader()); diff --git a/sky/engine/core/painting/Paint.dart b/sky/engine/core/painting/Paint.dart index f2c2890fc99..4aa6bcd01fd 100644 --- a/sky/engine/core/painting/Paint.dart +++ b/sky/engine/core/painting/Paint.dart @@ -83,15 +83,15 @@ class Paint { } return [ - style, + style.index, strokeWidth, - strokeCap, + strokeCap.index, isAntiAlias, - color, - transferMode, + color.value, + transferMode.index, colorFilter, maskFilter, - filterQuality, + filterQuality.index, shader, ]; } diff --git a/sky/engine/core/painting/Paint.h b/sky/engine/core/painting/Paint.h index 377ccc0577e..68a3763009d 100644 --- a/sky/engine/core/painting/Paint.h +++ b/sky/engine/core/painting/Paint.h @@ -6,9 +6,7 @@ #define SKY_ENGINE_CORE_PAINTING_PAINT_H_ #include "sky/engine/core/painting/CanvasColor.h" -#include "sky/engine/core/painting/PaintingStyle.h" #include "sky/engine/core/painting/TransferMode.h" -#include "sky/engine/core/painting/FilterQuality.h" #include "sky/engine/tonic/dart_wrappable.h" #include "sky/engine/wtf/PassRefPtr.h" #include "sky/engine/wtf/RefCounted.h" @@ -37,12 +35,6 @@ struct DartConverter { Dart_Handle& exception); }; -class StrokeCap {}; - -template <> -struct DartConverter - : public DartConverterEnum {}; - } // namespace blink #endif // SKY_ENGINE_CORE_PAINTING_PAINT_H_ diff --git a/sky/engine/core/painting/PaintingStyle.h b/sky/engine/core/painting/PaintingStyle.h deleted file mode 100644 index 797b82d81d7..00000000000 --- a/sky/engine/core/painting/PaintingStyle.h +++ /dev/null @@ -1,26 +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. - -#ifndef SKY_ENGINE_CORE_PAINTING_PAINTINGSTYLE_H_ -#define SKY_ENGINE_CORE_PAINTING_PAINTINGSTYLE_H_ - -#include "sky/engine/tonic/dart_converter.h" -#include "third_party/skia/include/core/SkPaint.h" - -namespace blink { - -class PaintingStyle {}; - -template <> -struct DartConverter : public DartConverterEnum { -}; - -// If this fails, it's because SkPaint::Style has changed. We need to change -// PaintingStyle.dart to ensure the PaintingStyle enum is in sync with the C++ -// values. -COMPILE_ASSERT(SkPaint::kStyleCount == 3, Need_to_update_PaintingStyle_dart); - -} // namespace blink - -#endif // SKY_ENGINE_CORE_PAINTING_PAINTINGSTYLE_H_ diff --git a/sky/engine/core/painting/PictureRecorder.cpp b/sky/engine/core/painting/PictureRecorder.cpp index 0672bf33c98..007a604929c 100644 --- a/sky/engine/core/painting/PictureRecorder.cpp +++ b/sky/engine/core/painting/PictureRecorder.cpp @@ -44,9 +44,9 @@ bool PictureRecorder::isRecording() { return m_canvas && m_canvas->isRecording(); } -SkCanvas* PictureRecorder::beginRecording(Rect bounds) +SkCanvas* PictureRecorder::beginRecording(SkRect bounds) { - return m_pictureRecorder.beginRecording(bounds.sk_rect, + return m_pictureRecorder.beginRecording(bounds, &m_rtreeFactory, SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag); } diff --git a/sky/engine/core/painting/PictureRecorder.h b/sky/engine/core/painting/PictureRecorder.h index 867e533db0a..2758eaa1d6b 100644 --- a/sky/engine/core/painting/PictureRecorder.h +++ b/sky/engine/core/painting/PictureRecorder.h @@ -27,7 +27,7 @@ public: ~PictureRecorder(); - SkCanvas* beginRecording(Rect bounds); + SkCanvas* beginRecording(SkRect bounds); PassRefPtr endRecording(); bool isRecording(); diff --git a/sky/engine/core/text/Paragraph.cpp b/sky/engine/core/text/Paragraph.cpp index 9a37b77a2fc..b5dda70ad39 100644 --- a/sky/engine/core/text/Paragraph.cpp +++ b/sky/engine/core/text/Paragraph.cpp @@ -84,14 +84,14 @@ void Paragraph::layout(double width) m_renderView->layout(); } -void Paragraph::paint(Canvas* canvas, const Offset& offset) +void Paragraph::paint(Canvas* canvas, double x, double y) { FontCachePurgePreventer fontCachePurgePreventer; // Very simplified painting to allow painting an arbitrary (layer-less) subtree. RenderBox* box = firstChildBox(); SkCanvas* skCanvas = canvas->skCanvas(); - skCanvas->translate(offset.sk_size.width(), offset.sk_size.height()); + skCanvas->translate(x, y); GraphicsContext context(skCanvas); Vector layers; @@ -102,7 +102,7 @@ void Paragraph::paint(Canvas* canvas, const Offset& offset) // Note we're ignoring any layers encountered. // TODO(abarth): Remove the concept of RenderLayers. - skCanvas->translate(-offset.sk_size.width(), -offset.sk_size.height()); + skCanvas->translate(-x, -y); } std::vector Paragraph::getRectsForRange(unsigned start, unsigned end) { diff --git a/sky/engine/core/text/Paragraph.h b/sky/engine/core/text/Paragraph.h index 70eccc904e1..3aa3f9bcabe 100644 --- a/sky/engine/core/text/Paragraph.h +++ b/sky/engine/core/text/Paragraph.h @@ -33,7 +33,7 @@ public: double ideographicBaseline(); void layout(double width); - void paint(Canvas* canvas, const Offset& offset); + void paint(Canvas* canvas, double x, double y); std::vector getRectsForRange(unsigned start, unsigned end); Dart_Handle getPositionForOffset(const Offset& offset);