Exemple #1
0
JSONVariant
MakeTestVariant(HandleT* handle)
{
    // In JS syntax:
    //
    //   return [
    //     undefined, null, true, 1.25, "test string",
    //     handle,
    //     [ 1, 2, 3 ],
    //     { "undefined" : undefined,
    //       "null"      : null,
    //       "true"      : true,
    //       "1.25"      : 1.25,
    //       "string"    : "string"
    //       "handle"    : handle,
    //       "array"     : [ 1, 2, 3 ]
    //     }
    //   ]
    //
    InfallibleTArray<JSONVariant> outer;

    outer.AppendElement(void_t());
    outer.AppendElement(null_t());
    outer.AppendElement(true);
    outer.AppendElement(1.25);
    outer.AppendElement(String("test string"));

    outer.AppendElement(handle);

    InfallibleTArray<JSONVariant> tmp;
    Array123(tmp);
    outer.AppendElement(tmp);

    InfallibleTArray<KeyValue> obj;
    obj.AppendElement(KeyValue(String("undefined"), void_t()));
    obj.AppendElement(KeyValue(String("null"), null_t()));
    obj.AppendElement(KeyValue(String("true"), true));
    obj.AppendElement(KeyValue(String("1.25"), 1.25));
    obj.AppendElement(KeyValue(String("string"), String("value")));
    obj.AppendElement(KeyValue(String("handle"), handle));
    InfallibleTArray<JSONVariant> tmp2;
    Array123(tmp2);
    obj.AppendElement(KeyValue(String("array"), tmp2));

    outer.AppendElement(obj);

    test_assert(outer == outer, "operator== is broken");

    return JSONVariant(outer);
}
/*static*/ PGrallocBufferParent*
GrallocBufferActor::Create(const gfxIntSize& aSize,
                           const uint32_t& aFormat,
                           const uint32_t& aUsage,
                           MaybeMagicGrallocBufferHandle* aOutHandle)
{
  PROFILER_LABEL("GrallocBufferActor", "Create");
  GrallocBufferActor* actor = new GrallocBufferActor();
  *aOutHandle = null_t();
  uint32_t format = aFormat;
  uint32_t usage = aUsage;

  if (format == 0 || usage == 0) {
    printf_stderr("GrallocBufferActor::Create -- format and usage must be non-zero");
    return actor;
  }

  sp<GraphicBuffer> buffer(new GraphicBuffer(aSize.width, aSize.height, format, usage));
  if (buffer->initCheck() != OK)
    return actor;

  size_t bpp = BytesPerPixelForPixelFormat(format);
  actor->mAllocBytes = aSize.width * aSize.height * bpp;
  sCurrentAlloc += actor->mAllocBytes;

  actor->mGraphicBuffer = buffer;
  *aOutHandle = MagicGrallocBufferHandle(buffer);

  return actor;
}
Exemple #3
0
void
BasicShadowCanvasLayer::Swap(const CanvasSurface& aNewFront, bool needYFlip,
                             CanvasSurface* aNewBack)
{
  AutoOpenSurface autoSurface(OPEN_READ_ONLY, aNewFront);
  // Destroy mFrontBuffer if size different
  gfxIntSize sz = autoSurface.Size();
  bool surfaceConfigChanged = sz != gfxIntSize(mBounds.width, mBounds.height);
  if (IsSurfaceDescriptorValid(mFrontSurface)) {
    AutoOpenSurface autoFront(OPEN_READ_ONLY, mFrontSurface);
    surfaceConfigChanged = surfaceConfigChanged ||
                           autoSurface.ContentType() != autoFront.ContentType();
  }
  if (surfaceConfigChanged) {
    DestroyFrontBuffer();
    mBounds.SetRect(0, 0, sz.width, sz.height);
  }

  mNeedsYFlip = needYFlip;
  // If mFrontBuffer
  if (IsSurfaceDescriptorValid(mFrontSurface)) {
    *aNewBack = mFrontSurface;
  } else {
    *aNewBack = null_t();
  }
  mFrontSurface = aNewFront;
}
Exemple #4
0
void define_impl<T, TargetType>::operator()(variant& var)
{
  if (OCI_IND_NULL == m_ind)
    var = null_t();
  else
    var = m_val;
} // define_impl::
/*static*/ PGrallocBufferParent*
GrallocBufferActor::Create(const gfxIntSize& aSize,
                           const gfxContentType& aContent,
                           MaybeMagicGrallocBufferHandle* aOutHandle)
{
  SAMPLE_LABEL("GrallocBufferActor", "Create");
  GrallocBufferActor* actor = new GrallocBufferActor();
  *aOutHandle = null_t();
  android::PixelFormat format = PixelFormatForContentType(aContent);
  sp<GraphicBuffer> buffer(
    new GraphicBuffer(aSize.width, aSize.height, format,
                      GraphicBuffer::USAGE_SW_READ_OFTEN |
                      GraphicBuffer::USAGE_SW_WRITE_OFTEN |
                      GraphicBuffer::USAGE_HW_TEXTURE));
  if (buffer->initCheck() != OK)
    return actor;

  size_t bpp = gfxASurface::BytePerPixelFromFormat(
      gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent));
  actor->mAllocBytes = aSize.width * aSize.height * bpp;
  sCurrentAlloc += actor->mAllocBytes;

  actor->mGraphicBuffer = buffer;
  *aOutHandle = MagicGrallocBufferHandle(buffer);
  return actor;
}
bool
StorageParent::RecvGetValue(const bool& aCallerSecure, const bool& aSessionOnly,
                            const nsString& aKey, StorageItem* aItem,
                            nsresult* rv)
{
  mStorage->SetSessionOnly(aSessionOnly);

  // We need to ensure that a proper null representation is sent to the child
  // if no item is found or an error occurs.

  *rv = NS_OK;
  nsCOMPtr<nsIDOMStorageItem> item = mStorage->GetValue(aCallerSecure, aKey, rv);
  if (NS_FAILED(*rv) || !item) {
    *aItem = null_t();
    return true;
  }

  ItemData data(EmptyString(), false);
  nsDOMStorageItem* internalItem = static_cast<nsDOMStorageItem*>(item.get());
  data.value() = internalItem->GetValueInternal();
  if (aCallerSecure)
    data.secure() = internalItem->IsSecure();
  *aItem = data;
  return true;
}
void
StorageChild::InitRemote()
{
  ContentChild* child = ContentChild::GetSingleton();
  AddIPDLReference();
  child->SendPStorageConstructor(this, null_t());
  SendInit(mUseDB, mCanUseChromePersist, mSessionOnly, mInPrivateBrowsing, mDomain, mScopeDBKey,
           mQuotaDomainDBKey, mQuotaETLDplus1DomainDBKey, mStorageType);
}
void
ImageBridgeChild::UpdatedTexture(CompositableClient* aCompositable,
                                 TextureClient* aTexture,
                                 nsIntRegion* aRegion)
{
  MaybeRegion region = aRegion ? MaybeRegion(*aRegion)
                               : MaybeRegion(null_t());
  mTxn->AddNoSwapEdit(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
                                      aTexture->GetID(),
                                      region));
}
Exemple #9
0
void
DeprecatedImageHostBuffered::MakeDeprecatedTextureHost(TextureIdentifier aTextureId,
                                                       const SurfaceDescriptor& aSurface,
                                                       ISurfaceAllocator* aAllocator,
                                                       const TextureInfo& aTextureInfo)
{
  DeprecatedImageHostSingle::MakeDeprecatedTextureHost(aTextureId,
                                                       aSurface,
                                                       aAllocator,
                                                       aTextureInfo);
  if (mDeprecatedTextureHost) {
    mDeprecatedTextureHost->SetBuffer(new SurfaceDescriptor(null_t()), aAllocator);
  }
}
Exemple #10
0
inline int get_data_blob::operator()(int req, size_t col, variant& var)
{
  T_CCI_BIT data;
  int ind(-1);
  const int r(lib::singleton().p_cci_get_data(req, int(col + 1), CCI_A_TYPE_BIT, &data, &ind));
  if (lib::error(r) || ind < 0)
    var = null_t();
  else
  {
    var = blob_t();
    blob_t& blob(::boost::get<blob_t>(var));
    blob.resize(data.size);
    if (!blob.empty()) memcpy(blob.data(), data.buf, data.size);
  }
  return r;
} // get_data_blob::
Exemple #11
0
void
ShadowLayerForwarder::CreatedThebesBuffer(ShadowableLayer* aThebes,
        const nsIntRegion& aFrontValidRegion,
        const nsIntRect& aBufferRect,
        const SurfaceDescriptor& aTempFrontBuffer)
{
    OptionalThebesBuffer buffer = null_t();
    if (IsSurfaceDescriptorValid(aTempFrontBuffer)) {
        buffer = ThebesBuffer(aTempFrontBuffer,
                              aBufferRect,
                              nsIntPoint(0, 0));
    }
    mTxn->AddEdit(OpCreateThebesBuffer(NULL, Shadow(aThebes),
                                       buffer,
                                       aFrontValidRegion));
}
/*static*/ PGrallocBufferParent*
GrallocBufferActor::Create(const gfxIntSize& aSize,
                           const uint32_t& aFormat,
                           const uint32_t& aUsage,
                           MaybeMagicGrallocBufferHandle* aOutHandle)
{
  GrallocBufferActor* actor = new GrallocBufferActor();
  *aOutHandle = null_t();
  sp<GraphicBuffer> buffer(
    new GraphicBuffer(aSize.width, aSize.height, aFormat, aUsage));
  if (buffer->initCheck() != OK)
    return actor;

  actor->mGraphicBuffer = buffer;
  *aOutHandle = MagicGrallocBufferHandle(buffer);
  return actor;
}
void
ShadowThebesLayerD3D10::Swap(
  const ThebesBuffer& aNewFront, const nsIntRegion& aUpdatedRegion,
  OptionalThebesBuffer* aNewBack, nsIntRegion* aNewBackValidRegion,
  OptionalThebesBuffer* aReadOnlyFront, nsIntRegion* aFrontUpdatedRegion)
{
  nsRefPtr<ID3D10Texture2D> newBackBuffer = mTexture;

  mTexture = OpenForeign(mD3DManager->device(), aNewFront.buffer());
  NS_ABORT_IF_FALSE(mTexture, "Couldn't open foreign texture");

  // The content process tracks back/front buffers on its own, so
  // the newBack is in essence unused.
  *aNewBack = aNewFront;

  // The content process doesn't need to read back from the front
  // buffer (yet).
  *aReadOnlyFront = null_t();

  // FIXME/bug 662109: synchronize using KeyedMutex
}
/*static*/ PGrallocBufferParent*
GrallocBufferActor::Create(const gfxIntSize& aSize,
                           const gfxContentType& aContent,
                           MaybeMagicGrallocBufferHandle* aOutHandle)
{
  SAMPLE_LABEL("GrallocBufferActor", "Create");
  GrallocBufferActor* actor = new GrallocBufferActor();
  *aOutHandle = null_t();
  android::PixelFormat format = PixelFormatForContentType(aContent);
  sp<GraphicBuffer> buffer(
    new GraphicBuffer(aSize.width, aSize.height, format,
                      GraphicBuffer::USAGE_SW_READ_OFTEN |
                      GraphicBuffer::USAGE_SW_WRITE_OFTEN |
                      GraphicBuffer::USAGE_HW_TEXTURE));
  if (buffer->initCheck() != OK)
    return actor;

  actor->mGraphicBuffer = buffer;
  *aOutHandle = MagicGrallocBufferHandle(buffer);
  return actor;
}
Exemple #15
0
void
TextureParent::CompositorRecycle()
{
  mTextureHost->ClearRecycleCallback();

  MaybeFenceHandle handle = null_t();
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
  if (mTextureHost) {
    TextureHostOGL* hostOGL = mTextureHost->AsHostOGL();
    android::sp<android::Fence> fence = hostOGL->GetAndResetReleaseFence();
    if (fence.get() && fence->isValid()) {
      handle = FenceHandle(fence);
      // HWC might not provide Fence.
      // In this case, HWC implicitly handles buffer's fence.
    }
  }
#endif
  mozilla::unused << SendCompositorRecycle(handle);

  // Don't forget to prepare for the next reycle
  mWaitForClientRecycle = mTextureHost;
}
int bind_result_arr<T, TypeID>::operator()(MYSQL_STMT* stmt, unsigned int col, variant& var)
{
  int r(0);
  if (m_is_null) var = null_t();
  else
  {
    if (m_bind.buffer_length < m_lenght) m_arr.resize(m_lenght);
    m_bind.buffer = (void*)m_arr.data();
    m_bind.buffer_length = m_lenght;
    r = lib::singleton().p_mysql_stmt_fetch_column(stmt, &m_bind, col, 0);
    m_bind.buffer = 0;
    m_bind.buffer_length = 0;

    if (r == 0)
    {
      var = T();
      T& arr = ::boost::get<T>(var);
      arr.resize(size_t(m_lenght));
      if (!arr.empty()) memcpy((void*)arr.data(), m_arr.data(), arr.size());
    }
  }
  return r;
} // bind_result_arr::
int bind_result_value<T, TypeID>::set_result(MYSQL_STMT*, unsigned int, db_variant& var)
{
	if (m_is_null)	var = null_t();
	else			var = m_val;
	return 0;
}	//bind_result_value
Exemple #18
0
bool
ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
{
  SAMPLE_LABEL("ShadowLayerForwarder", "EndTranscation");
  RenderTraceScope rendertrace("Foward Transaction", "000091");
  NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
  NS_ABORT_IF_FALSE(!mTxn->Finished(), "forgot BeginTransaction?");

  AutoTxnEnd _(mTxn);

  if (mTxn->Empty()) {
    MOZ_LAYERS_LOG(("[LayersForwarder] 0-length cset (?), skipping Update()"));
    return true;
  }

  MOZ_LAYERS_LOG(("[LayersForwarder] destroying buffers..."));

  for (PRUint32 i = 0; i < mTxn->mDyingBuffers.Length(); ++i) {
    DestroySharedSurface(&mTxn->mDyingBuffers[i]);
  }

  MOZ_LAYERS_LOG(("[LayersForwarder] building transaction..."));

  // We purposely add attribute-change ops to the final changeset
  // before we add paint ops.  This allows layers to record the
  // attribute changes before new pixels arrive, which can be useful
  // for setting up back/front buffers.
  RenderTraceScope rendertrace2("Foward Transaction", "000092");
  for (ShadowableLayerSet::const_iterator it = mTxn->mMutants.begin();
       it != mTxn->mMutants.end(); ++it) {
    ShadowableLayer* shadow = *it;
    Layer* mutant = shadow->AsLayer();
    NS_ABORT_IF_FALSE(!!mutant, "unshadowable layer?");

    LayerAttributes attrs;
    CommonLayerAttributes& common = attrs.common();
    common.visibleRegion() = mutant->GetVisibleRegion();
    common.transform() = mutant->GetTransform();
    common.contentFlags() = mutant->GetContentFlags();
    common.opacity() = mutant->GetOpacity();
    common.useClipRect() = !!mutant->GetClipRect();
    common.clipRect() = (common.useClipRect() ?
                         *mutant->GetClipRect() : nsIntRect());
    common.isFixedPosition() = mutant->GetIsFixedPosition();
    if (Layer* maskLayer = mutant->GetMaskLayer()) {
      common.maskLayerChild() = Shadow(maskLayer->AsShadowableLayer());
    } else {
      common.maskLayerChild() = NULL;
    }
    common.maskLayerParent() = NULL;
    attrs.specific() = null_t();
    mutant->FillSpecificAttributes(attrs.specific());

    mTxn->AddEdit(OpSetLayerAttributes(NULL, Shadow(shadow), attrs));
  }

  AutoInfallibleTArray<Edit, 10> cset;
  size_t nCsets = mTxn->mCset.size() + mTxn->mPaints.size();
  NS_ABORT_IF_FALSE(nCsets > 0, "should have bailed by now");

  cset.SetCapacity(nCsets);
  if (!mTxn->mCset.empty()) {
    cset.AppendElements(&mTxn->mCset.front(), mTxn->mCset.size());
  }
  // Paints after non-paint ops, including attribute changes.  See
  // above.
  if (!mTxn->mPaints.empty()) {
    cset.AppendElements(&mTxn->mPaints.front(), mTxn->mPaints.size());
  }

  MOZ_LAYERS_LOG(("[LayersForwarder] syncing before send..."));
  PlatformSyncBeforeUpdate();

  if (mTxn->mSwapRequired) {
    MOZ_LAYERS_LOG(("[LayersForwarder] sending transaction..."));
    RenderTraceScope rendertrace3("Forward Transaction", "000093");
    if (!mShadowManager->SendUpdate(cset, mIsFirstPaint, aReplies)) {
      MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
      return false;
    }
  } else {
    // If we don't require a swap we can call SendUpdateNoSwap which
    // assumes that aReplies is empty (DEBUG assertion)
    MOZ_LAYERS_LOG(("[LayersForwarder] sending no swap transaction..."));
    RenderTraceScope rendertrace3("Forward NoSwap Transaction", "000093");
    if (!mShadowManager->SendUpdateNoSwap(cset, mIsFirstPaint)) {
      MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
      return false;
    }
  }

  mIsFirstPaint = false;
  MOZ_LAYERS_LOG(("[LayersForwarder] ... done"));
  return true;
}
Exemple #19
0
PRBool
ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
{
    NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
    NS_ABORT_IF_FALSE(!mTxn->Finished(), "forgot BeginTransaction?");

    AutoTxnEnd _(mTxn);

    if (mTxn->Empty()) {
        MOZ_LAYERS_LOG(("[LayersForwarder] 0-length cset (?), skipping Update()"));
        return PR_TRUE;
    }

    MOZ_LAYERS_LOG(("[LayersForwarder] destroying buffers..."));

    for (PRUint32 i = 0; i < mTxn->mDyingBuffers.Length(); ++i) {
        DestroySharedSurface(&mTxn->mDyingBuffers[i]);
    }

    MOZ_LAYERS_LOG(("[LayersForwarder] building transaction..."));

    // We purposely add attribute-change ops to the final changeset
    // before we add paint ops.  This allows layers to record the
    // attribute changes before new pixels arrive, which can be useful
    // for setting up back/front buffers.
    for (ShadowableLayerSet::const_iterator it = mTxn->mMutants.begin();
            it != mTxn->mMutants.end(); ++it) {
        ShadowableLayer* shadow = *it;
        Layer* mutant = shadow->AsLayer();
        NS_ABORT_IF_FALSE(!!mutant, "unshadowable layer?");

        LayerAttributes attrs;
        CommonLayerAttributes& common = attrs.common();
        common.visibleRegion() = mutant->GetVisibleRegion();
        common.transform() = mutant->GetTransform();
        common.contentFlags() = mutant->GetContentFlags();
        common.opacity() = mutant->GetOpacity();
        common.useClipRect() = !!mutant->GetClipRect();
        common.clipRect() = (common.useClipRect() ?
                             *mutant->GetClipRect() : nsIntRect());
        common.isFixedPosition() = mutant->GetIsFixedPosition();
        common.useTileSourceRect() = !!mutant->GetTileSourceRect();
        common.tileSourceRect() = (common.useTileSourceRect() ?
                                   *mutant->GetTileSourceRect() : nsIntRect());
        attrs.specific() = null_t();
        mutant->FillSpecificAttributes(attrs.specific());

        mTxn->AddEdit(OpSetLayerAttributes(NULL, Shadow(shadow), attrs));
    }

    AutoInfallibleTArray<Edit, 10> cset;
    size_t nCsets = mTxn->mCset.size() + mTxn->mPaints.size();
    NS_ABORT_IF_FALSE(nCsets > 0, "should have bailed by now");

    cset.SetCapacity(nCsets);
    if (!mTxn->mCset.empty()) {
        cset.AppendElements(&mTxn->mCset.front(), mTxn->mCset.size());
    }
    // Paints after non-paint ops, including attribute changes.  See
    // above.
    if (!mTxn->mPaints.empty()) {
        cset.AppendElements(&mTxn->mPaints.front(), mTxn->mPaints.size());
    }

    MOZ_LAYERS_LOG(("[LayersForwarder] syncing before send..."));
    PlatformSyncBeforeUpdate();

    MOZ_LAYERS_LOG(("[LayersForwarder] sending transaction..."));
    if (!mShadowManager->SendUpdate(cset, aReplies)) {
        MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
        return PR_FALSE;
    }

    MOZ_LAYERS_LOG(("[LayersForwarder] ... done"));
    return PR_TRUE;
}