Bug 651858 - Part 3: Add layers API for creating an optimal DrawTarget. r=roc
authorBas Schouten <bschouten@mozilla.com>
Fri, 24 Jun 2011 19:41:18 +0200
changeset 71715 0f674a8c14a3c93a218c43920b3065d75b1f2139
parent 71714 95039cfae6a3d88fe0b906e97c9657f4557d38c4
child 71716 8223367a233f39d7dfb50589584d2fae16c2cf50
push id20601
push usermak77@bonardo.net
push dateSat, 25 Jun 2011 10:05:20 +0000
treeherdermozilla-central@48ad4ffc4230 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs651858
milestone7.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 651858 - Part 3: Add layers API for creating an optimal DrawTarget. r=roc
gfx/layers/Layers.cpp
gfx/layers/Layers.h
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -43,16 +43,17 @@
 #include "ImageLayers.h"
 #include "Layers.h"
 #include "gfxPlatform.h"
 #include "ReadbackLayer.h"
 #include "gfxUtils.h"
 #include "mozilla/Util.h"
 
 using namespace mozilla::layers;
+using namespace mozilla::gfx;
 
 typedef FrameMetrics::ViewID ViewID;
 const ViewID FrameMetrics::NULL_SCROLL_ID = 0;
 const ViewID FrameMetrics::ROOT_SCROLL_ID = 1;
 const ViewID FrameMetrics::START_SCROLL_ID = 2;
 
 #ifdef MOZ_LAYERS_HAVE_LOG
 FILE*
@@ -205,16 +206,24 @@ namespace layers {
 already_AddRefed<gfxASurface>
 LayerManager::CreateOptimalSurface(const gfxIntSize &aSize,
                                    gfxASurface::gfxImageFormat aFormat)
 {
   return gfxPlatform::GetPlatform()->
     CreateOffscreenSurface(aSize, gfxASurface::ContentFromFormat(aFormat));
 }
 
+TemporaryRef<DrawTarget>
+LayerManager::CreateDrawTarget(const IntSize &aSize,
+                               SurfaceFormat aFormat)
+{
+  // Right now this doesn't work on the general layer manager.
+  return NULL;
+}
+
 #ifdef DEBUG
 void
 LayerManager::Mutated(Layer* aLayer)
 {
 }
 #endif  // DEBUG
 
 //--------------------------------------------------
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -44,16 +44,18 @@
 #include "nsPoint.h"
 #include "nsRect.h"
 #include "nsISupportsImpl.h"
 #include "nsAutoPtr.h"
 #include "gfx3DMatrix.h"
 #include "gfxColor.h"
 #include "gfxPattern.h"
 
+#include "mozilla/gfx/2D.h"
+
 #if defined(DEBUG) || defined(PR_LOGGING)
 #  include <stdio.h>            // FILE
 #  include "prlog.h"
 #  define MOZ_LAYERS_HAVE_LOG
 #  define MOZ_LAYERS_LOG(_args)                             \
   PR_LOG(LayerManager::GetLog(), PR_LOG_DEBUG, _args)
 #else
 struct PRLogModuleInfo;
@@ -420,16 +422,25 @@ public:
    * Creates a layer which is optimized for inter-operating with this layer
    * manager.
    */
   virtual already_AddRefed<gfxASurface>
     CreateOptimalSurface(const gfxIntSize &aSize,
                          gfxASurface::gfxImageFormat imageFormat);
 
   /**
+   * Creates a DrawTarget which is optimized for inter-operating with this
+   * layermanager.
+   */
+  virtual TemporaryRef<mozilla::gfx::DrawTarget>
+    CreateDrawTarget(const mozilla::gfx::IntSize &aSize,
+                     mozilla::gfx::SurfaceFormat aFormat);
+
+
+  /**
    * Return the name of the layer manager's backend.
    */
   virtual void GetBackendName(nsAString& aName) = 0;
 
   /**
    * This setter can be used anytime. The user data for all keys is
    * initially null. Ownership pases to the layer manager.
    */