LCOV - code coverage report
Current view: top level - widget - CompositorWidget.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 3 36 8.3 %
Date: 2017-07-14 16:53:18 Functions: 1 9 11.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       3             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             : 
       5             : #include "CompositorWidget.h"
       6             : #include "GLConsts.h"
       7             : #include "nsBaseWidget.h"
       8             : #include "VsyncDispatcher.h"
       9             : 
      10             : namespace mozilla {
      11             : namespace widget {
      12             : 
      13           1 : CompositorWidget::CompositorWidget(const layers::CompositorOptions& aOptions)
      14           1 :   : mOptions(aOptions)
      15             : {
      16           1 : }
      17             : 
      18           0 : CompositorWidget::~CompositorWidget()
      19             : {
      20           0 : }
      21             : 
      22             : already_AddRefed<gfx::DrawTarget>
      23           0 : CompositorWidget::StartRemoteDrawing()
      24             : {
      25           0 :   return nullptr;
      26             : }
      27             : 
      28             : void
      29           0 : CompositorWidget::CleanupRemoteDrawing()
      30             : {
      31           0 :   mLastBackBuffer = nullptr;
      32           0 : }
      33             : 
      34             : already_AddRefed<gfx::DrawTarget>
      35           0 : CompositorWidget::GetBackBufferDrawTarget(gfx::DrawTarget* aScreenTarget,
      36             :                                           const LayoutDeviceIntRect& aRect,
      37             :                                           const LayoutDeviceIntRect& aClearRect)
      38             : {
      39           0 :   MOZ_ASSERT(aScreenTarget);
      40             :   gfx::SurfaceFormat format =
      41           0 :     aScreenTarget->GetFormat() == gfx::SurfaceFormat::B8G8R8X8 ? gfx::SurfaceFormat::B8G8R8X8 : gfx::SurfaceFormat::B8G8R8A8;
      42           0 :   gfx::IntSize size = aRect.ToUnknownRect().Size();
      43           0 :   gfx::IntSize clientSize(GetClientSize().ToUnknownSize());
      44             : 
      45           0 :   RefPtr<gfx::DrawTarget> target;
      46             :   // Re-use back buffer if possible
      47           0 :   if (mLastBackBuffer &&
      48           0 :       mLastBackBuffer->GetBackendType() == aScreenTarget->GetBackendType() &&
      49           0 :       mLastBackBuffer->GetFormat() == format &&
      50           0 :       size <= mLastBackBuffer->GetSize() &&
      51           0 :       mLastBackBuffer->GetSize() <= clientSize) {
      52           0 :     target = mLastBackBuffer;
      53           0 :     target->SetTransform(gfx::Matrix());
      54           0 :     if (!aClearRect.IsEmpty()) {
      55           0 :       gfx::IntRect clearRect = aClearRect.ToUnknownRect() - aRect.ToUnknownRect().TopLeft();
      56           0 :       target->ClearRect(gfx::Rect(clearRect.x, clearRect.y, clearRect.width, clearRect.height));
      57             :     }
      58             :   } else {
      59           0 :     target = aScreenTarget->CreateSimilarDrawTarget(size, format);
      60           0 :     mLastBackBuffer = target;
      61             :   }
      62           0 :   return target.forget();
      63             : }
      64             : 
      65             : already_AddRefed<gfx::SourceSurface>
      66           0 : CompositorWidget::EndBackBufferDrawing()
      67             : {
      68           0 :   RefPtr<gfx::SourceSurface> surface = mLastBackBuffer ? mLastBackBuffer->Snapshot() : nullptr;
      69           0 :   return surface.forget();
      70             : }
      71             : 
      72             : uint32_t
      73           0 : CompositorWidget::GetGLFrameBufferFormat()
      74             : {
      75           0 :   return LOCAL_GL_RGBA;
      76             : }
      77             : 
      78             : RefPtr<VsyncObserver>
      79           0 : CompositorWidget::GetVsyncObserver() const
      80             : {
      81             :   // This should only used when the widget is in the GPU process, and should be
      82             :   // implemented by IPDL-enabled CompositorWidgets.
      83             :   // GPU process does not have a CompositorVsyncDispatcher.
      84           0 :   MOZ_ASSERT_UNREACHABLE("Must be implemented by derived class");
      85             :   return nullptr;
      86             : }
      87             : 
      88             : } // namespace widget
      89             : } // namespace mozilla

Generated by: LCOV version 1.13