gfx/layers/basic/TextureClientX11.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2 //  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "mozilla/layers/TextureClientX11.h"
     6 #include "mozilla/layers/CompositableClient.h"
     7 #include "mozilla/layers/CompositableForwarder.h"
     8 #include "mozilla/layers/ISurfaceAllocator.h"
     9 #include "mozilla/layers/ShadowLayerUtilsX11.h"
    10 #include "mozilla/gfx/2D.h"
    11 #include "gfxXlibSurface.h"
    12 #include "gfx2DGlue.h"
    14 #include "mozilla/X11Util.h"
    15 #include <X11/Xlib.h>
    17 using namespace mozilla;
    18 using namespace mozilla::gfx;
    19 using namespace mozilla::layers;
    21 TextureClientX11::TextureClientX11(SurfaceFormat aFormat, TextureFlags aFlags)
    22   : TextureClient(aFlags),
    23     mFormat(aFormat),
    24     mLocked(false)
    25 {
    26   MOZ_COUNT_CTOR(TextureClientX11);
    27 }
    29 TextureClientX11::~TextureClientX11()
    30 {
    31   MOZ_COUNT_DTOR(TextureClientX11);
    32 }
    34 bool
    35 TextureClientX11::IsAllocated() const
    36 {
    37   return !!mSurface;
    38 }
    40 bool
    41 TextureClientX11::Lock(OpenMode aMode)
    42 {
    43   MOZ_ASSERT(!mLocked, "The TextureClient is already Locked!");
    44   mLocked = IsValid() && IsAllocated();
    45   return mLocked;
    46 }
    48 void
    49 TextureClientX11::Unlock()
    50 {
    51   MOZ_ASSERT(mLocked, "The TextureClient is already Unlocked!");
    52   mLocked = false;
    54   if (mSurface) {
    55     FinishX(DefaultXDisplay());
    56   }
    57 }
    59 bool
    60 TextureClientX11::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
    61 {
    62   MOZ_ASSERT(IsValid());
    63   if (!mSurface) {
    64     return false;
    65   }
    67   aOutDescriptor = SurfaceDescriptorX11(mSurface);
    68   return true;
    69 }
    71 TextureClientData*
    72 TextureClientX11::DropTextureData()
    73 {
    74   MOZ_ASSERT(!(mFlags & TEXTURE_DEALLOCATE_CLIENT));
    75   return nullptr;
    76 }
    78 bool
    79 TextureClientX11::AllocateForSurface(IntSize aSize, TextureAllocationFlags aTextureFlags)
    80 {
    81   MOZ_ASSERT(IsValid());
    82   //MOZ_ASSERT(mFormat != gfx::FORMAT_YUV, "This TextureClient cannot use YCbCr data");
    84   gfxContentType contentType = ContentForFormat(mFormat);
    85   nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(aSize, contentType);
    86   if (!surface || surface->GetType() != gfxSurfaceType::Xlib) {
    87     NS_ERROR("creating Xlib surface failed!");
    88     return false;
    89   }
    91   mSize = aSize;
    92   mSurface = static_cast<gfxXlibSurface*>(surface.get());
    94   // The host is always responsible for freeing the pixmap.
    95   mSurface->ReleasePixmap();
    96   return true;
    97 }
    99 TemporaryRef<DrawTarget>
   100 TextureClientX11::GetAsDrawTarget()
   101 {
   102   MOZ_ASSERT(IsValid());
   103   if (!mSurface) {
   104     return nullptr;
   105   }
   107   IntSize size = ToIntSize(mSurface->GetSize());
   108   return Factory::CreateDrawTargetForCairoSurface(mSurface->CairoSurface(), size);
   109 }

mercurial