2005-04-06 05:54:26 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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/. */
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2007-05-10 23:58:09 +04:00
|
|
|
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2013-10-08 03:15:59 +04:00
|
|
|
#if defined(HAVE_POSIX_MEMALIGN)
|
2011-02-17 01:43:30 +03:00
|
|
|
#include "gfxAlphaRecovery.h"
|
2013-10-08 03:15:59 +04:00
|
|
|
#endif
|
2005-04-07 23:12:19 +04:00
|
|
|
#include "gfxImageSurface.h"
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2007-01-27 04:26:49 +03:00
|
|
|
#include "cairo.h"
|
2012-06-15 02:00:44 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2016-01-08 07:57:38 +03:00
|
|
|
#include "mozilla/gfx/HelpersCairo.h"
|
2012-06-15 02:00:44 +04:00
|
|
|
#include "gfx2DGlue.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2012-06-15 02:00:44 +04:00
|
|
|
|
2014-02-25 05:30:48 +04:00
|
|
|
using namespace mozilla;
|
2012-06-15 02:00:44 +04:00
|
|
|
using namespace mozilla::gfx;
|
2007-01-27 04:26:49 +03:00
|
|
|
|
2010-05-13 19:52:59 +04:00
|
|
|
gfxImageSurface::gfxImageSurface()
|
|
|
|
: mSize(0, 0),
|
2011-10-17 18:59:28 +04:00
|
|
|
mOwnsData(false),
|
2016-01-08 07:57:38 +03:00
|
|
|
mFormat(SurfaceFormat::UNKNOWN),
|
2010-05-13 19:52:59 +04:00
|
|
|
mStride(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxImageSurface::InitFromSurface(cairo_surface_t *csurf)
|
|
|
|
{
|
2015-12-04 21:43:00 +03:00
|
|
|
if (!csurf || cairo_surface_status(csurf)) {
|
|
|
|
MakeInvalid();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-13 19:52:59 +04:00
|
|
|
mSize.width = cairo_image_surface_get_width(csurf);
|
|
|
|
mSize.height = cairo_image_surface_get_height(csurf);
|
|
|
|
mData = cairo_image_surface_get_data(csurf);
|
2016-01-08 07:57:38 +03:00
|
|
|
mFormat = CairoFormatToGfxFormat(cairo_image_surface_get_format(csurf));
|
2011-10-17 18:59:28 +04:00
|
|
|
mOwnsData = false;
|
2010-05-13 19:52:59 +04:00
|
|
|
mStride = cairo_image_surface_get_stride(csurf);
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
Init(csurf, true);
|
2010-05-13 19:52:59 +04:00
|
|
|
}
|
|
|
|
|
2015-06-01 11:26:19 +03:00
|
|
|
gfxImageSurface::gfxImageSurface(unsigned char *aData, const IntSize& aSize,
|
2008-07-09 12:22:20 +04:00
|
|
|
long aStride, gfxImageFormat aFormat)
|
|
|
|
{
|
2010-10-25 21:57:13 +04:00
|
|
|
InitWithData(aData, aSize, aStride, aFormat);
|
|
|
|
}
|
|
|
|
|
2011-09-13 18:49:01 +04:00
|
|
|
void
|
|
|
|
gfxImageSurface::MakeInvalid()
|
|
|
|
{
|
2015-06-01 11:26:19 +03:00
|
|
|
mSize = IntSize(-1, -1);
|
2013-07-31 19:44:31 +04:00
|
|
|
mData = nullptr;
|
2011-09-13 18:49:01 +04:00
|
|
|
mStride = 0;
|
|
|
|
}
|
|
|
|
|
2010-10-25 21:57:13 +04:00
|
|
|
void
|
2015-06-01 11:26:19 +03:00
|
|
|
gfxImageSurface::InitWithData(unsigned char *aData, const IntSize& aSize,
|
2010-10-25 21:57:13 +04:00
|
|
|
long aStride, gfxImageFormat aFormat)
|
|
|
|
{
|
|
|
|
mSize = aSize;
|
2011-10-17 18:59:28 +04:00
|
|
|
mOwnsData = false;
|
2010-10-25 21:57:13 +04:00
|
|
|
mData = aData;
|
|
|
|
mFormat = aFormat;
|
|
|
|
mStride = aStride;
|
|
|
|
|
2008-07-09 12:22:20 +04:00
|
|
|
if (!CheckSurfaceSize(aSize))
|
2011-09-13 18:49:01 +04:00
|
|
|
MakeInvalid();
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2016-01-08 07:57:38 +03:00
|
|
|
cairo_format_t cformat = GfxFormatToCairoFormat(mFormat);
|
2008-07-09 12:22:20 +04:00
|
|
|
cairo_surface_t *surface =
|
|
|
|
cairo_image_surface_create_for_data((unsigned char*)mData,
|
2015-09-29 07:11:52 +03:00
|
|
|
cformat,
|
2008-07-09 12:22:20 +04:00
|
|
|
mSize.width,
|
|
|
|
mSize.height,
|
|
|
|
mStride);
|
|
|
|
|
|
|
|
// cairo_image_surface_create_for_data can return a 'null' surface
|
|
|
|
// in out of memory conditions. The gfxASurface::Init call checks
|
|
|
|
// the surface it receives to see if there is an error with the
|
|
|
|
// surface and handles it appropriately. That is why there is
|
|
|
|
// no check here.
|
|
|
|
Init(surface);
|
|
|
|
}
|
|
|
|
|
2011-02-17 01:43:30 +03:00
|
|
|
static void*
|
|
|
|
TryAllocAlignedBytes(size_t aSize)
|
|
|
|
{
|
|
|
|
// Use fallible allocators here
|
2012-04-05 11:20:53 +04:00
|
|
|
#if defined(HAVE_POSIX_MEMALIGN)
|
2011-02-17 01:43:30 +03:00
|
|
|
void* ptr;
|
|
|
|
// Try to align for fast alpha recovery. This should only help
|
|
|
|
// cairo too, can't hurt.
|
|
|
|
return moz_posix_memalign(&ptr,
|
|
|
|
1 << gfxAlphaRecovery::GoodAlignmentLog2(),
|
|
|
|
aSize) ?
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr : ptr;
|
2011-02-17 01:43:30 +03:00
|
|
|
#else
|
|
|
|
// Oh well, hope that luck is with us in the allocator
|
2015-02-19 07:51:06 +03:00
|
|
|
return malloc(aSize);
|
2011-02-17 01:43:30 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-06-01 11:26:19 +03:00
|
|
|
gfxImageSurface::gfxImageSurface(const IntSize& size, gfxImageFormat format, bool aClear)
|
2013-04-19 14:13:18 +04:00
|
|
|
: mSize(size), mData(nullptr), mFormat(format)
|
2005-04-06 05:54:26 +04:00
|
|
|
{
|
2013-04-19 14:13:18 +04:00
|
|
|
AllocateAndInit(0, 0, aClear);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gfxImageSurface::AllocateAndInit(long aStride, int32_t aMinimalAllocation,
|
|
|
|
bool aClear)
|
|
|
|
{
|
|
|
|
// The callers should set mSize and mFormat.
|
|
|
|
MOZ_ASSERT(!mData);
|
|
|
|
mData = nullptr;
|
|
|
|
mOwnsData = false;
|
|
|
|
|
|
|
|
mStride = aStride > 0 ? aStride : ComputeStride();
|
|
|
|
if (aMinimalAllocation < mSize.height * mStride)
|
|
|
|
aMinimalAllocation = mSize.height * mStride;
|
2007-05-10 23:58:09 +04:00
|
|
|
|
2013-04-19 14:13:18 +04:00
|
|
|
if (!CheckSurfaceSize(mSize))
|
2011-09-13 18:49:01 +04:00
|
|
|
MakeInvalid();
|
2007-05-10 23:58:09 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
// if we have a zero-sized surface, just leave mData nullptr
|
2007-05-21 02:46:53 +04:00
|
|
|
if (mSize.height * mStride > 0) {
|
2010-08-24 02:42:51 +04:00
|
|
|
|
2011-02-17 01:43:30 +03:00
|
|
|
// This can fail to allocate memory aligned as we requested,
|
|
|
|
// or it can fail to allocate any memory at all.
|
2013-04-19 14:13:18 +04:00
|
|
|
mData = (unsigned char *) TryAllocAlignedBytes(aMinimalAllocation);
|
2007-05-21 02:46:53 +04:00
|
|
|
if (!mData)
|
|
|
|
return;
|
2012-04-18 01:55:11 +04:00
|
|
|
if (aClear)
|
2013-04-19 14:13:18 +04:00
|
|
|
memset(mData, 0, aMinimalAllocation);
|
2007-05-21 02:46:53 +04:00
|
|
|
}
|
2007-05-10 23:58:09 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mOwnsData = true;
|
2005-04-06 05:54:26 +04:00
|
|
|
|
2016-01-08 07:57:38 +03:00
|
|
|
cairo_format_t cformat = GfxFormatToCairoFormat(mFormat);
|
2005-06-30 08:58:27 +04:00
|
|
|
cairo_surface_t *surface =
|
|
|
|
cairo_image_surface_create_for_data((unsigned char*)mData,
|
2015-09-29 07:11:52 +03:00
|
|
|
cformat,
|
2007-02-08 23:47:48 +03:00
|
|
|
mSize.width,
|
|
|
|
mSize.height,
|
2007-05-10 23:58:09 +04:00
|
|
|
mStride);
|
2010-05-22 08:10:14 +04:00
|
|
|
|
2005-06-30 08:58:27 +04:00
|
|
|
Init(surface);
|
2010-05-22 08:10:14 +04:00
|
|
|
|
2010-11-19 19:56:05 +03:00
|
|
|
if (mSurfaceValid) {
|
|
|
|
RecordMemoryUsed(mSize.height * ComputeStride() +
|
|
|
|
sizeof(gfxImageSurface));
|
|
|
|
}
|
2005-04-06 05:54:26 +04:00
|
|
|
}
|
|
|
|
|
2015-06-01 11:26:19 +03:00
|
|
|
gfxImageSurface::gfxImageSurface(const IntSize& size, gfxImageFormat format,
|
2013-04-19 14:13:18 +04:00
|
|
|
long aStride, int32_t aExtraBytes, bool aClear)
|
|
|
|
: mSize(size), mData(nullptr), mFormat(format)
|
|
|
|
{
|
|
|
|
AllocateAndInit(aStride, aExtraBytes, aClear);
|
|
|
|
}
|
|
|
|
|
2006-04-05 01:54:22 +04:00
|
|
|
gfxImageSurface::gfxImageSurface(cairo_surface_t *csurf)
|
|
|
|
{
|
2007-02-08 23:47:48 +03:00
|
|
|
mSize.width = cairo_image_surface_get_width(csurf);
|
|
|
|
mSize.height = cairo_image_surface_get_height(csurf);
|
2006-08-10 02:43:06 +04:00
|
|
|
mData = cairo_image_surface_get_data(csurf);
|
2016-01-08 07:57:38 +03:00
|
|
|
mFormat = CairoFormatToGfxFormat(cairo_image_surface_get_format(csurf));
|
2011-10-17 18:59:28 +04:00
|
|
|
mOwnsData = false;
|
2006-08-10 02:43:06 +04:00
|
|
|
mStride = cairo_image_surface_get_stride(csurf);
|
2006-04-05 01:54:22 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
Init(csurf, true);
|
2006-04-05 01:54:22 +04:00
|
|
|
}
|
|
|
|
|
2005-04-07 23:12:19 +04:00
|
|
|
gfxImageSurface::~gfxImageSurface()
|
2005-04-06 05:54:26 +04:00
|
|
|
{
|
2008-07-08 03:49:39 +04:00
|
|
|
if (mOwnsData)
|
2007-05-10 23:58:09 +04:00
|
|
|
free(mData);
|
2005-04-06 05:54:26 +04:00
|
|
|
}
|
2005-06-30 08:58:27 +04:00
|
|
|
|
2011-01-04 19:40:54 +03:00
|
|
|
/*static*/ long
|
2015-06-01 11:26:19 +03:00
|
|
|
gfxImageSurface::ComputeStride(const IntSize& aSize, gfxImageFormat aFormat)
|
2005-06-30 08:58:27 +04:00
|
|
|
{
|
|
|
|
long stride;
|
|
|
|
|
2016-01-08 07:57:38 +03:00
|
|
|
if (aFormat == SurfaceFormat::A8R8G8B8_UINT32)
|
2011-01-04 19:40:54 +03:00
|
|
|
stride = aSize.width * 4;
|
2016-01-08 07:57:38 +03:00
|
|
|
else if (aFormat == SurfaceFormat::X8R8G8B8_UINT32)
|
2011-01-04 19:40:54 +03:00
|
|
|
stride = aSize.width * 4;
|
2016-01-08 07:57:38 +03:00
|
|
|
else if (aFormat == SurfaceFormat::R5G6B5_UINT16)
|
2011-01-04 19:40:54 +03:00
|
|
|
stride = aSize.width * 2;
|
2016-01-08 07:57:38 +03:00
|
|
|
else if (aFormat == SurfaceFormat::A8)
|
2011-01-04 19:40:54 +03:00
|
|
|
stride = aSize.width;
|
2015-09-28 22:07:44 +03:00
|
|
|
else {
|
2005-06-30 08:58:27 +04:00
|
|
|
NS_WARNING("Unknown format specified to gfxImageSurface!");
|
2011-01-04 19:40:54 +03:00
|
|
|
stride = aSize.width * 4;
|
2005-06-30 08:58:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
stride = ((stride + 3) / 4) * 4;
|
|
|
|
|
|
|
|
return stride;
|
|
|
|
}
|
2008-02-06 09:48:47 +03:00
|
|
|
|
2012-11-27 04:29:56 +04:00
|
|
|
size_t
|
2013-06-23 16:03:39 +04:00
|
|
|
gfxImageSurface::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
2012-11-27 04:29:56 +04:00
|
|
|
{
|
|
|
|
size_t n = gfxASurface::SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
if (mOwnsData) {
|
|
|
|
n += aMallocSizeOf(mData);
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
2013-06-23 16:03:39 +04:00
|
|
|
gfxImageSurface::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
2012-11-27 04:29:56 +04:00
|
|
|
{
|
|
|
|
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
}
|
|
|
|
|
2012-12-19 09:59:30 +04:00
|
|
|
bool
|
|
|
|
gfxImageSurface::SizeOfIsMeasured() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-06-15 02:00:44 +04:00
|
|
|
// helper function for the CopyFrom methods
|
|
|
|
static void
|
2015-06-01 11:26:19 +03:00
|
|
|
CopyForStride(unsigned char* aDest, unsigned char* aSrc, const IntSize& aSize, long aDestStride, long aSrcStride)
|
2012-06-15 02:00:44 +04:00
|
|
|
{
|
|
|
|
if (aDestStride == aSrcStride) {
|
|
|
|
memcpy (aDest, aSrc, aSrcStride * aSize.height);
|
|
|
|
} else {
|
2013-01-15 16:22:03 +04:00
|
|
|
int lineSize = std::min(aDestStride, aSrcStride);
|
2012-06-15 02:00:44 +04:00
|
|
|
for (int i = 0; i < aSize.height; i++) {
|
|
|
|
unsigned char* src = aSrc + aSrcStride * i;
|
|
|
|
unsigned char* dst = aDest + aDestStride * i;
|
|
|
|
|
|
|
|
memcpy (dst, src, lineSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// helper function for the CopyFrom methods
|
|
|
|
static bool
|
2013-09-25 00:45:13 +04:00
|
|
|
FormatsAreCompatible(gfxImageFormat a1, gfxImageFormat a2)
|
2012-06-15 02:00:44 +04:00
|
|
|
{
|
|
|
|
if (a1 != a2 &&
|
2016-01-08 07:57:38 +03:00
|
|
|
!(a1 == SurfaceFormat::A8R8G8B8_UINT32 &&
|
|
|
|
a2 == SurfaceFormat::X8R8G8B8_UINT32) &&
|
|
|
|
!(a1 == SurfaceFormat::X8R8G8B8_UINT32 &&
|
|
|
|
a2 == SurfaceFormat::A8R8G8B8_UINT32)) {
|
2012-06-15 02:00:44 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-06-15 02:00:44 +04:00
|
|
|
gfxImageSurface::CopyFrom (SourceSurface *aSurface)
|
2008-02-06 09:48:47 +03:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataSourceSurface> data = aSurface->GetDataSurface();
|
2012-06-15 02:00:44 +04:00
|
|
|
|
|
|
|
if (!data) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2008-02-06 09:48:47 +03:00
|
|
|
}
|
|
|
|
|
2015-06-01 11:26:19 +03:00
|
|
|
IntSize size(data->GetSize().width, data->GetSize().height);
|
2012-06-15 02:00:44 +04:00
|
|
|
if (size != mSize) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2008-02-06 09:48:47 +03:00
|
|
|
}
|
|
|
|
|
2012-06-15 02:00:44 +04:00
|
|
|
if (!FormatsAreCompatible(SurfaceFormatToImageFormat(aSurface->GetFormat()),
|
|
|
|
mFormat)) {
|
|
|
|
return false;
|
|
|
|
}
|
2008-02-06 09:48:47 +03:00
|
|
|
|
2012-06-15 02:00:44 +04:00
|
|
|
CopyForStride(mData, data->GetData(), size, mStride, data->Stride());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
gfxImageSurface::CopyFrom(gfxImageSurface *other)
|
|
|
|
{
|
|
|
|
if (other->mSize != mSize) {
|
|
|
|
return false;
|
2012-06-08 03:42:21 +04:00
|
|
|
}
|
|
|
|
|
2012-06-15 02:00:44 +04:00
|
|
|
if (!FormatsAreCompatible(other->mFormat, mFormat)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyForStride(mData, other->mData, mSize, mStride, other->mStride);
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2008-02-06 09:48:47 +03:00
|
|
|
}
|
2010-09-15 20:02:42 +04:00
|
|
|
|
2013-11-27 14:03:36 +04:00
|
|
|
bool
|
|
|
|
gfxImageSurface::CopyTo(SourceSurface *aSurface) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataSourceSurface> data = aSurface->GetDataSurface();
|
2013-11-27 14:03:36 +04:00
|
|
|
|
|
|
|
if (!data) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-01 11:26:19 +03:00
|
|
|
IntSize size(data->GetSize().width, data->GetSize().height);
|
2013-11-27 14:03:36 +04:00
|
|
|
if (size != mSize) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!FormatsAreCompatible(SurfaceFormatToImageFormat(aSurface->GetFormat()),
|
|
|
|
mFormat)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyForStride(data->GetData(), mData, size, data->Stride(), mStride);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<DataSourceSurface>
|
2014-02-25 04:51:45 +04:00
|
|
|
gfxImageSurface::CopyToB8G8R8A8DataSourceSurface()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataSourceSurface> dataSurface =
|
2014-02-25 04:51:45 +04:00
|
|
|
Factory::CreateDataSourceSurface(IntSize(GetSize().width, GetSize().height),
|
|
|
|
SurfaceFormat::B8G8R8A8);
|
|
|
|
if (dataSurface) {
|
|
|
|
CopyTo(dataSurface);
|
|
|
|
}
|
|
|
|
return dataSurface.forget();
|
|
|
|
}
|
|
|
|
|
2010-09-15 20:02:42 +04:00
|
|
|
already_AddRefed<gfxSubimageSurface>
|
|
|
|
gfxImageSurface::GetSubimage(const gfxRect& aRect)
|
|
|
|
{
|
|
|
|
gfxRect r(aRect);
|
|
|
|
r.Round();
|
2013-09-19 09:23:31 +04:00
|
|
|
MOZ_ASSERT(gfxRect(0, 0, mSize.width, mSize.height).Contains(r));
|
|
|
|
|
2013-09-20 13:50:05 +04:00
|
|
|
gfxImageFormat format = Format();
|
|
|
|
|
2010-09-15 20:02:42 +04:00
|
|
|
unsigned char* subData = Data() +
|
|
|
|
(Stride() * (int)r.Y()) +
|
|
|
|
(int)r.X() * gfxASurface::BytePerPixelFromFormat(Format());
|
|
|
|
|
2016-01-08 07:57:38 +03:00
|
|
|
if (format == SurfaceFormat::A8R8G8B8_UINT32 &&
|
2013-09-20 13:50:05 +04:00
|
|
|
GetOpaqueRect().Contains(aRect)) {
|
2016-01-08 07:57:38 +03:00
|
|
|
format = SurfaceFormat::X8R8G8B8_UINT32;
|
2013-09-20 13:50:05 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxSubimageSurface> image =
|
2010-09-15 20:02:42 +04:00
|
|
|
new gfxSubimageSurface(this, subData,
|
2015-06-01 11:26:19 +03:00
|
|
|
IntSize((int)r.Width(), (int)r.Height()),
|
2013-09-20 13:50:05 +04:00
|
|
|
format);
|
2010-09-15 20:02:42 +04:00
|
|
|
|
2013-04-22 15:15:59 +04:00
|
|
|
return image.forget();
|
2010-09-15 20:02:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxSubimageSurface::gfxSubimageSurface(gfxImageSurface* aParent,
|
|
|
|
unsigned char* aData,
|
2015-06-01 11:26:19 +03:00
|
|
|
const IntSize& aSize,
|
2013-09-20 13:50:05 +04:00
|
|
|
gfxImageFormat aFormat)
|
|
|
|
: gfxImageSurface(aData, aSize, aParent->Stride(), aFormat)
|
2010-09-15 20:02:42 +04:00
|
|
|
, mParent(aParent)
|
|
|
|
{
|
|
|
|
}
|
2010-11-11 23:31:22 +03:00
|
|
|
|
|
|
|
already_AddRefed<gfxImageSurface>
|
|
|
|
gfxImageSurface::GetAsImageSurface()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxImageSurface> surface = this;
|
2010-11-11 23:31:22 +03:00
|
|
|
return surface.forget();
|
|
|
|
}
|