void Canvas::drawAtlas(CanvasImage* atlas, const Vector<RSTransform>& transforms, const Vector<Rect>& rects, const Vector<SkColor>& colors, TransferMode mode, const Rect& cullRect, const Paint& paint) { if (!m_canvas) return; RefPtr<SkImage> skImage = atlas->image(); Vector<SkRSXform> skXForms; skXForms.reserveInitialCapacity(transforms.size()); for (const RSTransform& transform : transforms) skXForms.append(transform.sk_xform); Vector<SkRect> skRects; skRects.reserveInitialCapacity(rects.size()); for (const Rect& rect : rects) skRects.append(rect.sk_rect); m_canvas->drawAtlas( skImage.get(), skXForms.data(), skRects.data(), colors.isEmpty() ? nullptr : colors.data(), skXForms.size(), mode, cullRect.is_null ? nullptr : &cullRect.sk_rect, paint.paint() ); }
void Canvas::saveLayer(const Rect& bounds, const Paint& paint) { if (!m_canvas) return; m_canvas->saveLayer(!bounds.is_null ? &bounds.sk_rect : nullptr, paint.paint()); }
void Canvas::drawImageNine(const CanvasImage* image, Rect& center, Rect& dst, const Paint& paint) { if (!m_canvas) return; ASSERT(image); SkIRect icenter; center.sk_rect.round(&icenter); m_canvas->drawImageNine(image->image(), icenter, dst.sk_rect, paint.paint()); }
void Canvas::drawVertices(SkCanvas::VertexMode vertexMode, const Vector<Point>& vertices, const Vector<Point>& textureCoordinates, const Vector<SkColor>& colors, SkXfermode::Mode transferMode, const Vector<int>& indices, const Paint& paint, ExceptionState& es) { if (!m_canvas) return; size_t vertexCount = vertices.size(); if (textureCoordinates.size() && textureCoordinates.size() != vertexCount) return es.ThrowRangeError("vertices and textureCoordinates lengths must match"); if (colors.size() && colors.size() != vertexCount) return es.ThrowRangeError("vertices and colors lengths must match"); Vector<SkPoint> skVertices; for (size_t x = 0; x < vertices.size(); x++) { const Point& point = vertices[x]; if (point.is_null) return es.ThrowRangeError("vertices contained a null"); skVertices.append(point.sk_point); } Vector<SkPoint> skTextureCoordinates; for (size_t x = 0; x < textureCoordinates.size(); x++) { const Point& point = textureCoordinates[x]; if (point.is_null) return es.ThrowRangeError("textureCoordinates contained a null"); skTextureCoordinates.append(point.sk_point); } Vector<uint16_t> skIndices; for (size_t x = 0; x < indices.size(); x++) { uint16_t i = indices[x]; skIndices.append(i); } RefPtr<SkXfermode> transferModePtr = adoptRef(SkXfermode::Create(transferMode)); m_canvas->drawVertices( vertexMode, skVertices.size(), skVertices.data(), skTextureCoordinates.isEmpty() ? nullptr : skTextureCoordinates.data(), colors.isEmpty() ? nullptr : colors.data(), transferModePtr.get(), skIndices.isEmpty() ? nullptr : skIndices.data(), skIndices.size(), *paint.paint() ); }
void Canvas::saveLayer(double left, double top, double right, double bottom, const Paint& paint) { if (!m_canvas) return; SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom); m_canvas->saveLayer(&bounds, paint.paint()); }
void Canvas::drawVertices(SkCanvas::VertexMode vertexMode, const std::vector<Point>& vertices, const std::vector<Point>& textureCoordinates, const std::vector<CanvasColor>& colors, TransferMode transferMode, const std::vector<int>& indices, const Paint& paint) { if (!m_canvas) return; std::vector<SkPoint> skVertices; skVertices.reserve(vertices.size()); for (const Point& point : vertices) skVertices.push_back(point.sk_point); std::vector<SkPoint> skTextureCoordinates; skVertices.reserve(textureCoordinates.size()); for (const Point& point : textureCoordinates) skTextureCoordinates.push_back(point.sk_point); std::vector<SkColor> skColors; skColors.reserve(colors.size()); for (const CanvasColor& color : colors) skColors.push_back(color); std::vector<uint16_t> skIndices; skIndices.reserve(indices.size()); for (uint16_t i : indices) skIndices.push_back(i); RefPtr<SkXfermode> transferModePtr = adoptRef(SkXfermode::Create(transferMode)); m_canvas->drawVertices( vertexMode, skVertices.size(), skVertices.data(), skTextureCoordinates.empty() ? nullptr : skTextureCoordinates.data(), skColors.empty() ? nullptr : skColors.data(), transferModePtr.get(), skIndices.empty() ? nullptr : skIndices.data(), skIndices.size(), *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(), SkRect::MakeLTRB(srcLeft, srcTop, srcRight, srcBottom), SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom), paint.paint(), SkCanvas::kFast_SrcRectConstraint); }
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.round(&icenter); m_canvas->drawImageNine(image->image(), icenter, SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom), paint.paint()); }
void Canvas::drawAtlas(CanvasImage* atlas, const Vector<RSTransform>& transforms, const Vector<Rect>& rects, const Vector<SkColor>& colors, SkXfermode::Mode mode, const Rect& cullRect, const Paint& paint, ExceptionState& es) { if (!m_canvas) return; RefPtr<SkImage> skImage = atlas->image(); if (transforms.size() != rects.size()) return es.ThrowRangeError("transforms and rects lengths must match"); if (colors.size() && colors.size() != rects.size()) return es.ThrowRangeError("if supplied, colors length must match that of transforms and rects"); Vector<SkRSXform> skXForms; for (size_t x = 0; x < transforms.size(); x++) { const RSTransform& transform = transforms[x]; if (transform.is_null) return es.ThrowRangeError("transforms contained a null"); skXForms.append(transform.sk_xform); } Vector<SkRect> skRects; for (size_t x = 0; x < rects.size(); x++) { const Rect& rect = rects[x]; if (rect.is_null) return es.ThrowRangeError("rects contained a null"); skRects.append(rect.sk_rect); } m_canvas->drawAtlas( skImage.get(), skXForms.data(), skRects.data(), colors.isEmpty() ? nullptr : colors.data(), skXForms.size(), mode, cullRect.is_null ? nullptr : &cullRect.sk_rect, paint.paint() ); }
void Canvas::drawVertices(SkCanvas::VertexMode vertexMode, const Vector<Point>& vertices, const Vector<Point>& textureCoordinates, const Vector<SkColor>& colors, TransferMode transferMode, const Vector<int>& indices, const Paint& paint) { if (!m_canvas) return; Vector<SkPoint> skVertices; skVertices.reserveInitialCapacity(vertices.size()); for (const Point& point : vertices) skVertices.append(point.sk_point); Vector<SkPoint> skTextureCoordinates; skVertices.reserveInitialCapacity(textureCoordinates.size()); for (const Point& point : textureCoordinates) skTextureCoordinates.append(point.sk_point); Vector<uint16_t> skIndices; skIndices.reserveInitialCapacity(indices.size()); for (uint16_t i : indices) skIndices.append(i); RefPtr<SkXfermode> transferModePtr = adoptRef(SkXfermode::Create(transferMode)); m_canvas->drawVertices( vertexMode, skVertices.size(), skVertices.data(), skTextureCoordinates.isEmpty() ? nullptr : skTextureCoordinates.data(), colors.isEmpty() ? nullptr : colors.data(), transferModePtr.get(), skIndices.isEmpty() ? nullptr : skIndices.data(), skIndices.size(), *paint.paint() ); }
void Canvas::drawAtlas(CanvasImage* atlas, const std::vector<RSTransform>& transforms, const std::vector<Rect>& rects, const std::vector<CanvasColor>& colors, TransferMode mode, const Rect& cullRect, const Paint& paint) { if (!m_canvas) return; RefPtr<SkImage> skImage = atlas->image(); std::vector<SkRSXform> skXForms; skXForms.reserve(transforms.size()); for (const RSTransform& transform : transforms) skXForms.push_back(transform.sk_xform); std::vector<SkRect> skRects; skRects.reserve(rects.size()); for (const Rect& rect : rects) skRects.push_back(rect.sk_rect); std::vector<SkColor> skColors; skColors.reserve(colors.size()); for (const CanvasColor& color : colors) skColors.push_back(color); m_canvas->drawAtlas( skImage.get(), skXForms.data(), skRects.data(), skColors.empty() ? nullptr : skColors.data(), skXForms.size(), mode, cullRect.is_null ? nullptr : &cullRect.sk_rect, paint.paint() ); }
void Canvas::drawImageRect(const CanvasImage* image, Rect& src, Rect& dst, 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); }
void Canvas::drawImage(const CanvasImage* image, const Point& p, const Paint& paint) { if (!m_canvas) return; ASSERT(image); m_canvas->drawImage(image->image(), p.sk_point.x(), p.sk_point.y(), paint.paint()); }
void Canvas::saveLayerWithoutBounds(const Paint& paint) { if (!m_canvas) return; m_canvas->saveLayer(nullptr, 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(), x, y, paint.paint()); }