gfx/layers/wr/WebRenderLayer.h
author Kartikaya Gupta <kgupta@mozilla.com>
Wed, 26 Apr 2017 16:37:16 -0400
changeset 568972 5b30cbc2c96f4f76afc478551b3d6453c95d0f77
parent 568971 5151e0e158035590f841ee12a48ab93eb2128c9c
child 568973 fca7f45a1451d0bc8bea569642a1e144fbdb04f5
permissions -rw-r--r--
Bug 1359842 - Rename ParentStackingContextBounds to ParentBounds. r=nical MozReview-Commit-ID: HmvRnzvgRML

/* -*- 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/. */

#ifndef GFX_WEBRENDERLAYER_H
#define GFX_WEBRENDERLAYER_H

#include "Layers.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "mozilla/webrender/WebRenderAPI.h"

namespace mozilla {
namespace layers {

class ImageClientSingle;
class WebRenderBridgeChild;
class WebRenderLayerManager;

typedef gfx::Matrix4x4Typed<LayerPixel, LayerPixel> BoundsTransformMatrix;

class WebRenderLayer
{
public:
  virtual Layer* GetLayer() = 0;
  virtual void RenderLayer(wr::DisplayListBuilder& aBuilder) = 0;
  virtual Maybe<WrImageMask> RenderMaskLayer(const gfx::Matrix4x4& aTransform)
  {
    MOZ_ASSERT(false);
    return Nothing();
  }

  virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; }
  static inline WebRenderLayer*
  ToWebRenderLayer(Layer* aLayer)
  {
    return static_cast<WebRenderLayer*>(aLayer->ImplData());
  }

  Maybe<wr::ImageKey> UpdateImageKey(ImageClientSingle* aImageClient,
                                     ImageContainer* aContainer,
                                     Maybe<wr::ImageKey>& aOldKey,
                                     wr::ExternalImageId& aExternalImageId);

  WebRenderLayerManager* WrManager();
  WebRenderBridgeChild* WrBridge();
  WrImageKey GetImageKey();

  LayerRect RelativeToVisible(const LayerRect& aRect);
  LayerRect RelativeToParent(const LayerRect& aRect);
  LayerRect RelativeToParent(const LayoutDeviceRect& aRect);
  LayerRect VisibleBoundsRelativeToParent();
  LayerPoint GetOffsetToParent();
  gfx::Rect TransformedVisibleBoundsRelativeToParent();
protected:
  LayerRect Bounds();
  BoundsTransformMatrix BoundsTransform();
  LayerRect BoundsForStackingContext();
  LayerRect ParentBounds();
  Maybe<LayerRect> ClipRect();

  LayerRect GetWrBoundsRect();
  LayerRect GetWrRelBounds();
  LayerRect GetWrClipRect(const LayerRect& aRect);
  void DumpLayerInfo(const char* aLayerType, const LayerRect& aRect);
  Maybe<WrImageMask> BuildWrMaskLayer(bool aUnapplyLayerTransform);
};

} // namespace layers
} // namespace mozilla

#endif /* GFX_WEBRENDERLAYER_H */