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
|
|
48 | 48 | #include <Window.h> |
49 | 49 | #include <stdio.h> |
50 | 50 | |
| 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 | |
51 | 58 | namespace WebCore { |
52 | 59 | |
53 | 60 | |
… |
… |
GraphicsContextHaiku::~GraphicsContextHaiku()
|
64 | 71 | // Draws a filled rectangle with a stroked border. |
65 | 72 | void GraphicsContextHaiku::drawRect(const FloatRect& rect, float borderThickness) |
66 | 73 | { |
| 74 | HGTRACE(("drawRect: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); |
67 | 75 | if (m_state.fillPattern) |
68 | 76 | notImplemented(); |
69 | 77 | else if (m_state.fillGradient) { |
… |
… |
void GraphicsContextHaiku::drawRect(const FloatRect& rect, float borderThickness
|
81 | 89 | |
82 | 90 | void GraphicsContextHaiku::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) |
83 | 91 | { |
| 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())); |
84 | 94 | drawBitmap(image.platformImage().get(), imageSize, destRect, srcRect, options); |
85 | 95 | } |
86 | 96 | |
87 | 97 | void GraphicsContextHaiku::drawBitmap(BBitmap* image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) |
88 | 98 | { |
| 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())); |
89 | 101 | m_view->PushState(); |
90 | 102 | setCompositeOperation(options.compositeOperator()); |
91 | 103 | |
… |
… |
void GraphicsContextHaiku::drawBitmap(BBitmap* image, const FloatSize& imageSize
|
107 | 119 | // This is only used to draw borders. |
108 | 120 | void GraphicsContextHaiku::drawLine(const FloatPoint& point1, const FloatPoint& point2) |
109 | 121 | { |
| 122 | HGTRACE(("drawline: [%f:%f] [%f:%f])\n", point1.x(), point1.y(), point2.x(), point2.y())); |
110 | 123 | if (strokeStyle() == NoStroke || !strokeColor().isVisible()) |
111 | 124 | return; |
112 | 125 | m_view->StrokeLine(point1, point2, m_strokeStyle); |
… |
… |
void GraphicsContextHaiku::drawLine(const FloatPoint& point1, const FloatPoint&
|
115 | 128 | // This method is only used to draw the little circles used in lists. |
116 | 129 | void GraphicsContextHaiku::drawEllipse(const FloatRect& rect) |
117 | 130 | { |
| 131 | HGTRACE(("drawEllipse: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); |
118 | 132 | if (m_state.fillPattern || m_state.fillGradient || fillColor().isVisible()) { |
119 | 133 | // TODO: What's this shadow business? |
120 | 134 | if (m_state.fillPattern) |
… |
… |
void GraphicsContextHaiku::drawEllipse(const FloatRect& rect)
|
133 | 147 | |
134 | 148 | void GraphicsContextHaiku::strokeRect(const FloatRect& rect, float width) |
135 | 149 | { |
| 150 | HGTRACE(("strokeRect: [%f:%f] [%f:%f] width:%f\n", rect.x(), rect.y(), rect.width(), rect.height(), width)); |
136 | 151 | if (strokeStyle() == NoStroke || width <= 0.0f || !strokeColor().isVisible()) |
137 | 152 | return; |
138 | 153 | |
… |
… |
void GraphicsContextHaiku::strokeRect(const FloatRect& rect, float width)
|
145 | 160 | |
146 | 161 | void GraphicsContextHaiku::strokePath(const Path& path) |
147 | 162 | { |
| 163 | HGTRACE(("strokePath: (--todo print values)\n")); |
148 | 164 | m_view->MovePenTo(B_ORIGIN); |
149 | 165 | |
150 | 166 | // TODO: stroke the shadow (cf shadowAndStrokeCurrentCairoPath) |
… |
… |
void GraphicsContextHaiku::strokePath(const Path& path)
|
167 | 183 | |
168 | 184 | void GraphicsContextHaiku::fillRect(const FloatRect& rect, const Color& color) |
169 | 185 | { |
| 186 | HGTRACE(("fillRect(color): [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); |
170 | 187 | rgb_color previousColor = m_view->HighColor(); |
171 | 188 | |
172 | 189 | #if 0 |
… |
… |
void GraphicsContextHaiku::fillRect(const FloatRect& rect, const Color& color)
|
185 | 202 | |
186 | 203 | void GraphicsContextHaiku::fillRect(const FloatRect& rect) |
187 | 204 | { |
| 205 | HGTRACE(("fillRect: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); |
188 | 206 | // TODO fill the shadow |
189 | 207 | m_view->FillRect(rect, B_SOLID_LOW); |
190 | 208 | } |
191 | 209 | |
192 | 210 | void GraphicsContextHaiku::fillRoundedRectImpl(const FloatRoundedRect& roundRect, const Color& color) |
193 | 211 | { |
| 212 | HGTRACE(("fillRoundedRectImpl: (--todo print values)\n")); |
194 | 213 | if (!color.isVisible()) |
195 | 214 | return; |
196 | 215 | |
… |
… |
void GraphicsContextHaiku::fillRoundedRectImpl(const FloatRoundedRect& roundRect
|
254 | 273 | |
255 | 274 | void GraphicsContextHaiku::fillPath(const Path& path) |
256 | 275 | { |
| 276 | HGTRACE(("fillPath: (--todo print values)\n")); |
257 | 277 | m_view->SetFillRule(fillRule() == WindRule::NonZero ? B_NONZERO : B_EVEN_ODD); |
258 | 278 | m_view->MovePenTo(B_ORIGIN); |
259 | 279 | |
… |
… |
void GraphicsContextHaiku::fillPath(const Path& path)
|
278 | 298 | |
279 | 299 | void GraphicsContextHaiku::clip(const FloatRect& rect) |
280 | 300 | { |
| 301 | HGTRACE(("clip: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); |
281 | 302 | m_view->ClipToRect(rect); |
282 | 303 | } |
283 | 304 | |
284 | 305 | void GraphicsContextHaiku::clipPath(const Path& path, WindRule windRule) |
285 | 306 | { |
| 307 | HGTRACE(("clipPath: (--todo print values)\n")); |
286 | 308 | int32 fillRule = m_view->FillRule(); |
287 | 309 | |
288 | 310 | m_view->SetFillRule(windRule == WindRule::EvenOdd ? B_EVEN_ODD : B_NONZERO); |
… |
… |
void GraphicsContextHaiku::drawPattern(NativeImage& image, const FloatRect& dest
|
296 | 318 | const FloatRect& tileRect, const AffineTransform& transform, |
297 | 319 | const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options) |
298 | 320 | { |
| 321 | HGTRACE(("drawPattern: (--todo print values)\n")); |
299 | 322 | drawBitmap(image.platformImage().get(), image.size(), destRect, tileRect, transform, phase, spacing, options); |
300 | 323 | } |
301 | 324 | |
… |
… |
void GraphicsContextHaiku::drawBitmap(BBitmap* image, const WebCore::FloatSize&
|
303 | 326 | const FloatRect& tileRect, const AffineTransform&, |
304 | 327 | const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) |
305 | 328 | { |
| 329 | HGTRACE(("drawBitmap: (--todo print values)\n")); |
306 | 330 | if (!image->IsValid()) // If the image hasn't fully loaded. |
307 | 331 | return; |
308 | 332 | |
… |
… |
void GraphicsContextHaiku::drawBitmap(BBitmap* image, const WebCore::FloatSize&
|
343 | 367 | |
344 | 368 | void GraphicsContextHaiku::clipOut(const Path& path) |
345 | 369 | { |
| 370 | HGTRACE(("clipOut(path): (--todo print values)\n")); |
346 | 371 | if (path.isEmpty()) |
347 | 372 | return; |
348 | 373 | |
… |
… |
void GraphicsContextHaiku::clipOut(const Path& path)
|
351 | 376 | |
352 | 377 | void GraphicsContextHaiku::clipOut(const FloatRect& rect) |
353 | 378 | { |
| 379 | HGTRACE(("clipOut: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); |
354 | 380 | m_view->ClipToInverseRect(rect); |
355 | 381 | } |
356 | 382 | |
357 | 383 | void GraphicsContextHaiku::drawFocusRing(const Path& path, float width, float /*offset*/, const Color& color) |
358 | 384 | { |
| 385 | HGTRACE(("drawFocusRing(path): (--todo print values)\n")); |
359 | 386 | if (width <= 0 || !color.isVisible()) |
360 | 387 | return; |
361 | 388 | |
… |
… |
void GraphicsContextHaiku::drawFocusRing(const Path& path, float width, float /*
|
372 | 399 | |
373 | 400 | void GraphicsContextHaiku::drawFocusRing(const Vector<FloatRect>& rects, float width, float /* offset */, const Color& color) |
374 | 401 | { |
| 402 | HGTRACE(("drawFocusRing(rects): (--todo print values)\n")); |
375 | 403 | if (width <= 0 || !color.isVisible()) |
376 | 404 | return; |
377 | 405 | |
… |
… |
void GraphicsContextHaiku::drawFocusRing(const Vector<FloatRect>& rects, float w
|
398 | 426 | |
399 | 427 | void GraphicsContextHaiku::drawLinesForText(const FloatPoint& point, float, const DashArray& widths, bool printing, bool doubleUnderlines, WebCore::StrokeStyle) |
400 | 428 | { |
| 429 | HGTRACE(("drawLinesForText: (--todo print values)\n")); |
401 | 430 | if (widths.size() <= 0) |
402 | 431 | return; |
403 | 432 | |
… |
… |
void GraphicsContextHaiku::drawLinesForText(const FloatPoint& point, float, cons
|
414 | 443 | void GraphicsContextHaiku::drawDotsForDocumentMarker(WebCore::FloatRect const&, |
415 | 444 | WebCore::DocumentMarkerLineStyle) |
416 | 445 | { |
| 446 | HGTRACE(("drawDotsForDocumentMarker: Not Implemented\n")); |
417 | 447 | notImplemented(); |
418 | 448 | } |
419 | 449 | |
420 | 450 | FloatRect GraphicsContextHaiku::roundToDevicePixels(const FloatRect& rect, RoundingMode /* mode */) |
421 | 451 | { |
| 452 | HGTRACE(("roundToDevicePixels: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); |
422 | 453 | FloatRect rounded(rect); |
423 | 454 | rounded.setX(roundf(rect.x())); |
424 | 455 | rounded.setY(roundf(rect.y())); |
… |
… |
FloatRect GraphicsContextHaiku::roundToDevicePixels(const FloatRect& rect, Round
|
430 | 461 | /* Used by canvas.clearRect. Must clear the given rectangle with transparent black. */ |
431 | 462 | void GraphicsContextHaiku::clearRect(const FloatRect& rect) |
432 | 463 | { |
| 464 | HGTRACE(("clearRect: [%f:%f] [%f:%f]\n", rect.x(), rect.y(), rect.width(), rect.height())); |
433 | 465 | m_view->PushState(); |
434 | 466 | m_view->SetHighColor(0, 0, 0, 0); |
435 | 467 | m_view->SetDrawingMode(B_OP_COPY); |
… |
… |
void GraphicsContextHaiku::clearRect(const FloatRect& rect)
|
439 | 471 | |
440 | 472 | void GraphicsContextHaiku::setLineCap(LineCap lineCap) |
441 | 473 | { |
| 474 | HGTRACE(("setLineCap: (--todo print values)\n")); |
442 | 475 | cap_mode mode = B_BUTT_CAP; |
443 | 476 | switch (lineCap) { |
444 | 477 | case LineCap::Round: |
… |
… |
void GraphicsContextHaiku::setLineCap(LineCap lineCap)
|
457 | 490 | |
458 | 491 | void GraphicsContextHaiku::setLineDash(const DashArray& /*dashes*/, float /*dashOffset*/) |
459 | 492 | { |
| 493 | HGTRACE(("setLineDash: Not Implemented\n")); |
460 | 494 | // TODO this is used to draw dashed strokes in SVG, but we need app_server support |
461 | 495 | notImplemented(); |
462 | 496 | } |
463 | 497 | |
464 | 498 | void GraphicsContextHaiku::setLineJoin(LineJoin lineJoin) |
465 | 499 | { |
| 500 | HGTRACE(("setLineJoin: (--todo print values)\n")); |
466 | 501 | join_mode mode = B_MITER_JOIN; |
467 | 502 | switch (lineJoin) { |
468 | 503 | case LineJoin::Round: |
… |
… |
void GraphicsContextHaiku::setLineJoin(LineJoin lineJoin)
|
481 | 516 | |
482 | 517 | void GraphicsContextHaiku::setMiterLimit(float limit) |
483 | 518 | { |
| 519 | HGTRACE(("setMiterLimit: %f\n", limit)); |
484 | 520 | m_view->SetLineMode(m_view->LineCapMode(), m_view->LineJoinMode(), limit); |
485 | 521 | } |
486 | 522 | |
487 | 523 | AffineTransform GraphicsContextHaiku::getCTM(IncludeDeviceScale) const |
488 | 524 | { |
| 525 | HGTRACE(("getCTM: no values used\n")); |
489 | 526 | BAffineTransform t = m_view->Transform(); |
490 | 527 | // TODO: we actually need to use the combined transform here? |
491 | 528 | AffineTransform matrix(t.sx, t.shy, t.shx, t.sy, t.tx, t.ty); |
… |
… |
AffineTransform GraphicsContextHaiku::getCTM(IncludeDeviceScale) const
|
494 | 531 | |
495 | 532 | void GraphicsContextHaiku::translate(float x, float y) |
496 | 533 | { |
| 534 | HGTRACE(("translate: %f, %f\n", x, y)); |
497 | 535 | if (x == 0.f && y == 0.f) |
498 | 536 | return; |
499 | 537 | |
… |
… |
void GraphicsContextHaiku::translate(float x, float y)
|
502 | 540 | |
503 | 541 | void GraphicsContextHaiku::rotate(float radians) |
504 | 542 | { |
| 543 | HGTRACE(("rotate: %f\n", radians)); |
505 | 544 | if (radians == 0.f) |
506 | 545 | return; |
507 | 546 | |
… |
… |
void GraphicsContextHaiku::rotate(float radians)
|
510 | 549 | |
511 | 550 | void GraphicsContextHaiku::scale(const FloatSize& size) |
512 | 551 | { |
| 552 | HGTRACE(("scale: %f %f\n", size.width(), size.height())); |
513 | 553 | m_view->ScaleBy(size.width(), size.height()); |
514 | 554 | } |
515 | 555 | |
516 | 556 | void GraphicsContextHaiku::concatCTM(const AffineTransform& transform) |
517 | 557 | { |
| 558 | HGTRACE(("concatCTM: (--todo print values)\n")); |
518 | 559 | BAffineTransform current = m_view->Transform(); |
519 | 560 | current.Multiply(transform); |
520 | 561 | m_view->SetTransform(current); |
… |
… |
void GraphicsContextHaiku::concatCTM(const AffineTransform& transform)
|
522 | 563 | |
523 | 564 | void GraphicsContextHaiku::setCTM(const AffineTransform& transform) |
524 | 565 | { |
| 566 | HGTRACE(("setCTM: (--todo print values)\n")); |
525 | 567 | m_view->SetTransform(transform); |
526 | 568 | } |
527 | 569 | |
528 | 570 | void GraphicsContextHaiku::didUpdateState(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags) |
529 | 571 | { |
| 572 | HGTRACE(("didUpdateState: (--todo print values)\n")); |
530 | 573 | #if 0 |
531 | 574 | StrokeGradientChange = 1 << 0, |
532 | 575 | StrokePatternChange = 1 << 1, |
… |
… |
void GraphicsContextHaiku::set3DTransform(const TransformationMatrix& transform)
|
673 | 716 | |
674 | 717 | void GraphicsContextHaiku::beginTransparencyLayer(float opacity) |
675 | 718 | { |
| 719 | HGTRACE(("beginTransparencyLayer: %f\n", opacity)); |
676 | 720 | GraphicsContext::beginTransparencyLayer(opacity); |
677 | 721 | m_view->BeginLayer(static_cast<uint8>(opacity * 255.0)); |
678 | 722 | } |
679 | 723 | |
680 | 724 | void GraphicsContextHaiku::endTransparencyLayer() |
681 | 725 | { |
| 726 | HGTRACE(("endTransparencyLayer: no values\n")); |
682 | 727 | GraphicsContext::endTransparencyLayer(); |
683 | 728 | m_view->EndLayer(); |
684 | 729 | } |
685 | 730 | |
686 | 731 | IntRect GraphicsContextHaiku::clipBounds() const |
687 | 732 | { |
| 733 | HGTRACE(("clipBounds: no values\n")); |
688 | 734 | // This can be used by drawing code to do some early clipping (for example |
689 | 735 | // the SVG code may skip complete parts of the image which are outside |
690 | 736 | // the bounds). |
… |
… |
IntRect GraphicsContextHaiku::clipBounds() const
|
713 | 759 | |
714 | 760 | void GraphicsContextHaiku::save() |
715 | 761 | { |
| 762 | HGTRACE(("save: no values\n")); |
716 | 763 | m_view->PushState(); |
717 | 764 | GraphicsContext::save(); |
718 | 765 | } |
719 | 766 | |
720 | 767 | void GraphicsContextHaiku::restore() |
721 | 768 | { |
| 769 | HGTRACE(("restore: no values\n")); |
722 | 770 | GraphicsContext::restore(); |
723 | 771 | m_view->PopState(); |
724 | 772 | } |