mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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.
This commit is contained in:
parent
1d23f210d2
commit
c081845efc
@ -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",
|
||||
|
||||
@ -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<Point> 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<Point> vertices,
|
||||
List<Point> 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<RSTransform> transforms,
|
||||
List<Rect> rects,
|
||||
|
||||
@ -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> Canvas::create(PictureRecorder* recorder,
|
||||
Rect& bounds) {
|
||||
double left,
|
||||
double top,
|
||||
double right,
|
||||
double bottom) {
|
||||
ASSERT(recorder);
|
||||
ASSERT(!recorder->isRecording());
|
||||
PassRefPtr<Canvas> canvas = adoptRef(new Canvas(recorder->beginRecording(bounds)));
|
||||
PassRefPtr<Canvas> 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<SkColor>(color),
|
||||
static_cast<SkXfermode::Mode>(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,
|
||||
|
||||
@ -32,42 +32,80 @@ struct DartConverter<SkCanvas::VertexMode> : public DartConverterInteger<SkCanva
|
||||
class Canvas : public ThreadSafeRefCounted<Canvas>, public DartWrappable {
|
||||
DEFINE_WRAPPERTYPEINFO();
|
||||
public:
|
||||
static PassRefPtr<Canvas> create(PictureRecorder* recorder, Rect& bounds);
|
||||
static PassRefPtr<Canvas> 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<Point>& vertices,
|
||||
|
||||
@ -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<FilterQuality>
|
||||
: public DartConverterEnum<SkFilterQuality> {};
|
||||
|
||||
// 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_
|
||||
@ -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<Paint>::FromDart(Dart_Handle dart_paint) {
|
||||
SkPaint& paint = result.sk_paint;
|
||||
|
||||
if (!Dart_IsNull(values[kStyle]))
|
||||
paint.setStyle(DartConverter<PaintingStyle>::FromDart(values[kStyle]));
|
||||
paint.setStyle(static_cast<SkPaint::Style>(DartConverter<int>::FromDart(values[kStyle])));
|
||||
if (!Dart_IsNull(values[kStrokeWidth]))
|
||||
paint.setStrokeWidth(DartConverter<SkScalar>::FromDart(values[kStrokeWidth]));
|
||||
if (!Dart_IsNull(values[kStrokeCap]))
|
||||
paint.setStrokeCap(DartConverter<StrokeCap>::FromDart(values[kStrokeCap]));
|
||||
paint.setStrokeCap(static_cast<SkPaint::Cap>(DartConverter<int>::FromDart(values[kStrokeCap])));
|
||||
if (!Dart_IsNull(values[kIsAntiAlias]))
|
||||
paint.setAntiAlias(DartConverter<bool>::FromDart(values[kIsAntiAlias]));
|
||||
if (!Dart_IsNull(values[kColor]))
|
||||
paint.setColor(DartConverter<CanvasColor>::FromDart(values[kColor]));
|
||||
paint.setColor(static_cast<SkColor>(DartConverter<int>::FromDart(values[kColor])));
|
||||
if (!Dart_IsNull(values[kTransferMode]))
|
||||
paint.setXfermodeMode(DartConverter<TransferMode>::FromDart(values[kTransferMode]));
|
||||
paint.setXfermodeMode(static_cast<SkXfermode::Mode>(DartConverter<int>::FromDart(values[kTransferMode])));
|
||||
if (!Dart_IsNull(values[kColorFilter]))
|
||||
paint.setColorFilter(DartConverter<ColorFilter*>::FromDart(values[kColorFilter])->filter());
|
||||
if (!Dart_IsNull(values[kMaskFilter]))
|
||||
paint.setMaskFilter(DartConverter<MaskFilter*>::FromDart(values[kMaskFilter])->filter());
|
||||
if (!Dart_IsNull(values[kFilterQuality]))
|
||||
paint.setFilterQuality(DartConverter<FilterQuality>::FromDart(values[kFilterQuality]));
|
||||
paint.setFilterQuality(static_cast<SkFilterQuality>(DartConverter<int>::FromDart(values[kFilterQuality])));
|
||||
if (!Dart_IsNull(values[kShader]))
|
||||
paint.setShader(DartConverter<Shader*>::FromDart(values[kShader])->shader());
|
||||
|
||||
|
||||
@ -83,15 +83,15 @@ class Paint {
|
||||
}
|
||||
|
||||
return <dynamic>[
|
||||
style,
|
||||
style.index,
|
||||
strokeWidth,
|
||||
strokeCap,
|
||||
strokeCap.index,
|
||||
isAntiAlias,
|
||||
color,
|
||||
transferMode,
|
||||
color.value,
|
||||
transferMode.index,
|
||||
colorFilter,
|
||||
maskFilter,
|
||||
filterQuality,
|
||||
filterQuality.index,
|
||||
shader,
|
||||
];
|
||||
}
|
||||
|
||||
@ -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<Paint> {
|
||||
Dart_Handle& exception);
|
||||
};
|
||||
|
||||
class StrokeCap {};
|
||||
|
||||
template <>
|
||||
struct DartConverter<StrokeCap>
|
||||
: public DartConverterEnum<SkPaint::Cap> {};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_PAINTING_PAINT_H_
|
||||
|
||||
@ -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<PaintingStyle> : public DartConverterEnum<SkPaint::Style> {
|
||||
};
|
||||
|
||||
// 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_
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ public:
|
||||
|
||||
~PictureRecorder();
|
||||
|
||||
SkCanvas* beginRecording(Rect bounds);
|
||||
SkCanvas* beginRecording(SkRect bounds);
|
||||
PassRefPtr<Picture> endRecording();
|
||||
bool isRecording();
|
||||
|
||||
|
||||
@ -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<RenderBox*> 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<TextBox> Paragraph::getRectsForRange(unsigned start, unsigned end) {
|
||||
|
||||
@ -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<TextBox> getRectsForRange(unsigned start, unsigned end);
|
||||
Dart_Handle getPositionForOffset(const Offset& offset);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user