Host GraphicsContext's CTM inside GraphicsContextState
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Oct 2015 17:28:41 +0000 (17:28 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Oct 2015 17:28:41 +0000 (17:28 +0000)
commit06d5fa1d5df0f8ee88afa23a717ed711c528a67a
tree18122246824071e6c805c2ed0a71ebe563535d16
parent9d32f06cb9be1bdd590311c6a3b68a6133bc7726
Host GraphicsContext's CTM inside GraphicsContextState
https://bugs.webkit.org/show_bug.cgi?id=150146

Reviewed by Simon Fraser.

There are 6 operations which interact with CTMs:
- Get
- Set
- Concatenate
- Scale
- Rotate
- Translate

This patch modifies all these operations so that these operations shadow the
platform's CTM inside GraphicsContextState. This way, we don't have to consult
with the underlying graphics context in order to know the current CTM.

There are currently many places in the Core Graphics ports where we will change
the platform's CTM out from under the GraphicsContext. This patch migrates
those users to going through GraphicsContext, thereby preserving the integrity
of the shadowed state.

No new tests because there is no behavior change.

* platform/graphics/GraphicsContext.cpp: Setters deletate to platform calls.
The getter can just consult with the shadowed state.
(WebCore::GraphicsContext::concatCTM):
(WebCore::GraphicsContext::scale):
(WebCore::GraphicsContext::rotate):
(WebCore::GraphicsContext::translate):
(WebCore::GraphicsContext::setCTM):
(WebCore::GraphicsContext::getCTM):
(WebCore::GraphicsContext::beginTransparencyLayer):
(WebCore::GraphicsContext::applyDeviceScaleFactor):
* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContext::scale):
(WebCore::GraphicsContext::checkCTMInvariants): Make sure the shadowed state
matches the platform graphics context's state.
* platform/graphics/cairo/GraphicsContextCairo.cpp: Renaming functions.
(WebCore::GraphicsContext::resetPlatformCTM):
(WebCore::GraphicsContext::getPlatformCTM):
(WebCore::GraphicsContext::translatePlatformCTM):
(WebCore::GraphicsContext::concatPlatformCTM):
(WebCore::GraphicsContext::setPlatformCTM):
(WebCore::GraphicsContext::rotatePlatformCTM):
(WebCore::GraphicsContext::scalePlatformCTM):
(WebCore::GraphicsContext::getCTM): Deleted.
(WebCore::GraphicsContext::translate): Deleted.
(WebCore::GraphicsContext::concatCTM): Deleted.
(WebCore::GraphicsContext::setCTM): Deleted.
(WebCore::GraphicsContext::rotate): Deleted.
(WebCore::GraphicsContext::scale): Deleted.
* platform/graphics/cg/GraphicsContextCG.cpp: Renaming functions. Also,
migrate CTM setters to go through GraphicsContext.
(WebCore::GraphicsContext::resetPlatformCTM):
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::drawNativeImage):
(WebCore::drawPatternCallback):
(WebCore::GraphicsContext::drawPattern):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::strokeRect):
(WebCore::GraphicsContext::scalePlatformCTM):
(WebCore::GraphicsContext::rotatePlatformCTM):
(WebCore::GraphicsContext::translatePlatformCTM):
(WebCore::GraphicsContext::concatPlatformCTM):
(WebCore::GraphicsContext::setPlatformCTM):
(WebCore::GraphicsContext::getPlatformCTM):
(WebCore::GraphicsContext::scale): Deleted.
(WebCore::GraphicsContext::rotate): Deleted.
(WebCore::GraphicsContext::translate): Deleted.
(WebCore::GraphicsContext::concatCTM): Deleted.
(WebCore::GraphicsContext::setCTM): Deleted.
(WebCore::GraphicsContext::getCTM): Deleted.
* platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
(WebCore::GraphicsContextPlatformPrivate::save):
(WebCore::GraphicsContextPlatformPrivate::restore):
(WebCore::GraphicsContextPlatformPrivate::flush):
(WebCore::GraphicsContextPlatformPrivate::clip):
(WebCore::GraphicsContextPlatformPrivate::scale):
(WebCore::GraphicsContextPlatformPrivate::rotate):
(WebCore::GraphicsContextPlatformPrivate::translate):
(WebCore::GraphicsContextPlatformPrivate::concatCTM):
(WebCore::GraphicsContextPlatformPrivate::setCTM):
* platform/graphics/transforms/AffineTransform.h:
(WebCore::AffineTransform::isEssentiallyEqualTo): Equality comparison on floats
is not a good idea. Instead, this function is more valuable. (However, note that
it is expected for values in a CTM to hold values close to 0, which means that
this function might erroneously return false (similar to operator=()).
* platform/graphics/win/GraphicsContextWin.cpp:
(WebCore::GraphicsContextPlatformPrivate::scale):
(WebCore::GraphicsContextPlatformPrivate::concatPlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::setPlatformCTM):
(WebCore::GraphicsContextPlatformPrivate::concatCTM): Deleted.
(WebCore::GraphicsContextPlatformPrivate::setCTM): Deleted.
* platform/mac/DragImageMac.mm:
(WebCore::drawAtPoint):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191295 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/Image.h
Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
Source/WebCore/platform/graphics/transforms/AffineTransform.h
Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp
Source/WebCore/platform/mac/DragImageMac.mm
Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h