Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "mozilla/ipc/DocumentRendererParent.h" |
michael@0 | 6 | #include "gfxImageSurface.h" |
michael@0 | 7 | #include "gfxPattern.h" |
michael@0 | 8 | #include "nsICanvasRenderingContextInternal.h" |
michael@0 | 9 | |
michael@0 | 10 | using namespace mozilla::ipc; |
michael@0 | 11 | |
michael@0 | 12 | DocumentRendererParent::DocumentRendererParent() |
michael@0 | 13 | {} |
michael@0 | 14 | |
michael@0 | 15 | DocumentRendererParent::~DocumentRendererParent() |
michael@0 | 16 | {} |
michael@0 | 17 | |
michael@0 | 18 | void DocumentRendererParent::SetCanvasContext(nsICanvasRenderingContextInternal* aCanvas, |
michael@0 | 19 | gfxContext* ctx) |
michael@0 | 20 | { |
michael@0 | 21 | mCanvas = aCanvas; |
michael@0 | 22 | mCanvasContext = ctx; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | void DocumentRendererParent::DrawToCanvas(const nsIntSize& aSize, |
michael@0 | 26 | const nsCString& aData) |
michael@0 | 27 | { |
michael@0 | 28 | if (!mCanvas || !mCanvasContext) |
michael@0 | 29 | return; |
michael@0 | 30 | |
michael@0 | 31 | nsRefPtr<gfxImageSurface> surf = |
michael@0 | 32 | new gfxImageSurface(reinterpret_cast<uint8_t*>(const_cast<nsCString&>(aData).BeginWriting()), |
michael@0 | 33 | gfxIntSize(aSize.width, aSize.height), |
michael@0 | 34 | aSize.width * 4, |
michael@0 | 35 | gfxImageFormat::ARGB32); |
michael@0 | 36 | nsRefPtr<gfxPattern> pat = new gfxPattern(surf); |
michael@0 | 37 | |
michael@0 | 38 | gfxRect rect(gfxPoint(0, 0), gfxSize(aSize.width, aSize.height)); |
michael@0 | 39 | mCanvasContext->NewPath(); |
michael@0 | 40 | mCanvasContext->PixelSnappedRectangleAndSetPattern(rect, pat); |
michael@0 | 41 | mCanvasContext->Fill(); |
michael@0 | 42 | |
michael@0 | 43 | // get rid of the pattern surface ref, because aData is very |
michael@0 | 44 | // likely to go away shortly |
michael@0 | 45 | mCanvasContext->SetColor(gfxRGBA(1,1,1,1)); |
michael@0 | 46 | |
michael@0 | 47 | gfxRect damageRect = mCanvasContext->UserToDevice(rect); |
michael@0 | 48 | mCanvas->Redraw(damageRect); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | bool |
michael@0 | 52 | DocumentRendererParent::Recv__delete__(const nsIntSize& renderedSize, |
michael@0 | 53 | const nsCString& data) |
michael@0 | 54 | { |
michael@0 | 55 | DrawToCanvas(renderedSize, data); |
michael@0 | 56 | return true; |
michael@0 | 57 | } |