Ticket #17665: 0001-GraphicsContextHaiku-add-tracing.patch

File 0001-GraphicsContextHaiku-add-tracing.patch, 13.0 KB (added by nephele, 2 years ago)

Patch to enable tracing in webkit GraphicsContextHaiku

  • Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp

    From e592e5b408827f89c931ceb5a1a5c2a0dd1cb0a2 Mon Sep 17 00:00:00 2001
    From: Pascal Abresch <nep@packageloss.eu>
    Date: Sat, 19 Mar 2022 18:15:21 +0100
    Subject: [PATCH] GraphicsContextHaiku: add tracing
    
    ---
     .../graphics/haiku/GraphicsContextHaiku.cpp   | 48 +++++++++++++++++++
     1 file changed, 48 insertions(+)
    
    diff --git a/Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp b/Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp
    index 42b4be465c..75726a3a93 100644
    a b  
    4848#include <Window.h>
    4949#include <stdio.h>
    5050
     51#define TRACE_GRAPHICS_HAIKU
     52#ifdef TRACE_GRAPHICS_HAIKU
     53#   define HGTRACE(x) printf x
     54#else
     55#   define HGTRACE(x) ;
     56#endif
     57
    5158namespace WebCore {
    5259
    5360
    GraphicsContextHaiku::~GraphicsContextHaiku()  
    6471// Draws a filled rectangle with a stroked border.
    6572void GraphicsContextHaiku::drawRect(const FloatRect& rect, float borderThickness)
    6673{
     74    HGTRACE(("drawRect: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height()));
    6775    if (m_state.fillPattern)
    6876        notImplemented();
    6977    else if (m_state.fillGradient) {
    void GraphicsContextHaiku::drawRect(const FloatRect& rect, float borderThickness  
    8189
    8290void GraphicsContextHaiku::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
    8391{
     92    HGTRACE(("drawNativeImage:  src([%f:%f] [%f:%f])\n", srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height()));
     93    HGTRACE(("                 dest([%f:%f] [%f:%f])\n", destRect.x(), destRect.y(), destRect.width(), destRect.height()));
    8494    drawBitmap(image.platformImage().get(), imageSize, destRect, srcRect, options);
    8595}
    8696
    8797void GraphicsContextHaiku::drawBitmap(BBitmap* image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
    8898{
     99    HGTRACE(("drawBitmap:  src([%f:%f] [%f:%f])\n", srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height()));
     100    HGTRACE(("            dest([%f:%f] [%f:%f])\n", destRect.x(), destRect.y(), destRect.width(), destRect.height()));
    89101    m_view->PushState();
    90102    setCompositeOperation(options.compositeOperator());
    91103
    void GraphicsContextHaiku::drawBitmap(BBitmap* image, const FloatSize& imageSize  
    107119// This is only used to draw borders.
    108120void GraphicsContextHaiku::drawLine(const FloatPoint& point1, const FloatPoint& point2)
    109121{
     122    HGTRACE(("drawline: [%f:%f] [%f:%f])\n", point1.x(), point1.y(), point2.x(), point2.y()));
    110123    if (strokeStyle() == NoStroke || !strokeColor().isVisible())
    111124        return;
    112125    m_view->StrokeLine(point1, point2, m_strokeStyle);
    void GraphicsContextHaiku::drawLine(const FloatPoint& point1, const FloatPoint&  
    115128// This method is only used to draw the little circles used in lists.
    116129void GraphicsContextHaiku::drawEllipse(const FloatRect& rect)
    117130{
     131    HGTRACE(("drawEllipse: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height()));
    118132    if (m_state.fillPattern || m_state.fillGradient || fillColor().isVisible()) {
    119133//        TODO: What's this shadow business?
    120134        if (m_state.fillPattern)
    void GraphicsContextHaiku::drawEllipse(const FloatRect& rect)  
    133147
    134148void GraphicsContextHaiku::strokeRect(const FloatRect& rect, float width)
    135149{
     150    HGTRACE(("strokeRect: [%f:%f] [%f:%f] width:%f\n", rect.x(), rect.y(), rect.width(), rect.height(), width));
    136151    if (strokeStyle() == NoStroke || width <= 0.0f || !strokeColor().isVisible())
    137152        return;
    138153
    void GraphicsContextHaiku::strokeRect(const FloatRect& rect, float width)  
    145160
    146161void GraphicsContextHaiku::strokePath(const Path& path)
    147162{
     163    HGTRACE(("strokePath: (--todo print values)\n"));
    148164    m_view->MovePenTo(B_ORIGIN);
    149165
    150166    // TODO: stroke the shadow (cf shadowAndStrokeCurrentCairoPath)
    void GraphicsContextHaiku::strokePath(const Path& path)  
    167183
    168184void GraphicsContextHaiku::fillRect(const FloatRect& rect, const Color& color)
    169185{
     186    HGTRACE(("fillRect(color): [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height()));
    170187    rgb_color previousColor = m_view->HighColor();
    171188
    172189#if 0
    void GraphicsContextHaiku::fillRect(const FloatRect& rect, const Color& color)  
    185202
    186203void GraphicsContextHaiku::fillRect(const FloatRect& rect)
    187204{
     205    HGTRACE(("fillRect: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height()));
    188206    // TODO fill the shadow
    189207    m_view->FillRect(rect, B_SOLID_LOW);
    190208}
    191209
    192210void GraphicsContextHaiku::fillRoundedRectImpl(const FloatRoundedRect& roundRect, const Color& color)
    193211{
     212    HGTRACE(("fillRoundedRectImpl: (--todo print values)\n"));
    194213    if (!color.isVisible())
    195214        return;
    196215
    void GraphicsContextHaiku::fillRoundedRectImpl(const FloatRoundedRect& roundRect  
    254273
    255274void GraphicsContextHaiku::fillPath(const Path& path)
    256275{
     276    HGTRACE(("fillPath: (--todo print values)\n"));
    257277    m_view->SetFillRule(fillRule() == WindRule::NonZero ? B_NONZERO : B_EVEN_ODD);
    258278    m_view->MovePenTo(B_ORIGIN);
    259279
    void GraphicsContextHaiku::fillPath(const Path& path)  
    278298
    279299void GraphicsContextHaiku::clip(const FloatRect& rect)
    280300{
     301    HGTRACE(("clip: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height()));
    281302    m_view->ClipToRect(rect);
    282303}
    283304
    284305void GraphicsContextHaiku::clipPath(const Path& path, WindRule windRule)
    285306{
     307    HGTRACE(("clipPath: (--todo print values)\n"));
    286308    int32 fillRule = m_view->FillRule();
    287309
    288310    m_view->SetFillRule(windRule == WindRule::EvenOdd ? B_EVEN_ODD : B_NONZERO);
    void GraphicsContextHaiku::drawPattern(NativeImage& image, const FloatRect& dest  
    296318    const FloatRect& tileRect, const AffineTransform& transform,
    297319    const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
    298320{
     321    HGTRACE(("drawPattern: (--todo print values)\n"));
    299322    drawBitmap(image.platformImage().get(), image.size(), destRect, tileRect, transform, phase, spacing, options);
    300323}
    301324
    void GraphicsContextHaiku::drawBitmap(BBitmap* image, const WebCore::FloatSize&  
    303326    const FloatRect& tileRect, const AffineTransform&,
    304327    const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&)
    305328{
     329    HGTRACE(("drawBitmap: (--todo print values)\n"));
    306330    if (!image->IsValid()) // If the image hasn't fully loaded.
    307331        return;
    308332
    void GraphicsContextHaiku::drawBitmap(BBitmap* image, const WebCore::FloatSize&  
    343367
    344368void GraphicsContextHaiku::clipOut(const Path& path)
    345369{
     370    HGTRACE(("clipOut(path): (--todo print values)\n"));
    346371    if (path.isEmpty())
    347372        return;
    348373
    void GraphicsContextHaiku::clipOut(const Path& path)  
    351376
    352377void GraphicsContextHaiku::clipOut(const FloatRect& rect)
    353378{
     379    HGTRACE(("clipOut: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height()));
    354380    m_view->ClipToInverseRect(rect);
    355381}
    356382
    357383void GraphicsContextHaiku::drawFocusRing(const Path& path, float width, float /*offset*/, const Color& color)
    358384{
     385    HGTRACE(("drawFocusRing(path): (--todo print values)\n"));
    359386    if (width <= 0 || !color.isVisible())
    360387        return;
    361388
    void GraphicsContextHaiku::drawFocusRing(const Path& path, float width, float /*  
    372399
    373400void GraphicsContextHaiku::drawFocusRing(const Vector<FloatRect>& rects, float width, float /* offset */, const Color& color)
    374401{
     402    HGTRACE(("drawFocusRing(rects): (--todo print values)\n"));
    375403    if (width <= 0 || !color.isVisible())
    376404        return;
    377405
    void GraphicsContextHaiku::drawFocusRing(const Vector<FloatRect>& rects, float w  
    398426
    399427void GraphicsContextHaiku::drawLinesForText(const FloatPoint& point, float, const DashArray& widths, bool printing, bool doubleUnderlines, WebCore::StrokeStyle)
    400428{
     429    HGTRACE(("drawLinesForText: (--todo print values)\n"));
    401430    if (widths.size() <= 0)
    402431        return;
    403432
    void GraphicsContextHaiku::drawLinesForText(const FloatPoint& point, float, cons  
    414443void GraphicsContextHaiku::drawDotsForDocumentMarker(WebCore::FloatRect const&,
    415444    WebCore::DocumentMarkerLineStyle)
    416445{
     446    HGTRACE(("drawDotsForDocumentMarker: Not Implemented\n"));
    417447    notImplemented();
    418448}
    419449
    420450FloatRect GraphicsContextHaiku::roundToDevicePixels(const FloatRect& rect, RoundingMode /* mode */)
    421451{
     452    HGTRACE(("roundToDevicePixels: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height()));
    422453    FloatRect rounded(rect);
    423454    rounded.setX(roundf(rect.x()));
    424455    rounded.setY(roundf(rect.y()));
    FloatRect GraphicsContextHaiku::roundToDevicePixels(const FloatRect& rect, Round  
    430461/* Used by canvas.clearRect. Must clear the given rectangle with transparent black. */
    431462void GraphicsContextHaiku::clearRect(const FloatRect& rect)
    432463{
     464    HGTRACE(("clearRect: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height()));
    433465    m_view->PushState();
    434466    m_view->SetHighColor(0, 0, 0, 0);
    435467    m_view->SetDrawingMode(B_OP_COPY);
    void GraphicsContextHaiku::clearRect(const FloatRect& rect)  
    439471
    440472void GraphicsContextHaiku::setLineCap(LineCap lineCap)
    441473{
     474    HGTRACE(("setLineCap: (--todo print values)\n"));
    442475    cap_mode mode = B_BUTT_CAP;
    443476    switch (lineCap) {
    444477    case LineCap::Round:
    void GraphicsContextHaiku::setLineCap(LineCap lineCap)  
    457490
    458491void GraphicsContextHaiku::setLineDash(const DashArray& /*dashes*/, float /*dashOffset*/)
    459492{
     493    HGTRACE(("setLineDash: Not Implemented\n"));
    460494    // TODO this is used to draw dashed strokes in SVG, but we need app_server support
    461495    notImplemented();
    462496}
    463497
    464498void GraphicsContextHaiku::setLineJoin(LineJoin lineJoin)
    465499{
     500    HGTRACE(("setLineJoin: (--todo print values)\n"));
    466501    join_mode mode = B_MITER_JOIN;
    467502    switch (lineJoin) {
    468503    case LineJoin::Round:
    void GraphicsContextHaiku::setLineJoin(LineJoin lineJoin)  
    481516
    482517void GraphicsContextHaiku::setMiterLimit(float limit)
    483518{
     519    HGTRACE(("setMiterLimit: %f\n", limit));
    484520    m_view->SetLineMode(m_view->LineCapMode(), m_view->LineJoinMode(), limit);
    485521}
    486522
    487523AffineTransform GraphicsContextHaiku::getCTM(IncludeDeviceScale) const
    488524{
     525    HGTRACE(("getCTM: no values used\n"));
    489526    BAffineTransform t = m_view->Transform();
    490527        // TODO: we actually need to use the combined transform here?
    491528    AffineTransform matrix(t.sx, t.shy, t.shx, t.sy, t.tx, t.ty);
    AffineTransform GraphicsContextHaiku::getCTM(IncludeDeviceScale) const  
    494531
    495532void GraphicsContextHaiku::translate(float x, float y)
    496533{
     534    HGTRACE(("translate: %f, %f\n", x, y));
    497535    if (x == 0.f && y == 0.f)
    498536        return;
    499537
    void GraphicsContextHaiku::translate(float x, float y)  
    502540
    503541void GraphicsContextHaiku::rotate(float radians)
    504542{
     543    HGTRACE(("rotate: %f\n", radians));
    505544    if (radians == 0.f)
    506545        return;
    507546
    void GraphicsContextHaiku::rotate(float radians)  
    510549
    511550void GraphicsContextHaiku::scale(const FloatSize& size)
    512551{
     552    HGTRACE(("scale: %f %f\n", size.width(), size.height()));
    513553    m_view->ScaleBy(size.width(), size.height());
    514554}
    515555
    516556void GraphicsContextHaiku::concatCTM(const AffineTransform& transform)
    517557{
     558    HGTRACE(("concatCTM: (--todo print values)\n"));
    518559    BAffineTransform current = m_view->Transform();
    519560    current.Multiply(transform);
    520561    m_view->SetTransform(current);
    void GraphicsContextHaiku::concatCTM(const AffineTransform& transform)  
    522563
    523564void GraphicsContextHaiku::setCTM(const AffineTransform& transform)
    524565{
     566    HGTRACE(("setCTM: (--todo print values)\n"));
    525567    m_view->SetTransform(transform);
    526568}
    527569
    528570void GraphicsContextHaiku::didUpdateState(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags)
    529571{
     572    HGTRACE(("didUpdateState: (--todo print values)\n"));
    530573#if 0
    531574        StrokeGradientChange                    = 1 << 0,
    532575        StrokePatternChange                     = 1 << 1,
    void GraphicsContextHaiku::set3DTransform(const TransformationMatrix& transform)  
    673716
    674717void GraphicsContextHaiku::beginTransparencyLayer(float opacity)
    675718{
     719    HGTRACE(("beginTransparencyLayer: %f\n", opacity));
    676720    GraphicsContext::beginTransparencyLayer(opacity);
    677721    m_view->BeginLayer(static_cast<uint8>(opacity * 255.0));
    678722}
    679723
    680724void GraphicsContextHaiku::endTransparencyLayer()
    681725{
     726    HGTRACE(("endTransparencyLayer: no values\n"));
    682727    GraphicsContext::endTransparencyLayer();
    683728    m_view->EndLayer();
    684729}
    685730
    686731IntRect GraphicsContextHaiku::clipBounds() const
    687732{
     733    HGTRACE(("clipBounds: no values\n"));
    688734    // This can be used by drawing code to do some early clipping (for example
    689735    // the SVG code may skip complete parts of the image which are outside
    690736    // the bounds).
    IntRect GraphicsContextHaiku::clipBounds() const  
    713759
    714760void GraphicsContextHaiku::save()
    715761{
     762    HGTRACE(("save: no values\n"));
    716763    m_view->PushState();
    717764    GraphicsContext::save();
    718765}
    719766
    720767void GraphicsContextHaiku::restore()
    721768{
     769    HGTRACE(("restore: no values\n"));
    722770    GraphicsContext::restore();
    723771    m_view->PopState();
    724772}