mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
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:
parent
7df55cf9f2
commit
5434a4fec1
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user