| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 struct GraphicsContext::CanvasSaveState { | 94 struct GraphicsContext::CanvasSaveState { |
| 95 CanvasSaveState(bool pendingSave, int count) | 95 CanvasSaveState(bool pendingSave, int count) |
| 96 : m_pendingSave(pendingSave), m_restoreCount(count) { } | 96 : m_pendingSave(pendingSave), m_restoreCount(count) { } |
| 97 | 97 |
| 98 bool m_pendingSave; | 98 bool m_pendingSave; |
| 99 int m_restoreCount; | 99 int m_restoreCount; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 struct GraphicsContext::RecordingState { | 102 struct GraphicsContext::RecordingState { |
| 103 RecordingState(SkPictureRecorder* recorder, SkCanvas* currentCanvas, const S
kMatrix& currentMatrix, PassRefPtr<DisplayList> displayList) | 103 RecordingState(SkPictureRecorder* recorder, SkCanvas* currentCanvas, const S
kMatrix& currentMatrix, |
| 104 PassRefPtr<DisplayList> displayList, RegionTrackingMode trackingMode) |
| 104 : m_displayList(displayList) | 105 : m_displayList(displayList) |
| 105 , m_recorder(recorder) | 106 , m_recorder(recorder) |
| 106 , m_savedCanvas(currentCanvas) | 107 , m_savedCanvas(currentCanvas) |
| 107 , m_savedMatrix(currentMatrix) { } | 108 , m_savedMatrix(currentMatrix) |
| 109 , m_regionTrackingMode(trackingMode) { } |
| 108 | 110 |
| 109 ~RecordingState() { } | 111 ~RecordingState() { } |
| 110 | 112 |
| 111 RefPtr<DisplayList> m_displayList; | 113 RefPtr<DisplayList> m_displayList; |
| 112 SkPictureRecorder* m_recorder; | 114 SkPictureRecorder* m_recorder; |
| 113 SkCanvas* m_savedCanvas; | 115 SkCanvas* m_savedCanvas; |
| 114 const SkMatrix m_savedMatrix; | 116 const SkMatrix m_savedMatrix; |
| 117 RegionTrackingMode m_regionTrackingMode; |
| 115 }; | 118 }; |
| 116 | 119 |
| 117 GraphicsContext::GraphicsContext(SkCanvas* canvas, DisabledMode disableContextOr
Painting) | 120 GraphicsContext::GraphicsContext(SkCanvas* canvas, DisabledMode disableContextOr
Painting) |
| 118 : m_canvas(canvas) | 121 : m_canvas(canvas) |
| 119 , m_paintStateStack() | 122 , m_paintStateStack() |
| 120 , m_paintStateIndex(0) | 123 , m_paintStateIndex(0) |
| 121 , m_pendingCanvasSave(false) | 124 , m_pendingCanvasSave(false) |
| 122 , m_annotationMode(0) | 125 , m_annotationMode(0) |
| 123 #if ENABLE(ASSERT) | 126 #if ENABLE(ASSERT) |
| 124 , m_annotationCount(0) | 127 , m_annotationCount(0) |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 515 |
| 513 // We want the bounds offset mapped to (0, 0), such that the display lis
t content | 516 // We want the bounds offset mapped to (0, 0), such that the display lis
t content |
| 514 // is fully contained within the SkPictureRecord's bounds. | 517 // is fully contained within the SkPictureRecord's bounds. |
| 515 if (!toFloatSize(bounds.location()).isZero()) { | 518 if (!toFloatSize(bounds.location()).isZero()) { |
| 516 m_canvas->translate(-bounds.x(), -bounds.y()); | 519 m_canvas->translate(-bounds.x(), -bounds.y()); |
| 517 // To avoid applying the offset repeatedly in getTotalMatrix(), we p
re-apply it here. | 520 // To avoid applying the offset repeatedly in getTotalMatrix(), we p
re-apply it here. |
| 518 savedMatrix.preTranslate(bounds.x(), bounds.y()); | 521 savedMatrix.preTranslate(bounds.x(), bounds.y()); |
| 519 } | 522 } |
| 520 } | 523 } |
| 521 | 524 |
| 522 m_recordingStateStack.append(RecordingState(recorder, savedCanvas, savedMatr
ix, displayList)); | 525 m_recordingStateStack.append(RecordingState(recorder, savedCanvas, savedMatr
ix, displayList, |
| 526 static_cast<RegionTrackingMode>(m_regionTrackingMode))); |
| 527 |
| 528 // Disable region tracking during recording. |
| 529 setRegionTrackingMode(RegionTrackingDisabled); |
| 523 } | 530 } |
| 524 | 531 |
| 525 PassRefPtr<DisplayList> GraphicsContext::endRecording() | 532 PassRefPtr<DisplayList> GraphicsContext::endRecording() |
| 526 { | 533 { |
| 527 ASSERT(!m_recordingStateStack.isEmpty()); | 534 ASSERT(!m_recordingStateStack.isEmpty()); |
| 528 | 535 |
| 529 RecordingState recording = m_recordingStateStack.last(); | 536 RecordingState recording = m_recordingStateStack.last(); |
| 530 if (!contextDisabled()) | 537 if (!contextDisabled()) |
| 531 recording.m_displayList->setPicture(recording.m_recorder->endRecording()
); | 538 recording.m_displayList->setPicture(recording.m_recorder->endRecording()
); |
| 532 | 539 |
| 533 m_canvas = recording.m_savedCanvas; | 540 m_canvas = recording.m_savedCanvas; |
| 541 setRegionTrackingMode(recording.m_regionTrackingMode); |
| 534 delete recording.m_recorder; | 542 delete recording.m_recorder; |
| 535 m_recordingStateStack.removeLast(); | 543 m_recordingStateStack.removeLast(); |
| 536 | 544 |
| 537 return recording.m_displayList; | 545 return recording.m_displayList; |
| 538 } | 546 } |
| 539 | 547 |
| 540 bool GraphicsContext::isRecording() const | 548 bool GraphicsContext::isRecording() const |
| 541 { | 549 { |
| 542 return !m_recordingStateStack.isEmpty(); | 550 return !m_recordingStateStack.isEmpty(); |
| 543 } | 551 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 563 | 571 |
| 564 const FloatPoint& location = displayList->bounds().location(); | 572 const FloatPoint& location = displayList->bounds().location(); |
| 565 if (location.x() || location.y()) { | 573 if (location.x() || location.y()) { |
| 566 SkMatrix m; | 574 SkMatrix m; |
| 567 m.setTranslate(location.x(), location.y()); | 575 m.setTranslate(location.x(), location.y()); |
| 568 m_canvas->drawPicture(displayList->picture(), &m, 0); | 576 m_canvas->drawPicture(displayList->picture(), &m, 0); |
| 569 } else { | 577 } else { |
| 570 m_canvas->drawPicture(displayList->picture()); | 578 m_canvas->drawPicture(displayList->picture()); |
| 571 } | 579 } |
| 572 | 580 |
| 581 if (regionTrackingEnabled()) { |
| 582 // Since we don't track regions within display lists, conservatively |
| 583 // mark the bounds as non-opaque. |
| 584 SkPaint paint; |
| 585 paint.setXfermodeMode(SkXfermode::kClear_Mode); |
| 586 m_trackedRegion.didDrawBounded(this, displayList->bounds(), paint); |
| 587 } |
| 588 |
| 573 if (performClip || performTransform) | 589 if (performClip || performTransform) |
| 574 restore(); | 590 restore(); |
| 575 } | 591 } |
| 576 | 592 |
| 577 void GraphicsContext::drawConvexPolygon(size_t numPoints, const FloatPoint* poin
ts, bool shouldAntialias) | 593 void GraphicsContext::drawConvexPolygon(size_t numPoints, const FloatPoint* poin
ts, bool shouldAntialias) |
| 578 { | 594 { |
| 579 if (contextDisabled()) | 595 if (contextDisabled()) |
| 580 return; | 596 return; |
| 581 | 597 |
| 582 if (numPoints <= 1) | 598 if (numPoints <= 1) |
| (...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 // FIXME: This is to not break tests (it results in the filter bitmap fl
ag | 1996 // FIXME: This is to not break tests (it results in the filter bitmap fl
ag |
| 1981 // being set to true). We need to decide if we respect InterpolationNone | 1997 // being set to true). We need to decide if we respect InterpolationNone |
| 1982 // being returned from computeInterpolationQuality. | 1998 // being returned from computeInterpolationQuality. |
| 1983 resampling = InterpolationLow; | 1999 resampling = InterpolationLow; |
| 1984 } | 2000 } |
| 1985 resampling = limitInterpolationQuality(this, resampling); | 2001 resampling = limitInterpolationQuality(this, resampling); |
| 1986 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); | 2002 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); |
| 1987 } | 2003 } |
| 1988 | 2004 |
| 1989 } // namespace blink | 2005 } // namespace blink |
| OLD | NEW |