Bug 1003707 - Implement GetSize for recording surface created by windows printing. r=Bas

This commit is contained in:
Matt Woodrow 2014-05-28 12:59:10 +12:00
Родитель 6e2a836d23
Коммит ee01a4734c
2 изменённых файлов: 14 добавлений и 2 удалений

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

@ -10,6 +10,7 @@
#include "gfxTypes.h"
#include "mozilla/Scoped.h"
#include "nscore.h"
#include "nsSize.h"
#ifdef MOZILLA_INTERNAL_API
#include "nsStringFwd.h"
@ -22,7 +23,6 @@ struct nsIntPoint;
struct nsIntRect;
struct gfxRect;
struct gfxPoint;
struct nsIntSize;
template <typename T>
struct already_AddRefed;
@ -274,11 +274,18 @@ protected:
*/
class gfxUnknownSurface : public gfxASurface {
public:
gfxUnknownSurface(cairo_surface_t *surf) {
gfxUnknownSurface(cairo_surface_t *surf)
: mSize(-1, -1)
{
Init(surf, true);
}
virtual ~gfxUnknownSurface() { }
virtual const nsIntSize GetSize() const { return mSize; }
void SetSize(const nsIntSize& aSize) { mSize = aSize; }
private:
nsIntSize mSize;
};
#endif /* GFX_ASURFACE_H */

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

@ -149,6 +149,11 @@ gfxWindowsSurface::CreateSimilarSurface(gfxContentType aContent,
}
nsRefPtr<gfxASurface> result = Wrap(surface);
if (mForPrinting) {
MOZ_ASSERT(result->GetType() == gfxSurfaceType::Recording);
gfxUnknownSurface *unknown = static_cast<gfxUnknownSurface*>(result.get());
unknown->SetSize(aSize);
}
cairo_surface_destroy(surface);
return result.forget();
}