mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1025497 - Stop using gfxImageSurface in Cocoa widget code. r=mstange
This commit is contained in:
parent
6344ccf0e8
commit
197045f650
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -38,7 +38,6 @@ using mozilla::unused;
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsGfxCIID.h"
|
||||
|
||||
#include "gfxImageSurface.h"
|
||||
#include "gfxContext.h"
|
||||
|
||||
#include "Layers.h"
|
||||
|
@ -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"
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user