DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
/* -*- Mode: C++; tab-width: 2; 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 "WebRenderDisplayItemLayer.h"

#include "LayersLogging.h"
#include "mozilla/webrender/webrender_ffi.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "mozilla/layers/WebRenderBridgeChild.h"
#include "nsDisplayList.h"
#include "mozilla/gfx/Matrix.h"

namespace mozilla {
namespace layers {

void
WebRenderDisplayItemLayer::RenderLayer()
{
  if (mItem) {
    // We might have recycled this layer. Throw away the old commands.
    mCommands.Clear();
    mParentCommands.Clear();
    mItem->CreateWebRenderCommands(mCommands, mParentCommands, this);
  }
  // else we have an empty transaction and just use the
  // old commands.

  WrBridge()->AddWebRenderCommands(mCommands);
  WrBridge()->AddWebRenderParentCommands(mParentCommands);
}

uint64_t
WebRenderDisplayItemLayer::SendImageContainer(ImageContainer* aContainer)
{
  if (mImageContainer != aContainer) {
    AutoLockImage autoLock(aContainer);
    Image* image = autoLock.GetImage();
    if (!image) {
      return 0;
    }

    if (!mImageClient) {
      mImageClient = ImageClient::CreateImageClient(CompositableType::IMAGE,
                                                    WrBridge(),
                                                    TextureFlags::DEFAULT);
      if (!mImageClient) {
        return 0;
      }
      mImageClient->Connect();
    }

    if (!mExternalImageId) {
      MOZ_ASSERT(mImageClient);
      mExternalImageId = WrBridge()->AllocExternalImageIdForCompositable(mImageClient);
    }
    MOZ_ASSERT(mExternalImageId);

    if (mImageClient && !mImageClient->UpdateImage(aContainer, /* unused */0)) {
      return 0;
    }
    mImageContainer = aContainer;
  }

  return mExternalImageId;
}

} // namespace layers
} // namespace mozilla