Bug 961783. Remove unneeded DDB optimization. r=vlad

As far as I can tell we always draw images to dc's that are in system memory.
In this case there's no upside to having ddb and a potential downside because
we have to do a readback from gpu into system memory.

--HG--
extra : rebase_source : e536721adc1de2bcff3300ee29c2d1c4b8c15ac0
This commit is contained in:
Jeff Muizelaar 2014-01-20 12:02:34 -05:00
Родитель 454490103b
Коммит 75796ea17d
4 изменённых файлов: 1 добавлений и 81 удалений

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

@ -199,31 +199,6 @@ gfxWindowsSurface::GetAsImageSurface()
return result.forget();
}
already_AddRefed<gfxWindowsSurface>
gfxWindowsSurface::OptimizeToDDB(HDC dc, const gfxIntSize& size, gfxImageFormat format)
{
if (mForPrinting)
return nullptr;
if (format != gfxImageFormatRGB24)
return nullptr;
nsRefPtr<gfxWindowsSurface> wsurf = new gfxWindowsSurface(dc, size, format);
if (wsurf->CairoStatus() != 0)
return nullptr;
gfxContext tmpCtx(wsurf);
tmpCtx.SetOperator(gfxContext::OPERATOR_SOURCE);
tmpCtx.SetSource(this);
tmpCtx.Paint();
// we let the new DDB surfaces be converted back to dibsections if
// acquire_source_image is called on them
cairo_win32_surface_set_can_convert_to_dib(wsurf->CairoSurface(), TRUE);
return wsurf.forget().downcast<gfxWindowsSurface>();
}
nsresult
gfxWindowsSurface::BeginPrinting(const nsAString& aTitle,
const nsAString& aPrintToFileName)

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

@ -57,10 +57,6 @@ public:
already_AddRefed<gfxImageSurface> GetAsImageSurface();
already_AddRefed<gfxWindowsSurface> OptimizeToDDB(HDC dc,
const gfxIntSize& size,
gfxImageFormat format);
nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
nsresult EndPrinting();
nsresult AbortPrinting();

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

@ -28,13 +28,6 @@ static bool gDisableOptimize = false;
/* Whether to use the windows surface; only for desktop win32 */
#define USE_WIN_SURFACE 1
static uint32_t gTotalDDBs = 0;
static uint32_t gTotalDDBSize = 0;
// only use up a maximum of 64MB in DDBs
#define kMaxDDBSize (64*1024*1024)
// and don't let anything in that's bigger than 4MB
#define kMaxSingleDDBSize (4*1024*1024)
#endif
using namespace mozilla;
@ -113,9 +106,6 @@ imgFrame::imgFrame() :
mFormatChanged(false),
mCompositingFailed(false),
mNonPremult(false),
#ifdef USE_WIN_SURFACE
mIsDDBSurface(false),
#endif
mInformedDiscardTracker(false),
mDirty(false)
{
@ -132,12 +122,6 @@ imgFrame::~imgFrame()
{
moz_free(mPalettedImageData);
mPalettedImageData = nullptr;
#ifdef USE_WIN_SURFACE
if (mIsDDBSurface) {
gTotalDDBs--;
gTotalDDBSize -= mSize.width * mSize.height * 4;
}
#endif
if (mInformedDiscardTracker) {
DiscardTracker::InformAllocation(-4 * mSize.height * mSize.width);
@ -296,40 +280,8 @@ nsresult imgFrame::Optimize()
mOptSurface = nullptr;
#ifdef USE_WIN_SURFACE
// we need to special-case windows here, because windows has
// a distinction between DIB and DDB and we want to use DDBs as much
// as we can.
if (mWinSurface) {
// Don't do DDBs for large images; see bug 359147
// Note that we bother with DDBs at all because they are much faster
// on some systems; on others there isn't much of a speed difference
// between DIBs and DDBs.
//
// Originally this just limited to 1024x1024; but that still
// had us hitting overall total memory usage limits (which was
// around 220MB on my intel shared memory system with 2GB RAM
// and 16-128mb in use by the video card, so I can't make
// heads or tails out of this limit).
//
// So instead, we clamp the max size to 64MB (this limit shuld
// be made dynamic based on.. something.. as soon a we figure
// out that something) and also limit each individual image to
// be less than 4MB to keep very large images out of DDBs.
// assume (almost -- we don't quadword-align) worst-case size
uint32_t ddbSize = mSize.width * mSize.height * 4;
if (ddbSize <= kMaxSingleDDBSize &&
ddbSize + gTotalDDBSize <= kMaxDDBSize)
{
nsRefPtr<gfxWindowsSurface> wsurf = mWinSurface->OptimizeToDDB(nullptr, gfxIntSize(mSize.width, mSize.height), mFormat);
if (wsurf) {
gTotalDDBs++;
gTotalDDBSize += ddbSize;
mIsDDBSurface = true;
mOptSurface = wsurf;
}
}
if (!mOptSurface && !mFormatChanged) {
if (!mFormatChanged) {
// just use the DIB if the format has not changed
mOptSurface = mWinSurface;
}

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

@ -178,9 +178,6 @@ private: // data
/** Have we called DiscardTracker::InformAllocation()? */
bool mInformedDiscardTracker;
#ifdef XP_WIN
bool mIsDDBSurface;
#endif
bool mDirty;
};