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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 realizeSave(SkCanvas::kMatrix_SaveFlag); | 458 realizeSave(SkCanvas::kMatrix_SaveFlag); |
459 | 459 |
460 m_canvas->setMatrix(matrix); | 460 m_canvas->setMatrix(matrix); |
461 } | 461 } |
462 | 462 |
463 bool GraphicsContext::concat(const SkMatrix& matrix) | 463 bool GraphicsContext::concat(const SkMatrix& matrix) |
464 { | 464 { |
465 if (paintingDisabled()) | 465 if (paintingDisabled()) |
466 return false; | 466 return false; |
467 | 467 |
468 if (matrix.isIdentity()) | |
469 return true; | |
470 | |
468 realizeSave(SkCanvas::kMatrix_SaveFlag); | 471 realizeSave(SkCanvas::kMatrix_SaveFlag); |
469 | 472 |
470 return m_canvas->concat(matrix); | 473 return m_canvas->concat(matrix); |
471 } | 474 } |
472 | 475 |
473 void GraphicsContext::beginTransparencyLayer(float opacity, const FloatRect* bou nds) | 476 void GraphicsContext::beginTransparencyLayer(float opacity, const FloatRect* bou nds) |
474 { | 477 { |
475 beginLayer(opacity, m_state->m_compositeOperator, bounds); | 478 beginLayer(opacity, m_state->m_compositeOperator, bounds); |
476 } | 479 } |
477 | 480 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
555 | 558 |
556 bool GraphicsContext::isRecording() const | 559 bool GraphicsContext::isRecording() const |
557 { | 560 { |
558 return !m_recordingStateStack.isEmpty(); | 561 return !m_recordingStateStack.isEmpty(); |
559 } | 562 } |
560 | 563 |
561 void GraphicsContext::drawDisplayList(DisplayList* displayList) | 564 void GraphicsContext::drawDisplayList(DisplayList* displayList) |
562 { | 565 { |
563 ASSERT(!displayList->picture()->getRecordingCanvas()); | 566 ASSERT(!displayList->picture()->getRecordingCanvas()); |
564 | 567 |
565 if (paintingDisabled() || !displayList) | 568 if (paintingDisabled() || !displayList || displayList->bounds().isEmpty()) |
566 return; | 569 return; |
567 | 570 |
568 realizeSave(SkCanvas::kMatrixClip_SaveFlag); | 571 realizeSave(SkCanvas::kMatrixClip_SaveFlag); |
569 | 572 |
570 const FloatRect& bounds = displayList->bounds(); | 573 const FloatRect& bounds = displayList->bounds(); |
571 if (bounds.x() || bounds.y()) | 574 if (bounds.x() || bounds.y()) |
572 m_canvas->translate(bounds.x(), bounds.y()); | 575 m_canvas->translate(bounds.x(), bounds.y()); |
573 | 576 |
574 m_canvas->drawPicture(*displayList->picture()); | 577 m_canvas->drawPicture(*displayList->picture()); |
575 | 578 |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1580 realizeSave(SkCanvas::kMatrix_SaveFlag); | 1583 realizeSave(SkCanvas::kMatrix_SaveFlag); |
1581 | 1584 |
1582 m_canvas->rotate(WebCoreFloatToSkScalar(angleInRadians * (180.0f / 3.1415926 5f))); | 1585 m_canvas->rotate(WebCoreFloatToSkScalar(angleInRadians * (180.0f / 3.1415926 5f))); |
1583 } | 1586 } |
1584 | 1587 |
1585 void GraphicsContext::translate(float w, float h) | 1588 void GraphicsContext::translate(float w, float h) |
1586 { | 1589 { |
1587 if (paintingDisabled()) | 1590 if (paintingDisabled()) |
1588 return; | 1591 return; |
1589 | 1592 |
1593 if (!w && !h) | |
1594 return; | |
1595 | |
1590 realizeSave(SkCanvas::kMatrix_SaveFlag); | 1596 realizeSave(SkCanvas::kMatrix_SaveFlag); |
1591 | 1597 |
1592 m_canvas->translate(WebCoreFloatToSkScalar(w), WebCoreFloatToSkScalar(h)); | 1598 m_canvas->translate(WebCoreFloatToSkScalar(w), WebCoreFloatToSkScalar(h)); |
1593 } | 1599 } |
1594 | 1600 |
1595 void GraphicsContext::scale(const FloatSize& size) | 1601 void GraphicsContext::scale(const FloatSize& size) |
1596 { | 1602 { |
1597 if (paintingDisabled()) | 1603 if (paintingDisabled()) |
1598 return; | 1604 return; |
1599 | 1605 |
1606 if (size.width() == 1 && size.height() == 1) | |
Stephen Chennney
2014/01/17 21:53:21
Not sure if the compiler automatically casts the 1
| |
1607 return; | |
1608 | |
1600 realizeSave(SkCanvas::kMatrix_SaveFlag); | 1609 realizeSave(SkCanvas::kMatrix_SaveFlag); |
1601 | 1610 |
1602 m_canvas->scale(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar (size.height())); | 1611 m_canvas->scale(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar (size.height())); |
1603 } | 1612 } |
1604 | 1613 |
1605 void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect) | 1614 void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect) |
1606 { | 1615 { |
1607 if (paintingDisabled()) | 1616 if (paintingDisabled()) |
1608 return; | 1617 return; |
1609 | 1618 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1995 | 2004 |
1996 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 2005 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
1997 { | 2006 { |
1998 if (m_trackTextRegion) { | 2007 if (m_trackTextRegion) { |
1999 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); | 2008 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); |
2000 m_textRegion.join(textRect); | 2009 m_textRegion.join(textRect); |
2001 } | 2010 } |
2002 } | 2011 } |
2003 | 2012 |
2004 } | 2013 } |
OLD | NEW |