author | Jonathan Watt <jwatt@jwatt.org> |
Fri, 24 Oct 2014 08:26:27 +0100 | |
changeset 212077 | d2836e069aef6d8ce2cd6aad02cebcc8a1a3b57e |
parent 212076 | ac33dde6856caa7bffb3ebe6c5d9d0b7b1845c9e |
child 212078 | 4ded53bfb503183e0c97273938498857187f9f92 |
push id | 27697 |
push user | cbook@mozilla.com |
push date | Fri, 24 Oct 2014 13:48:53 +0000 |
treeherder | mozilla-central@de805196bbc4 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mattwoodrow |
bugs | 1087568 |
milestone | 36.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/canvas/DocumentRendererParent.cpp +++ b/dom/canvas/DocumentRendererParent.cpp @@ -1,16 +1,18 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "mozilla/ipc/DocumentRendererParent.h" + +#include "gfx2DGlue.h" #include "mozilla/gfx/2D.h" -#include "mozilla/ipc/DocumentRendererParent.h" +#include "mozilla/gfx/PathHelpers.h" #include "mozilla/RefPtr.h" -#include "gfxPattern.h" #include "nsICanvasRenderingContextInternal.h" using namespace mozilla; using namespace mozilla::gfx; using namespace mozilla::ipc; DocumentRendererParent::DocumentRendererParent() {} @@ -26,33 +28,28 @@ void DocumentRendererParent::SetCanvasCo } void DocumentRendererParent::DrawToCanvas(const nsIntSize& aSize, const nsCString& aData) { if (!mCanvas || !mCanvasContext) return; + DrawTarget* drawTarget = mCanvasContext->GetDrawTarget(); + Rect rect(0, 0, aSize.width, aSize.height); + MaybeSnapToDevicePixels(rect, *drawTarget, true); RefPtr<DataSourceSurface> dataSurface = Factory::CreateWrappingDataSourceSurface(reinterpret_cast<uint8_t*>(const_cast<nsCString&>(aData).BeginWriting()), aSize.width * 4, IntSize(aSize.width, aSize.height), SurfaceFormat::B8G8R8A8); - nsRefPtr<gfxPattern> pat = new gfxPattern(dataSurface, Matrix()); + SurfacePattern pattern(dataSurface, ExtendMode::CLAMP); + drawTarget->FillRect(rect, pattern); - gfxRect rect(gfxPoint(0, 0), gfxSize(aSize.width, aSize.height)); - mCanvasContext->NewPath(); - mCanvasContext->PixelSnappedRectangleAndSetPattern(rect, pat); - mCanvasContext->Fill(); - - // get rid of the pattern surface ref, because aData is very - // likely to go away shortly - mCanvasContext->SetColor(gfxRGBA(1,1,1,1)); - - gfxRect damageRect = mCanvasContext->UserToDevice(rect); + gfxRect damageRect = mCanvasContext->UserToDevice(ThebesRect(rect)); mCanvas->Redraw(damageRect); } void DocumentRendererParent::ActorDestroy(ActorDestroyReason aWhy) { // Implement me! Bug 1005139 }
--- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -545,38 +545,16 @@ gfxContext::UserToDevicePixelSnapped(gfx #undef WITHIN_E pt = UserToDevice(pt); pt.Round(); return true; } void -gfxContext::PixelSnappedRectangleAndSetPattern(const gfxRect& rect, - gfxPattern *pattern) -{ - gfxRect r(rect); - - // Bob attempts to pixel-snap the rectangle, and returns true if - // the snapping succeeds. If it does, we need to set up an - // identity matrix, because the rectangle given back is in device - // coordinates. - // - // We then have to call a translate to dr.pos afterwards, to make - // sure the image lines up in the right place with our pixel - // snapped rectangle. - // - // If snapping wasn't successful, we just translate to where the - // pattern would normally start (in app coordinates) and do the - // same thing. - Rectangle(r, true); - SetPattern(pattern); -} - -void gfxContext::SetAntialiasMode(AntialiasMode mode) { CurrentState().aaMode = mode; } AntialiasMode gfxContext::CurrentAntialiasMode() const {
--- a/gfx/thebes/gfxContext.h +++ b/gfx/thebes/gfxContext.h @@ -304,25 +304,16 @@ public: * * If ignoreScale is true, then snapping will take place even if * the CTM has a scale applied. Snapping never takes place if * there is a rotation in the CTM. */ bool UserToDevicePixelSnapped(gfxPoint& pt, bool ignoreScale = false) const; /** - * Attempts to pixel snap the rectangle, add it to the current - * path, and to set pattern as the current painting source. This - * should be used for drawing filled pixel-snapped rectangles (like - * images), because the CTM at the time of the SetPattern call needs - * to have a snapped translation, or you get smeared images. - */ - void PixelSnappedRectangleAndSetPattern(const gfxRect& rect, gfxPattern *pattern); - - /** ** Painting sources **/ /** * Set a solid color to use for drawing. This color is in the device color space * and is not transformed. */ void SetDeviceColor(const gfxRGBA& c);