mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 887791 - Add MacIOSurfaceImage. r=roc
This commit is contained in:
parent
9cd72931be
commit
770c0c7a31
@ -22,6 +22,7 @@
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include "mozilla/gfx/QuartzSupport.h"
|
||||
#include "MacIOSurfaceImage.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
@ -74,6 +75,12 @@ ImageFactory::CreateImage(const ImageFormat *aFormats,
|
||||
img = new SharedTextureImage();
|
||||
return img.forget();
|
||||
}
|
||||
#ifdef XP_MACOSX
|
||||
if (FormatInList(aFormats, aNumFormats, MAC_IOSURFACE)) {
|
||||
img = new MacIOSurfaceImage();
|
||||
return img.forget();
|
||||
}
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
if (FormatInList(aFormats, aNumFormats, D3D9_RGB32_TEXTURE)) {
|
||||
img = new D3D9SurfaceImage();
|
||||
|
@ -45,6 +45,11 @@ enum ImageFormat {
|
||||
*/
|
||||
CAIRO_SURFACE,
|
||||
|
||||
/**
|
||||
* A MacIOSurface object.
|
||||
*/
|
||||
MAC_IOSURFACE,
|
||||
|
||||
/**
|
||||
* An bitmap image that can be shared with a remote process.
|
||||
*/
|
||||
|
55
gfx/layers/MacIOSurfaceImage.h
Normal file
55
gfx/layers/MacIOSurfaceImage.h
Normal file
@ -0,0 +1,55 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* 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/. */
|
||||
|
||||
#ifndef GFX_MACIOSURFACEIMAGE_H
|
||||
#define GFX_MACIOSURFACEIMAGE_H
|
||||
|
||||
#include "mozilla/gfx/MacIOSurface.h"
|
||||
#include "gfxImageSurface.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace layers {
|
||||
|
||||
class MacIOSurfaceImage : public Image {
|
||||
public:
|
||||
void SetSurface(MacIOSurface* aSurface) { mSurface = aSurface; }
|
||||
MacIOSurface* GetSurface() { return mSurface; }
|
||||
|
||||
gfxIntSize GetSize() {
|
||||
return gfxIntSize(mSurface->GetDevicePixelWidth(), mSurface->GetDevicePixelHeight());
|
||||
}
|
||||
|
||||
virtual already_AddRefed<gfxASurface> GetAsSurface() {
|
||||
mSurface->Lock();
|
||||
size_t bytesPerRow = mSurface->GetBytesPerRow();
|
||||
size_t ioWidth = mSurface->GetDevicePixelWidth();
|
||||
size_t ioHeight = mSurface->GetDevicePixelHeight();
|
||||
|
||||
unsigned char* ioData = (unsigned char*)mSurface->GetBaseAddress();
|
||||
|
||||
nsRefPtr<gfxImageSurface> imgSurface =
|
||||
new gfxImageSurface(gfxIntSize(ioWidth, ioHeight), gfxImageFormatARGB32);
|
||||
|
||||
for (size_t i = 0; i < ioHeight; i++) {
|
||||
memcpy(imgSurface->Data() + i * imgSurface->Stride(),
|
||||
ioData + i * bytesPerRow, ioWidth * 4);
|
||||
}
|
||||
|
||||
mSurface->Unlock();
|
||||
|
||||
return imgSurface.forget();
|
||||
}
|
||||
|
||||
MacIOSurfaceImage() : Image(nullptr, MAC_IOSURFACE) {}
|
||||
|
||||
private:
|
||||
RefPtr<MacIOSurface> mSurface;
|
||||
};
|
||||
|
||||
} // layers
|
||||
} // mozilla
|
||||
|
||||
#endif // GFX_SHAREDTEXTUREIMAGE_H
|
@ -161,6 +161,9 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
EXPORTS.mozilla.layers += [
|
||||
'opengl/GLManager.h',
|
||||
]
|
||||
EXPORTS += [
|
||||
'MacIOSurfaceImage.h',
|
||||
]
|
||||
SOURCES += [
|
||||
'ipc/ShadowLayerUtilsMac.cpp',
|
||||
'opengl/GLManager.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user