gfx/layers/opengl/TextureClientOGL.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/. */
     6 #include "GLContext.h"                  // for GLContext, etc
     7 #include "SurfaceStream.h"
     8 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
     9 #include "mozilla/layers/ISurfaceAllocator.h"
    10 #include "mozilla/layers/TextureClientOGL.h"
    11 #include "nsSize.h"                     // for nsIntSize
    13 using namespace mozilla::gl;
    15 namespace mozilla {
    16 namespace layers {
    18 class CompositableForwarder;
    20 SharedTextureClientOGL::SharedTextureClientOGL(TextureFlags aFlags)
    21   : TextureClient(aFlags)
    22   , mHandle(0)
    23   , mInverted(false)
    24 {
    25   // SharedTextureClient is always owned externally.
    26   mFlags |= TEXTURE_DEALLOCATE_CLIENT;
    27 }
    29 SharedTextureClientOGL::~SharedTextureClientOGL()
    30 {
    31   // the shared data is owned externally.
    32 }
    35 bool
    36 SharedTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
    37 {
    38   MOZ_ASSERT(IsValid());
    39   if (!IsAllocated()) {
    40     return false;
    41   }
    42   aOutDescriptor = SharedTextureDescriptor(mShareType, mHandle, mSize, mInverted);
    43   return true;
    44 }
    46 void
    47 SharedTextureClientOGL::InitWith(gl::SharedTextureHandle aHandle,
    48                                  gfx::IntSize aSize,
    49                                  gl::SharedTextureShareType aShareType,
    50                                  bool aInverted)
    51 {
    52   MOZ_ASSERT(IsValid());
    53   MOZ_ASSERT(!IsAllocated());
    54   mHandle = aHandle;
    55   mSize = aSize;
    56   mShareType = aShareType;
    57   mInverted = aInverted;
    58   if (mInverted) {
    59     AddFlags(TEXTURE_NEEDS_Y_FLIP);
    60   }
    61 }
    63 bool
    64 SharedTextureClientOGL::Lock(OpenMode mode)
    65 {
    66   MOZ_ASSERT(!mIsLocked);
    67   if (!IsValid() || !IsAllocated()) {
    68     return false;
    69   }
    70   mIsLocked = true;
    71   return true;
    72 }
    74 void
    75 SharedTextureClientOGL::Unlock()
    76 {
    77   MOZ_ASSERT(mIsLocked);
    78   mIsLocked = false;
    79 }
    81 bool
    82 SharedTextureClientOGL::IsAllocated() const
    83 {
    84   return mHandle != 0;
    85 }
    87 StreamTextureClientOGL::StreamTextureClientOGL(TextureFlags aFlags)
    88   : TextureClient(aFlags)
    89   , mIsLocked(false)
    90 {
    91 }
    93 StreamTextureClientOGL::~StreamTextureClientOGL()
    94 {
    95   // the data is owned externally.
    96 }
    98 bool
    99 StreamTextureClientOGL::Lock(OpenMode mode)
   100 {
   101   MOZ_ASSERT(!mIsLocked);
   102   if (!IsValid() || !IsAllocated()) {
   103     return false;
   104   }
   105   mIsLocked = true;
   106   return true;
   107 }
   109 void
   110 StreamTextureClientOGL::Unlock()
   111 {
   112   MOZ_ASSERT(mIsLocked);
   113   mIsLocked = false;
   114 }
   116 bool
   117 StreamTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
   118 {
   119   if (!IsAllocated()) {
   120     return false;
   121   }
   123   gfx::SurfaceStreamHandle handle = mStream->GetShareHandle();
   124   aOutDescriptor = SurfaceStreamDescriptor(handle, false);
   125   return true;
   126 }
   128 void
   129 StreamTextureClientOGL::InitWith(gfx::SurfaceStream* aStream)
   130 {
   131   MOZ_ASSERT(!IsAllocated());
   132   mStream = aStream;
   133   mGL = mStream->GLContext();
   134 }
   136 bool
   137 StreamTextureClientOGL::IsAllocated() const
   138 {
   139   return mStream != 0;
   140 }
   143 } // namespace
   144 } // namespace

mercurial