Bug 993323 - Make nsWindowGfx::CreateIcon() use the new gfxUtils helper for format conversion. r=Bas

This commit is contained in:
Jonathan Watt 2014-04-08 16:12:28 +01:00
Родитель 968f30feea
Коммит aca76ba851
1 изменённых файлов: 5 добавлений и 14 удалений

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

@ -27,6 +27,7 @@ using mozilla::plugins::PluginInstanceParent;
#include "nsWindowGfx.h"
#include <windows.h>
#include "gfxImageSurface.h"
#include "gfxUtils.h"
#include "gfxWindowsSurface.h"
#include "gfxWindowsPlatform.h"
#include "mozilla/gfx/2D.h"
@ -673,21 +674,11 @@ nsresult nsWindowGfx::CreateIcon(imgIContainer *aContainer,
DrawOptions(1.0f, CompositionOp::OP_SOURCE));
} else if (surface->GetFormat() != SurfaceFormat::B8G8R8A8) {
// Convert format to SurfaceFormat::B8G8R8A8
dataSurface = Factory::CreateDataSourceSurface(iconSize,
SurfaceFormat::B8G8R8A8);
dataSurface = gfxUtils::
CopySurfaceToDataSourceSurfaceWithFormat(surface,
SurfaceFormat::B8G8R8A8);
NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);
mappedOK = dataSurface->Map(DataSourceSurface::MapType::READ_WRITE, &map);
NS_ENSURE_TRUE(mappedOK, NS_ERROR_FAILURE);
RefPtr<DrawTarget> dt =
Factory::CreateDrawTargetForData(BackendType::CAIRO,
map.mData,
dataSurface->GetSize(),
map.mStride,
SurfaceFormat::B8G8R8A8);
dt->CopySurface(surface, IntRect(IntPoint(0, 0), iconSize),
IntPoint(0, 0));
mappedOK = dataSurface->Map(DataSourceSurface::MapType::READ, &map);
} else {
dataSurface = surface->GetDataSurface();
NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);