Skip to content

Commit

Permalink
Backed out 3 changesets (bug 1685183) for causing build bustages. CLO…
Browse files Browse the repository at this point in the history
…SED TREE

Backed out changeset bef089a9a5fa (bug 1685183)
Backed out changeset d9e2699b32c6 (bug 1685183)
Backed out changeset 083f895fddd9 (bug 1685183)
  • Loading branch information
Butkovits Atila committed Apr 8, 2021
1 parent fa0e157 commit 1557f3a
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 45 deletions.
35 changes: 23 additions & 12 deletions gfx/2d/MacIOSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
using namespace mozilla;

MacIOSurface::MacIOSurface(CFTypeRefPtr<IOSurfaceRef> aIOSurfaceRef,
bool aHasAlpha, gfx::YUVColorSpace aColorSpace)
double aContentsScaleFactor, bool aHasAlpha,
gfx::YUVColorSpace aColorSpace)
: mIOSurfaceRef(std::move(aIOSurfaceRef)),
mContentsScaleFactor(aContentsScaleFactor),
mHasAlpha(aHasAlpha),
mColorSpace(aColorSpace) {
IncrementUseCount();
Expand Down Expand Up @@ -57,9 +59,10 @@ void SetSizeProperties(const CFTypeRefPtr<CFMutableDictionaryRef>& aDict,
}

/* static */
already_AddRefed<MacIOSurface> MacIOSurface::CreateIOSurface(int aWidth,
int aHeight,
bool aHasAlpha) {
already_AddRefed<MacIOSurface> MacIOSurface::CreateIOSurface(
int aWidth, int aHeight, double aContentsScaleFactor, bool aHasAlpha) {
if (aContentsScaleFactor <= 0) return nullptr;

auto props = CFTypeRefPtr<CFMutableDictionaryRef>::WrapUnderCreateRule(
::CFDictionaryCreateMutable(kCFAllocatorDefault, 4,
&kCFTypeDictionaryKeyCallBacks,
Expand All @@ -70,6 +73,9 @@ already_AddRefed<MacIOSurface> MacIOSurface::CreateIOSurface(int aWidth,
MOZ_ASSERT((size_t)aHeight <= GetMaxHeight());

int32_t bytesPerElem = 4;
size_t intScaleFactor = ceil(aContentsScaleFactor);
aWidth *= intScaleFactor;
aHeight *= intScaleFactor;
SetSizeProperties(props, aWidth, aHeight, bytesPerElem);

AddDictionaryInt(props, kIOSurfacePixelFormat,
Expand All @@ -89,7 +95,7 @@ already_AddRefed<MacIOSurface> MacIOSurface::CreateIOSurface(int aWidth,
}

RefPtr<MacIOSurface> ioSurface =
new MacIOSurface(std::move(surfaceRef), aHasAlpha);
new MacIOSurface(std::move(surfaceRef), aContentsScaleFactor, aHasAlpha);

return ioSurface.forget();
}
Expand Down Expand Up @@ -191,7 +197,7 @@ already_AddRefed<MacIOSurface> MacIOSurface::CreateNV12Surface(
colorData.get());

RefPtr<MacIOSurface> ioSurface =
new MacIOSurface(std::move(surfaceRef), false, aColorSpace);
new MacIOSurface(std::move(surfaceRef), 1.0, false, aColorSpace);

return ioSurface.forget();
}
Expand Down Expand Up @@ -253,21 +259,24 @@ already_AddRefed<MacIOSurface> MacIOSurface::CreateYUV422Surface(
colorData.get());

RefPtr<MacIOSurface> ioSurface =
new MacIOSurface(std::move(surfaceRef), false, aColorSpace);
new MacIOSurface(std::move(surfaceRef), 1.0, false, aColorSpace);

return ioSurface.forget();
}

/* static */
already_AddRefed<MacIOSurface> MacIOSurface::LookupSurface(
IOSurfaceID aIOSurfaceID, bool aHasAlpha, gfx::YUVColorSpace aColorSpace) {
IOSurfaceID aIOSurfaceID, double aContentsScaleFactor, bool aHasAlpha,
gfx::YUVColorSpace aColorSpace) {
if (aContentsScaleFactor <= 0) return nullptr;

CFTypeRefPtr<IOSurfaceRef> surfaceRef =
CFTypeRefPtr<IOSurfaceRef>::WrapUnderCreateRule(
::IOSurfaceLookup(aIOSurfaceID));
if (!surfaceRef) return nullptr;

RefPtr<MacIOSurface> ioSurface =
new MacIOSurface(std::move(surfaceRef), aHasAlpha, aColorSpace);
RefPtr<MacIOSurface> ioSurface = new MacIOSurface(
std::move(surfaceRef), aContentsScaleFactor, aHasAlpha, aColorSpace);

return ioSurface.forget();
}
Expand All @@ -285,11 +294,13 @@ void* MacIOSurface::GetBaseAddressOfPlane(size_t aPlaneIndex) const {
}

size_t MacIOSurface::GetWidth(size_t plane) const {
return GetDevicePixelWidth(plane);
size_t intScaleFactor = ceil(mContentsScaleFactor);
return GetDevicePixelWidth(plane) / intScaleFactor;
}

size_t MacIOSurface::GetHeight(size_t plane) const {
return GetDevicePixelHeight(plane);
size_t intScaleFactor = ceil(mContentsScaleFactor);
return GetDevicePixelHeight(plane) / intScaleFactor;
}

size_t MacIOSurface::GetPlaneCount() const {
Expand Down
11 changes: 8 additions & 3 deletions gfx/2d/MacIOSurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,23 @@ class MacIOSurface final
// of the MacIOSurface instance.
// MacIOSurface holds a reference to the corresponding IOSurface.

static already_AddRefed<MacIOSurface> CreateIOSurface(int aWidth, int aHeight,
bool aHasAlpha = true);
static already_AddRefed<MacIOSurface> CreateIOSurface(
int aWidth, int aHeight, double aContentsScaleFactor = 1.0,
bool aHasAlpha = true);
static already_AddRefed<MacIOSurface> CreateNV12Surface(
const IntSize& aYSize, const IntSize& aCbCrSize,
YUVColorSpace aColorSpace, ColorRange aColorRange);
static already_AddRefed<MacIOSurface> CreateYUV422Surface(
const IntSize& aSize, YUVColorSpace aColorSpace, ColorRange aColorRange);
static void ReleaseIOSurface(MacIOSurface* aIOSurface);
static already_AddRefed<MacIOSurface> LookupSurface(
IOSurfaceID aSurfaceID, bool aHasAlpha = true,
IOSurfaceID aSurfaceID, double aContentsScaleFactor = 1.0,
bool aHasAlpha = true,
mozilla::gfx::YUVColorSpace aColorSpace =
mozilla::gfx::YUVColorSpace::Identity);

explicit MacIOSurface(CFTypeRefPtr<IOSurfaceRef> aIOSurfaceRef,
double aContentsScaleFactor = 1.0,
bool aHasAlpha = true,
mozilla::gfx::YUVColorSpace aColorSpace =
mozilla::gfx::YUVColorSpace::Identity);
Expand All @@ -89,6 +92,7 @@ class MacIOSurface final
IntSize GetSize(size_t plane = 0) const {
return IntSize(GetWidth(plane), GetHeight(plane));
}
double GetContentsScaleFactor() const { return mContentsScaleFactor; }
size_t GetDevicePixelWidth(size_t plane = 0) const;
size_t GetDevicePixelHeight(size_t plane = 0) const;
size_t GetBytesPerRow(size_t plane = 0) const;
Expand Down Expand Up @@ -138,6 +142,7 @@ class MacIOSurface final

private:
CFTypeRefPtr<IOSurfaceRef> mIOSurfaceRef;
const double mContentsScaleFactor;
const bool mHasAlpha;
YUVColorSpace mColorSpace = YUVColorSpace::Identity;
bool mIsLocked = false;
Expand Down
20 changes: 13 additions & 7 deletions gfx/2d/QuartzSupport.mm
Original file line number Diff line number Diff line change
Expand Up @@ -475,32 +475,38 @@ static void cgdata_release_callback(void* aCGData, const void* data, size_t size
}

void* ioData = surf->GetBaseAddress();
double scaleFactor = surf->GetContentsScaleFactor();
size_t intScaleFactor = ceil(surf->GetContentsScaleFactor());
CGDataProviderRef dataProvider =
::CGDataProviderCreateWithData(ioData, ioData, ioHeight * (bytesPerRow)*4,
::CGDataProviderCreateWithData(ioData, ioData, ioHeight * intScaleFactor * (bytesPerRow)*4,
nullptr); // No release callback
if (!dataProvider) {
surf->Unlock();
return NS_ERROR_FAILURE;
}

CGImageRef cgImage = ::CGImageCreate(ioWidth, ioHeight, 8, 32, bytesPerRow, aColorSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
dataProvider, nullptr, true, kCGRenderingIntentDefault);
CGImageRef cgImage =
::CGImageCreate(ioWidth * intScaleFactor, ioHeight * intScaleFactor, 8, 32, bytesPerRow,
aColorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
dataProvider, nullptr, true, kCGRenderingIntentDefault);
::CGDataProviderRelease(dataProvider);
if (!cgImage) {
surf->Unlock();
return NS_ERROR_FAILURE;
}
CGImageRef subImage =
::CGImageCreateWithImageInRect(cgImage, ::CGRectMake(aX, aY, aWidth, aHeight));
CGImageRef subImage = ::CGImageCreateWithImageInRect(
cgImage, ::CGRectMake(aX * scaleFactor, aY * scaleFactor, aWidth * scaleFactor,
aHeight * scaleFactor));
if (!subImage) {
::CGImageRelease(cgImage);
surf->Unlock();
return NS_ERROR_FAILURE;
}

::CGContextScaleCTM(aContext, 1.0f, -1.0f);
::CGContextDrawImage(aContext, CGRectMake(aX, -(CGFloat)aY - (CGFloat)aHeight, aWidth, aHeight),
::CGContextDrawImage(aContext,
CGRectMake(aX * scaleFactor, (-(CGFloat)aY - (CGFloat)aHeight) * scaleFactor,
aWidth * scaleFactor, aHeight * scaleFactor),
subImage);

::CGImageRelease(subImage);
Expand Down
7 changes: 4 additions & 3 deletions gfx/gl/GLBlitHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,8 @@ const DrawBlitProg* GLBlitHelper::CreateDrawBlitProg(
#ifdef XP_MACOSX
static RefPtr<MacIOSurface> LookupSurface(
const layers::SurfaceDescriptorMacIOSurface& sd) {
return MacIOSurface::LookupSurface(sd.surfaceId(), !sd.isOpaque(),
sd.yUVColorSpace());
return MacIOSurface::LookupSurface(sd.surfaceId(), sd.scaleFactor(),
!sd.isOpaque(), sd.yUVColorSpace());
}
#endif

Expand Down Expand Up @@ -1266,7 +1266,8 @@ bool GLBlitHelper::BlitImage(layers::GPUVideoImage* const srcImage,
TSurfaceDescriptorMacIOSurface: {
const auto& subdesc = subdescUnion.get_SurfaceDescriptorMacIOSurface();
RefPtr<MacIOSurface> surface = MacIOSurface::LookupSurface(
subdesc.surfaceId(), !subdesc.isOpaque(), subdesc.yUVColorSpace());
subdesc.surfaceId(), subdesc.scaleFactor(), !subdesc.isOpaque(),
subdesc.yUVColorSpace());
MOZ_ASSERT(surface);
if (!surface) {
return false;
Expand Down
5 changes: 3 additions & 2 deletions gfx/gl/SharedSurfaceIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ UniquePtr<SharedSurface_IOSurface> SharedSurface_IOSurface::Create(
const SharedSurfaceDesc& desc) {
const auto& size = desc.size;
const RefPtr<MacIOSurface> ioSurf =
MacIOSurface::CreateIOSurface(size.width, size.height, true);
MacIOSurface::CreateIOSurface(size.width, size.height, 1.0, true);
if (!ioSurf) {
NS_WARNING("Failed to create MacIOSurface.");
return nullptr;
Expand Down Expand Up @@ -92,7 +92,8 @@ Maybe<layers::SurfaceDescriptor>
SharedSurface_IOSurface::ToSurfaceDescriptor() {
const bool isOpaque = false; // RGBA
return Some(layers::SurfaceDescriptorMacIOSurface(
mIOSurf->GetIOSurfaceID(), isOpaque, mIOSurf->GetYUVColorSpace()));
mIOSurf->GetIOSurfaceID(), mIOSurf->GetContentsScaleFactor(), isOpaque,
mIOSurf->GetYUVColorSpace()));
}

} // namespace gl
Expand Down
2 changes: 1 addition & 1 deletion gfx/layers/MacIOSurfaceImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ already_AddRefed<MacIOSurface> MacIOSurfaceRecycleAllocator::Allocate(
// Only construct a MacIOSurface object when we find one that isn't
// in-use, since the constructor adds a usage ref.
if (!result && !::IOSurfaceIsInUse(surf.get())) {
result = new MacIOSurface(surf, false, aYUVColorSpace);
result = new MacIOSurface(surf, 1.0, false, aYUVColorSpace);
}

mSurfaces.AppendElement(surf);
Expand Down
6 changes: 3 additions & 3 deletions gfx/layers/basic/MacIOSurfaceTextureHostBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ gfx::SurfaceFormat MacIOSurfaceTextureSourceBasic::GetFormat() const {
MacIOSurfaceTextureHostBasic::MacIOSurfaceTextureHostBasic(
TextureFlags aFlags, const SurfaceDescriptorMacIOSurface& aDescriptor)
: TextureHost(aFlags) {
mSurface = MacIOSurface::LookupSurface(aDescriptor.surfaceId(),
!aDescriptor.isOpaque(),
aDescriptor.yUVColorSpace());
mSurface = MacIOSurface::LookupSurface(
aDescriptor.surfaceId(), aDescriptor.scaleFactor(),
!aDescriptor.isOpaque(), aDescriptor.yUVColorSpace());
}

gfx::SourceSurface* MacIOSurfaceTextureSourceBasic::GetSurface(
Expand Down
1 change: 1 addition & 0 deletions gfx/layers/ipc/LayersSurfaces.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace layers {

[Comparable] struct SurfaceDescriptorMacIOSurface {
uint32_t surfaceId;
double scaleFactor;
bool isOpaque;
YUVColorSpace yUVColorSpace;
};
Expand Down
14 changes: 7 additions & 7 deletions gfx/layers/opengl/MacIOSurfaceTextureClientOGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ MacIOSurfaceTextureData* MacIOSurfaceTextureData::Create(const IntSize& aSize,
}

RefPtr<MacIOSurface> surf = MacIOSurface::CreateIOSurface(
aSize.width, aSize.height, aFormat == SurfaceFormat::B8G8R8A8);
aSize.width, aSize.height, 1.0, aFormat == SurfaceFormat::B8G8R8A8);
if (!surf) {
return nullptr;
}
Expand All @@ -50,17 +50,17 @@ MacIOSurfaceTextureData* MacIOSurfaceTextureData::Create(const IntSize& aSize,
}

bool MacIOSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor) {
aOutDescriptor = SurfaceDescriptorMacIOSurface(mSurface->GetIOSurfaceID(),
!mSurface->HasAlpha(),
mSurface->GetYUVColorSpace());
aOutDescriptor = SurfaceDescriptorMacIOSurface(
mSurface->GetIOSurfaceID(), mSurface->GetContentsScaleFactor(),
!mSurface->HasAlpha(), mSurface->GetYUVColorSpace());
return true;
}

void MacIOSurfaceTextureData::GetSubDescriptor(
RemoteDecoderVideoSubDescriptor* const aOutDesc) {
*aOutDesc = SurfaceDescriptorMacIOSurface(mSurface->GetIOSurfaceID(),
!mSurface->HasAlpha(),
mSurface->GetYUVColorSpace());
*aOutDesc = SurfaceDescriptorMacIOSurface(
mSurface->GetIOSurfaceID(), mSurface->GetContentsScaleFactor(),
!mSurface->HasAlpha(), mSurface->GetYUVColorSpace());
}

void MacIOSurfaceTextureData::FillInfo(TextureData::Info& aInfo) const {
Expand Down
6 changes: 3 additions & 3 deletions gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ MacIOSurfaceTextureHostOGL::MacIOSurfaceTextureHostOGL(
TextureFlags aFlags, const SurfaceDescriptorMacIOSurface& aDescriptor)
: TextureHost(aFlags) {
MOZ_COUNT_CTOR(MacIOSurfaceTextureHostOGL);
mSurface = MacIOSurface::LookupSurface(aDescriptor.surfaceId(),
!aDescriptor.isOpaque(),
aDescriptor.yUVColorSpace());
mSurface = MacIOSurface::LookupSurface(
aDescriptor.surfaceId(), aDescriptor.scaleFactor(),
!aDescriptor.isOpaque(), aDescriptor.yUVColorSpace());
if (!mSurface) {
gfxCriticalNote << "Failed to look up MacIOSurface";
}
Expand Down
5 changes: 3 additions & 2 deletions gfx/thebes/gfxPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
* aTarget should not keep a reference to the returned surface because that
* will cause a cycle.
*
* This function is static so that it can be accessed from outside the main
* process.
* This function is static so that it can be accessed from
* PluginInstanceChild (where we can't call gfxPlatform::GetPlatform()
* because the prefs service can only be accessed from the main process).
*
* aIsPlugin is used to tell the backend that they can optimize this surface
* specifically because it's used for a plugin. This is mostly for Skia.
Expand Down
5 changes: 3 additions & 2 deletions gfx/vr/VRManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1396,8 +1396,9 @@ bool VRManager::SubmitFrame(const layers::SurfaceDescriptor& aTexture,
const auto& desc = aTexture.get_SurfaceDescriptorMacIOSurface();
layer.textureType = VRLayerTextureType::LayerTextureType_MacIOSurface;
layer.textureHandle = desc.surfaceId();
RefPtr<MacIOSurface> surf = MacIOSurface::LookupSurface(
desc.surfaceId(), !desc.isOpaque(), desc.yUVColorSpace());
RefPtr<MacIOSurface> surf =
MacIOSurface::LookupSurface(desc.surfaceId(), desc.scaleFactor(),
!desc.isOpaque(), desc.yUVColorSpace());
if (surf) {
layer.textureSize.width = surf->GetDevicePixelWidth();
layer.textureSize.height = surf->GetDevicePixelHeight();
Expand Down
1 change: 1 addition & 0 deletions ipc/glue/WindowsMessageLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ ProcessOrDeferMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {

} // namespace

// We need the pointer value of this in PluginInstanceChild.
LRESULT CALLBACK NeuteredWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam) {
WNDPROC oldWndProc = (WNDPROC)GetProp(hwnd, kOldWndProcProp);
Expand Down
3 changes: 3 additions & 0 deletions widget/TextEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ namespace dom {
class PBrowserParent;
class PBrowserChild;
} // namespace dom
namespace plugins {
class PPluginInstanceChild;
} // namespace plugins

enum class AccessKeyType {
// Handle access key for chrome.
Expand Down

0 comments on commit 1557f3a

Please sign in to comment.