Bug 1025497 - Stop using gfxImageSurface in Cocoa widget code. r=mstange

This commit is contained in:
Jonathan Watt 2014-06-17 10:37:45 +01:00
parent 2cbb0e1746
commit 90d9a5c55c
6 changed files with 20 additions and 13 deletions

View File

@ -6,6 +6,7 @@
#include "GLTextureImage.h"
#include "GLContext.h"
#include "gfxContext.h"
#include "gfxImageSurface.h"
#include "gfxPlatform.h"
#include "gfxUtils.h"
#include "gfx2DGlue.h"

View File

@ -14,6 +14,7 @@
#include "LayerSorter.h" // for SortLayersBy3DZOrder
#include "LayersLogging.h" // for AppendToString
#include "ReadbackLayer.h" // for ReadbackLayer
#include "gfxImageSurface.h"
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxUtils.h" // for gfxUtils, etc
#include "gfx2DGlue.h"

View File

@ -24,7 +24,6 @@
#include "nsThreadUtils.h"
#include "nsIThreadManager.h"
#include "mozilla/dom/mobilemessage/PSms.h"
#include "gfxImageSurface.h"
#include "gfxPlatform.h"
#include "gfxContext.h"
#include "mozilla/gfx/2D.h"

View File

@ -38,7 +38,6 @@ using mozilla::unused;
#include "nsWidgetsCID.h"
#include "nsGfxCIID.h"
#include "gfxImageSurface.h"
#include "gfxContext.h"
#include "Layers.h"

View File

@ -3,7 +3,6 @@
* 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/. */
#include "gfxImageSurface.h"
#include "gfxPlatform.h"
#include "gfxUtils.h"
#include "nsCocoaUtils.h"

View File

@ -166,24 +166,31 @@ nsDragService::ConstructDragImage(nsIDOMNode* aDOMNode,
uint32_t width = aDragRect->width;
uint32_t height = aDragRect->height;
nsRefPtr<gfxImageSurface> imgSurface = new gfxImageSurface(
gfxIntSize(width, height), gfxImageFormat::ARGB32);
if (!imgSurface)
RefPtr<DataSourceSurface> dataSurface =
Factory::CreateDataSourceSurface(IntSize(width, height),
SurfaceFormat::B8G8R8A8);
DataSourceSurface::MappedSurface map;
if (!dataSurface->Map(DataSourceSurface::MapType::READ_WRITE, &map)) {
return nil;
}
RefPtr<DrawTarget> dt =
gfxPlatform::GetPlatform()->
CreateDrawTargetForSurface(imgSurface, IntSize(width, height));
if (!dt)
Factory::CreateDrawTargetForData(BackendType::CAIRO,
map.mData,
dataSurface->GetSize(),
map.mStride,
dataSurface->GetFormat());
if (!dt) {
dataSurface->Unmap();
return nil;
}
dt->FillRect(gfx::Rect(0, 0, width, height),
SurfacePattern(surface, ExtendMode::CLAMP),
DrawOptions(1.0f, CompositionOp::OP_SOURCE));
uint32_t* imageData = (uint32_t*)imgSurface->Data();
int32_t stride = imgSurface->Stride();
NSBitmapImageRep* imageRep =
[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:width
@ -198,7 +205,7 @@ nsDragService::ConstructDragImage(nsIDOMNode* aDOMNode,
uint8_t* dest = [imageRep bitmapData];
for (uint32_t i = 0; i < height; ++i) {
uint8_t* src = (uint8_t *)imageData + i * stride;
uint8_t* src = map.mData + i * map.mStride;
for (uint32_t j = 0; j < width; ++j) {
// Reduce transparency overall by multipying by a factor. Remember, Alpha
// is premultipled here. Also, Quartz likes RGBA, so do that translation as well.
@ -217,6 +224,7 @@ nsDragService::ConstructDragImage(nsIDOMNode* aDOMNode,
dest += 4;
}
}
dataSurface->Unmap();
NSImage* image =
[[NSImage alloc] initWithSize:NSMakeSize(width / scaleFactor,