Bug 1231864 (part 2) - Clean up gfxWindowsNativeDrawing::BeginNativeDrawing(). r=mattwoodrow.

This patch inlines the CurrentSurface() and GetDCWithClip() calls in
BeginNativeDrawing(). This allows them to share a single |cairo_t*| and gets
rid of the GetCairo() call in GetDCWithClip(), which was one of those confusing
ones that only made sense if its a Cairo backend.

The patch also inverts the sense of mDeviceOffset, and changes its type from
gfxPoint to Point.
This commit is contained in:
Nicholas Nethercote 2015-12-14 15:00:08 -08:00
Родитель 7df55cf9f2
Коммит 5434a4fec1
4 изменённых файлов: 22 добавлений и 14 удалений

Просмотреть файл

@ -15,6 +15,9 @@
#include "mozilla/gfx/Helpers.h"
#include "gfx2DGlue.h"
#include "cairo.h"
#include "cairo-win32.h"
using namespace mozilla;
using namespace mozilla::gfx;
@ -43,8 +46,21 @@ HDC
gfxWindowsNativeDrawing::BeginNativeDrawing()
{
if (mRenderState == RENDER_STATE_INIT) {
RefPtr<gfxASurface> surf =
mContext->CurrentSurface(&mDeviceOffset.x, &mDeviceOffset.y);
RefPtr<gfxASurface> surf;
DrawTarget* drawTarget = mContext->GetDrawTarget();
cairo_t* cairo = nullptr;
if (drawTarget->GetBackendType() == BackendType::CAIRO) {
cairo = static_cast<cairo_t*>
(drawTarget->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
if (cairo) {
cairo_surface_t* s = cairo_get_target(cairo);
if (s) {
mDeviceOffset = mContext->GetDeviceOffset();
surf = gfxASurface::Wrap(s);
}
}
}
if (surf && surf->CairoStatus() != 0)
return nullptr;
@ -69,7 +85,7 @@ gfxWindowsNativeDrawing::BeginNativeDrawing()
// grab the DC. This can fail if there is a complex clipping path,
// in which case we'll have to fall back.
mWinSurface = static_cast<gfxWindowsSurface*>(static_cast<gfxASurface*>(surf.get()));
mDC = mWinSurface->GetDCWithClip(mContext);
mDC = cairo_win32_get_dc_with_clip(cairo);
if (mDC) {
if (mTransformType == TRANSLATION_ONLY) {
@ -146,8 +162,8 @@ gfxWindowsNativeDrawing::BeginNativeDrawing()
}
GetViewportOrgEx(mDC, &mOrigViewportOrigin);
SetViewportOrgEx(mDC,
mOrigViewportOrigin.x + (int)mDeviceOffset.x,
mOrigViewportOrigin.y + (int)mDeviceOffset.y,
mOrigViewportOrigin.x - (int)mDeviceOffset.x,
mOrigViewportOrigin.y - (int)mDeviceOffset.y,
nullptr);
return mDC;

Просмотреть файл

@ -91,7 +91,7 @@ private:
// what state the rendering is in
uint8_t mRenderState;
gfxPoint mDeviceOffset;
mozilla::gfx::Point mDeviceOffset;
RefPtr<gfxPattern> mBlackPattern, mWhitePattern;
enum TransformType {

Просмотреть файл

@ -172,12 +172,6 @@ gfxWindowsSurface::~gfxWindowsSurface()
}
}
HDC
gfxWindowsSurface::GetDCWithClip(gfxContext *ctx)
{
return cairo_win32_get_dc_with_clip (ctx->GetCairo());
}
HDC
gfxWindowsSurface::GetDC()
{

Просмотреть файл

@ -53,8 +53,6 @@ public:
HDC GetDC();
HDC GetDCWithClip(gfxContext *);
already_AddRefed<gfxImageSurface> GetAsImageSurface();
nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);