Bug 944703 - Part 1: make SurfaceCaps hold a strong reference to its ISurfaceAllocator - r=jgilbert
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 03 Dec 2013 13:44:38 -0500
changeset 174270 101f294ad43cef67b1d0319e317eb252da48d829
parent 174269 3856aa97c77c16d5ef2b86892c4c94dc45cfef53
child 174271 781892a439cf94def2bcb9c497e70868a36b8ab4
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs944703
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 944703 - Part 1: make SurfaceCaps hold a strong reference to its ISurfaceAllocator - r=jgilbert
gfx/gl/SurfaceTypes.cpp
gfx/gl/SurfaceTypes.h
gfx/gl/moz.build
new file mode 100644
--- /dev/null
+++ b/gfx/gl/SurfaceTypes.cpp
@@ -0,0 +1,59 @@
+/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
+/* 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 "SurfaceTypes.h"
+#include "mozilla/layers/ISurfaceAllocator.h"
+
+namespace mozilla {
+namespace gfx {
+
+SurfaceCaps::SurfaceCaps()
+{
+  Clear();
+}
+
+SurfaceCaps::SurfaceCaps(const SurfaceCaps& other)
+{
+  *this = other;
+}
+
+SurfaceCaps&
+SurfaceCaps::operator=(const SurfaceCaps& other)
+{
+  any = other.any;
+  color = other.color;
+  alpha = other.alpha;
+  bpp16 = other.bpp16;
+  depth = other.depth;
+  stencil = other.stencil;
+  antialias = other.antialias;
+  preserve = other.preserve;
+  surfaceAllocator = other.surfaceAllocator;
+
+  return *this;
+}
+
+void
+SurfaceCaps::Clear()
+{
+  any = false;
+  color = false;
+  alpha = false;
+  bpp16 = false;
+  depth = false;
+  stencil = false;
+  antialias = false;
+  preserve = false;
+  surfaceAllocator = nullptr;
+}
+
+
+
+SurfaceCaps::~SurfaceCaps()
+{
+}
+
+}
+}
--- a/gfx/gl/SurfaceTypes.h
+++ b/gfx/gl/SurfaceTypes.h
@@ -2,49 +2,49 @@
 /* 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 SURFACE_TYPES_H_
 #define SURFACE_TYPES_H_
 
 #include "mozilla/TypedEnum.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/Attributes.h"
 #include <stdint.h>
 
-#include <cstring>
-
 namespace mozilla {
 namespace layers {
 class ISurfaceAllocator;
 }
 
 namespace gfx {
 
 typedef uintptr_t SurfaceStreamHandle;
 
-struct SurfaceCaps
+struct SurfaceCaps MOZ_FINAL
 {
     bool any;
     bool color, alpha;
     bool bpp16;
     bool depth, stencil;
     bool antialias;
     bool preserve;
 
     // The surface allocator that we want to create this
     // for.  May be null.
-    layers::ISurfaceAllocator* surfaceAllocator;
+    RefPtr<layers::ISurfaceAllocator> surfaceAllocator;
 
-    SurfaceCaps() {
-        Clear();
-    }
+    SurfaceCaps();
+    SurfaceCaps(const SurfaceCaps& other);
+    ~SurfaceCaps();
 
-    void Clear() {
-        std::memset(this, 0, sizeof(SurfaceCaps));
-    }
+    void Clear();
+
+    SurfaceCaps& operator=(const SurfaceCaps& other);
 
     // We can't use just 'RGB' here, since it's an ancient Windows macro.
     static SurfaceCaps ForRGB() {
         SurfaceCaps caps;
 
         caps.color = true;
 
         return caps;
--- a/gfx/gl/moz.build
+++ b/gfx/gl/moz.build
@@ -121,16 +121,17 @@ UNIFIED_SOURCES += [
     'GLSharedHandleHelpers.cpp',
     'GLTextureImage.cpp',
     'ScopedGLHelpers.cpp',
     'SharedSurface.cpp',
     'SharedSurfaceEGL.cpp',
     'SharedSurfaceGL.cpp',
     'SurfaceFactory.cpp',
     'SurfaceStream.cpp',
+    'SurfaceTypes.cpp',
     'TextureGarbageBin.cpp',
     'TextureImageEGL.cpp',
     'VBOArena.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 MSVC_ENABLE_PGO = True