mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
89d38b5d7a
- Bug 1173364 - support ARIA table and cell roles, r=marcoz (c6f9fc891e) - Bug 1205318 - make aria-owns loop alg more sophisticated, r=yzen (d287b1e41c) - Bug 1205476 - crash in mozilla::a11y::DocAccessible::ProcessInvalidationList(), r=smaug (bf920abdd3) - Bug 1205476 - crash in mozilla::a11y::DocAccessible::ProcessInvalidationList(), part3, r=davidb (675c3a0ee2) - Bug 1205476 - crash in mozilla::a11y::DocAccessible::ProcessInvalidationList, part2, r=davidb (a7cd835169) - Bug 1186786 - Replace nsBaseHashtable::EnumerateRead() calls in accessible/ with iterators. r=tbsaunde. (172fcbe18f) - Bug 1219299 - rework aria-owns implementation, r=yzen (c297a84b41) - Bug 1219744 - no child_of/parent_of relations for aria-owns, r=yzen (38ea8be268) - Bug 1205341 - get rid of aria-owns provided relations, part1: remove ARIA combobox special support (bug 819273 backout), r=yzen (0ca03a27bd) - Bug 1219743 - remove special ARIA owns support for ARIA menus, r=yzen (64468fdfd1) - Bug 1200595 - Introduce TextureData and implement it for X11. r=mattwoodrow, Bas, sotaro (2e6bc3f02c) - Bug 1200595 - Buffer TextureData implementation. r=mattwoodrow (1cb3ffd937) - Bug 1227415 - Fix copy buffer size r=jolin (344130daec) - Bug 1200595 - Gralloc TextureData implementation. r=sotaro (a0726233ca) - Bug 1205725 - Add basic SidebandStream handling to HwcComposer2D r=mwu,nical (42bea59a5f) - namespace (ab69730d53) - Bug 1194775 - Paper over a crash in ContentClient. r=Bas (998051cee4) - minor (c24c0b069d) - Bug 1197315 - remove PR_snprintf calls in gfx/; r=froydnj (f153fed9c8) - Bug 1157664 - Initialize mozilla::layers::FPSCOUNTER::mIteratorIndex. r=nical (cf5d2203ee) - Bug 1157663 - Init mMap in the constructor to avoid half initialized structures. r=nical (d972306493) - Bug 1167370: Check for Map() call failing. r=bas (707eda52ff) - Bug 1221276 - Don't crash if we don't have a surface. r=nical (c53141ea3d) - Bug 1219230 - Use the valid region for determining buffer size instead of the visible region. r=mstange (f2d4783eef) - Pass the correct moz2d backend in CanvasClients. (bug 1212499, r=mattwoodrow) (c16688afbb) - Bug 1179987 - Simplify unlocking of tiled texture hosts. r=nical (781200f702) - Bug 1170189 - Fix tiling crash on Linux. r=jrmuizel (879bbfb506) - Bug 1170189 - fix a comment in the tiling code. r=BenWa (62b47f1bbd) - Bug 1179987 - Make tiled TextureSource recycling based on pointer comparisons rather than trying to do it geometrically. r=nical (7bde534929) - Bug 1189710 - Use correct offset for LayerRenderState in TiledContentHost. r=jrmuizel (cb93c2f98a) - Bug 1215050 - Make layerscope support TiledPaintedLayer when using HWC. r=mattwoodrow, r=cjku (6bffac30f8) - Bug 1186208 - Fix crash when tiling is enabled on linux. r=mattwoodrow (b2f2c85734) - Bug 1197713 - Add missing gfxPrefs.h include to TiledContentHost.cpp. r=nical (22bce4e071) - Bug 1143575. Async image invalidation does not necessarily need to invalidate the layer; LayerTreeInvalidation will do that for us. r=mattwoodrow (a6144b7127) - Bug 1219529 - Don't attempt to deallocate shmems after the ipdl protocol is shut down. r=sotaro (3bb89ef36e) - Bug 1143575. Add assertion for diagnostic purposes. r=nical (e4944dd72f) - Bug 1202175 - Guard GLX-specific call in SurfaceDescriptorX11. r=jgilbert (167a4aa49b) - Bug 1132528 - Handle non existent key r=nical (6c12df1446) - Bug 1137151: Marked destructor of |GrallocReporter| as protected, r=jmuizelaar (57605c4472) - Bug 1145389 - Add gralloc allocation requet size check r=nical (47c6065148) - Bug 1181197 - Fix null dereference in SharedPlanarYCbCrImage destructor. r=jgilbert (3f8c390a6f) - Bug 1195110 - Check if GLContext is destroyed before freeing resources in CompositingRenderTargetOGL. r=jrmuizel (8eac603d84) - bug 1178956 - Specify precision in OGLShaderProgram.cpp to fix compositor on iOS. r=kip (daa6d9db20) - Bug 1186725 - InitTextures should check if LockRect() returns an error, r=mattwoodrow (bc87f908a7) - Bug 1170143 - Add some error checks around the creation of dxgi ycbcrvideo frames. r=Bas (c96e4d9e79) - Bug 1170143 - Build fix. r=me (a9d0064bc3) - Bug 1202700 - Use d3d9 device to upload YCbCr surfaces on the client side if possible. r=Bas (3ccd0c68f5) - Bug 1199361 - Add texture memory reporters for YCbCr TextureClients. r=jrmuizel (723e9d4b10) - bug 1183967 - fixup correct case of mfidl.h (e9abd04709) - Bug 1133007 - followup - make CreateServerSocketRunnable's constructor explicit; r=bustage (5de0ec7900) - Bug 1195653 - Part1.1: Dump SecondaryEffects (EffectTypes::MASK) on Layerscope viewer. r=dglastonbury (v2, carry r+) (a6736ad381) - Bug 1195653 - Part1.2: Use sSentTextureIds instead of sTextureIdList and move HasTextureIdBeenSent into SendTextureSource. r=dglastonbury (v3, carry r+) (7e0b14bca6) - Bug 1195653 - Part1.3: Add isMask attribute field to LayerScopePacket.proto. r=dglastonbury (v2, carry r+) (510e50e09a) - Bug 1195653 - Part1.4: Generated file diffs from patched LayerScopePacket.proto. r=dglastonbury (v1, carry r+) (f1824afcb3) - Bug 1195653 - Part1.5: Send isMask info to LayerScope viewer by TexturePacket. r=dglastonbury (v3) (1722e5e6fe) - Bug 1205521 - Part1: (v3) Add texture/mask attribute fields in LayerScopePacket.proto. r=dglastonbury (0cca15f8f5) - Bug 1205521 - Part2: (v3) Generated file diffs from patched LayerScopePacket.proto. r=dglastonbury (6253724bcf) - Bug 1205521 - Part3: (v3) Dump texture/mask attributes on layerscope viewer. r=dglastonbury (31d346bad1) - Bug 1205521 - Part4: (v2) Align LayerScopePacket to fit changes in Bug 1211324. r=dglastonbury (712da0fe9c) - Bug 1177023 - Log the IsRootContent flag when dumping framemetrics. r=botond (9bea51f318) - Bug 1153724 - Only assert if the size was reasonable to start. r=mchang (c3d61bbee1) - namespace (edcce0a0b3) - Bug 1195857: Make nsPresContext::HasAuthorSpecifiedRules()'s arg 'const', to remove need for const_cast in callers. r=jwatt (274fe66dca) - Bug 1182414, part 1 - Fix printing crash with range input controls. r=dholbert (352a408a83) - Bug 1182414, part 2 - Add printing crash test. r=dholbert (0fc9bd4529) - Bug 1099103 - Prevent numbers input using a grouping separator from being mis-processed as if the separator was a decimal separator. r=dholbert (90276c2f6b) - Bug 1157142 - Support logical (inline/block) in addition to physical orientation for the <input type=range> element; make inline the default behavior so that range sliders respect writing mode. r=jwatt (2ec37cbba8)
292 lines
8.1 KiB
C++
292 lines
8.1 KiB
C++
/* -*- 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/. */
|
|
|
|
#include "GrallocTextureHostBasic.h"
|
|
#include "GrallocImages.h" // for GetDataSourceSurfaceFrom()
|
|
#include "mozilla/layers/SharedBufferManagerParent.h"
|
|
|
|
#if ANDROID_VERSION >= 17
|
|
#include <ui/Fence.h>
|
|
#endif
|
|
|
|
namespace mozilla {
|
|
namespace layers {
|
|
|
|
static gfx::SurfaceFormat
|
|
HalFormatToSurfaceFormat(int aHalFormat, TextureFlags aFlags)
|
|
{
|
|
bool swapRB = bool(aFlags & TextureFlags::RB_SWAPPED);
|
|
switch (aHalFormat) {
|
|
case android::PIXEL_FORMAT_BGRA_8888:
|
|
return swapRB ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8A8;
|
|
case android::PIXEL_FORMAT_RGBA_8888:
|
|
return swapRB ? gfx::SurfaceFormat::B8G8R8A8 : gfx::SurfaceFormat::R8G8B8A8;
|
|
case android::PIXEL_FORMAT_RGBX_8888:
|
|
return swapRB ? gfx::SurfaceFormat::B8G8R8X8 : gfx::SurfaceFormat::R8G8B8X8;
|
|
case android::PIXEL_FORMAT_RGB_565:
|
|
return gfx::SurfaceFormat::R5G6B5_UINT16;
|
|
case HAL_PIXEL_FORMAT_YCbCr_422_SP:
|
|
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
|
|
case HAL_PIXEL_FORMAT_YCbCr_422_I:
|
|
case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
|
|
case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
|
|
case HAL_PIXEL_FORMAT_YV12:
|
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
|
case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
|
|
#endif
|
|
// Needs convert to RGB565
|
|
return gfx::SurfaceFormat::R5G6B5_UINT16;
|
|
default:
|
|
if (aHalFormat >= 0x100 && aHalFormat <= 0x1FF) {
|
|
// Reserved range for HAL specific formats.
|
|
// Needs convert to RGB565
|
|
return gfx::SurfaceFormat::R5G6B5_UINT16;
|
|
} else {
|
|
MOZ_CRASH("Unhandled HAL pixel format");
|
|
return gfx::SurfaceFormat::UNKNOWN; // not reached
|
|
}
|
|
}
|
|
}
|
|
|
|
static bool
|
|
NeedsConvertFromYUVtoRGB565(int aHalFormat)
|
|
{
|
|
switch (aHalFormat) {
|
|
case android::PIXEL_FORMAT_BGRA_8888:
|
|
case android::PIXEL_FORMAT_RGBA_8888:
|
|
case android::PIXEL_FORMAT_RGBX_8888:
|
|
case android::PIXEL_FORMAT_RGB_565:
|
|
return false;
|
|
case HAL_PIXEL_FORMAT_YCbCr_422_SP:
|
|
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
|
|
case HAL_PIXEL_FORMAT_YCbCr_422_I:
|
|
case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
|
|
case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
|
|
case HAL_PIXEL_FORMAT_YV12:
|
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
|
case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
|
|
#endif
|
|
return true;
|
|
default:
|
|
if (aHalFormat >= 0x100 && aHalFormat <= 0x1FF) {
|
|
// Reserved range for HAL specific formats.
|
|
return true;
|
|
} else {
|
|
MOZ_CRASH("Unhandled HAL pixel format");
|
|
return false; // not reached
|
|
}
|
|
}
|
|
}
|
|
|
|
GrallocTextureHostBasic::GrallocTextureHostBasic(
|
|
TextureFlags aFlags,
|
|
const NewSurfaceDescriptorGralloc& aDescriptor)
|
|
: TextureHost(aFlags)
|
|
, mGrallocHandle(aDescriptor)
|
|
, mSize(0, 0)
|
|
, mCropSize(0, 0)
|
|
, mFormat(gfx::SurfaceFormat::UNKNOWN)
|
|
, mIsOpaque(aDescriptor.isOpaque())
|
|
{
|
|
android::GraphicBuffer* grallocBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
|
|
MOZ_ASSERT(grallocBuffer);
|
|
|
|
if (grallocBuffer) {
|
|
mFormat =
|
|
HalFormatToSurfaceFormat(grallocBuffer->getPixelFormat(),
|
|
aFlags & TextureFlags::RB_SWAPPED);
|
|
mSize = gfx::IntSize(grallocBuffer->getWidth(), grallocBuffer->getHeight());
|
|
mCropSize = mSize;
|
|
} else {
|
|
printf_stderr("gralloc buffer is nullptr\n");
|
|
}
|
|
}
|
|
|
|
bool
|
|
GrallocTextureHostBasic::Lock()
|
|
{
|
|
if (!mCompositor || !IsValid()) {
|
|
return false;
|
|
}
|
|
|
|
if (mTextureSource) {
|
|
return true;
|
|
}
|
|
|
|
android::sp<android::GraphicBuffer> graphicBuffer =
|
|
GetGraphicBufferFromDesc(mGrallocHandle);
|
|
MOZ_ASSERT(graphicBuffer.get());
|
|
|
|
RefPtr<gfx::DataSourceSurface> surf;
|
|
if (NeedsConvertFromYUVtoRGB565(graphicBuffer->getPixelFormat())) {
|
|
PlanarYCbCrData ycbcrData;
|
|
surf = GetDataSourceSurfaceFrom(graphicBuffer,
|
|
mCropSize,
|
|
ycbcrData);
|
|
} else {
|
|
uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN;
|
|
int32_t rv = graphicBuffer->lock(usage,
|
|
reinterpret_cast<void**>(&mMappedBuffer));
|
|
if (rv) {
|
|
mMappedBuffer = nullptr;
|
|
NS_WARNING("Couldn't lock graphic buffer");
|
|
return false;
|
|
}
|
|
surf = gfx::Factory::CreateWrappingDataSourceSurface(
|
|
mMappedBuffer,
|
|
graphicBuffer->getStride() * gfx::BytesPerPixel(mFormat),
|
|
mCropSize,
|
|
mFormat);
|
|
}
|
|
mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
|
|
mTextureSource->Update(surf, nullptr);
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
GrallocTextureHostBasic::IsValid() const
|
|
{
|
|
android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
|
|
return graphicBuffer != nullptr;
|
|
}
|
|
|
|
bool
|
|
GrallocTextureHostBasic::BindTextureSource(CompositableTextureSourceRef& aTexture)
|
|
{
|
|
aTexture = mTextureSource;
|
|
return !!aTexture;
|
|
}
|
|
|
|
void
|
|
GrallocTextureHostBasic::UnbindTextureSource()
|
|
{
|
|
ClearTextureSource();
|
|
}
|
|
|
|
void
|
|
GrallocTextureHostBasic::ClearTextureSource()
|
|
{
|
|
mTextureSource = nullptr;
|
|
if (mMappedBuffer) {
|
|
android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
|
|
MOZ_ASSERT(graphicBuffer);
|
|
mMappedBuffer = nullptr;
|
|
graphicBuffer->unlock();
|
|
}
|
|
}
|
|
|
|
void
|
|
GrallocTextureHostBasic::SetCompositor(Compositor* aCompositor)
|
|
{
|
|
BasicCompositor* compositor = static_cast<BasicCompositor*>(aCompositor);
|
|
mCompositor = compositor;
|
|
if (mTextureSource) {
|
|
mTextureSource->SetCompositor(compositor);
|
|
}
|
|
}
|
|
|
|
gfx::SurfaceFormat
|
|
GrallocTextureHostBasic::GetFormat() const {
|
|
return mFormat;
|
|
}
|
|
|
|
void
|
|
GrallocTextureHostBasic::WaitAcquireFenceHandleSyncComplete()
|
|
{
|
|
if (!mAcquireFenceHandle.IsValid()) {
|
|
return;
|
|
}
|
|
|
|
#if ANDROID_VERSION >= 17
|
|
RefPtr<FenceHandle::FdObj> fdObj = mAcquireFenceHandle.GetAndResetFdObj();
|
|
android::sp<android::Fence> fence(
|
|
new android::Fence(fdObj->GetAndResetFd()));
|
|
|
|
// Wait fece complete with timeout.
|
|
// If a source of the fence becomes invalid because of error,
|
|
// fene complete is not signaled. See Bug 1061435.
|
|
int rv = fence->wait(400 /*400 msec*/);
|
|
if (rv != android::OK) {
|
|
NS_ERROR("failed to wait fence complete");
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void
|
|
GrallocTextureHostBasic::SetCropRect(nsIntRect aCropRect)
|
|
{
|
|
MOZ_ASSERT(aCropRect.TopLeft() == gfx::IntPoint(0, 0));
|
|
MOZ_ASSERT(!aCropRect.IsEmpty());
|
|
MOZ_ASSERT(aCropRect.width <= mSize.width);
|
|
MOZ_ASSERT(aCropRect.height <= mSize.height);
|
|
|
|
gfx::IntSize cropSize(aCropRect.width, aCropRect.height);
|
|
if (mCropSize == cropSize) {
|
|
return;
|
|
}
|
|
|
|
mCropSize = cropSize;
|
|
ClearTextureSource();
|
|
}
|
|
|
|
void
|
|
GrallocTextureHostBasic::DeallocateSharedData()
|
|
{
|
|
ClearTextureSource();
|
|
|
|
if (mGrallocHandle.buffer().type() != MaybeMagicGrallocBufferHandle::Tnull_t) {
|
|
MaybeMagicGrallocBufferHandle handle = mGrallocHandle.buffer();
|
|
base::ProcessId owner;
|
|
if (handle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef) {
|
|
owner = handle.get_GrallocBufferRef().mOwner;
|
|
}
|
|
else {
|
|
owner = handle.get_MagicGrallocBufferHandle().mRef.mOwner;
|
|
}
|
|
|
|
SharedBufferManagerParent::DropGrallocBuffer(owner, mGrallocHandle);
|
|
}
|
|
}
|
|
|
|
void
|
|
GrallocTextureHostBasic::ForgetSharedData()
|
|
{
|
|
ClearTextureSource();
|
|
}
|
|
|
|
void
|
|
GrallocTextureHostBasic::DeallocateDeviceData()
|
|
{
|
|
ClearTextureSource();
|
|
}
|
|
|
|
LayerRenderState
|
|
GrallocTextureHostBasic::GetRenderState()
|
|
{
|
|
android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
|
|
|
|
if (graphicBuffer) {
|
|
LayerRenderStateFlags flags = LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT;
|
|
if (mIsOpaque) {
|
|
flags |= LayerRenderStateFlags::OPAQUE;
|
|
}
|
|
if (mFlags & TextureFlags::ORIGIN_BOTTOM_LEFT) {
|
|
flags |= LayerRenderStateFlags::ORIGIN_BOTTOM_LEFT;
|
|
}
|
|
if (mFlags & TextureFlags::RB_SWAPPED) {
|
|
flags |= LayerRenderStateFlags::FORMAT_RB_SWAP;
|
|
}
|
|
return LayerRenderState(graphicBuffer,
|
|
mCropSize,
|
|
flags,
|
|
this);
|
|
}
|
|
|
|
return LayerRenderState();
|
|
}
|
|
|
|
} // namespace layers
|
|
} // namespace mozilla
|