Attachment #516139: Patch: add paint stats to ImagesContainer for bug #580531

View | Details | Raw Unified | Return to bug 580531
Collapse All | Expand All

(-)a/gfx/layers/ImageLayers.h (-2 / +72 lines)
Line     Link Here 
 Lines 34-49    Link Here 
34
 * the terms of any one of the MPL, the GPL or the LGPL.
34
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 *
35
 *
36
 * ***** END LICENSE BLOCK ***** */
36
 * ***** END LICENSE BLOCK ***** */
37
37
38
#ifndef GFX_IMAGELAYER_H
38
#ifndef GFX_IMAGELAYER_H
39
#define GFX_IMAGELAYER_H
39
#define GFX_IMAGELAYER_H
40
40
41
#include "Layers.h"
41
#include "Layers.h"
42
#include "mozilla/TimeStamp.h"
42
43
43
#include "gfxPattern.h"
44
#include "gfxPattern.h"
44
#include "nsThreadUtils.h"
45
#include "nsThreadUtils.h"
45
#include "nsCoreAnimationSupport.h"
46
#include "nsCoreAnimationSupport.h"
46
47
47
namespace mozilla {
48
namespace mozilla {
48
namespace layers {
49
namespace layers {
49
50
 Lines 126-156   protected: Link Here 
126
 * (because layers can only be used on the main thread) and we want to
127
 * (because layers can only be used on the main thread) and we want to
127
 * be able to set the current Image from any thread, to facilitate
128
 * be able to set the current Image from any thread, to facilitate
128
 * video playback without involving the main thread, for example.
129
 * video playback without involving the main thread, for example.
129
 */
130
 */
130
class THEBES_API ImageContainer {
131
class THEBES_API ImageContainer {
131
  THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageContainer)
132
  THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageContainer)
132
133
133
public:
134
public:
134
  ImageContainer() {}
135
  ImageContainer() : mPaintCount(0), mPreviousImagePainted(PR_FALSE) {}
135
  virtual ~ImageContainer() {}
136
  virtual ~ImageContainer() {}
136
137
137
  /**
138
  /**
138
   * Create an Image in one of the given formats.
139
   * Create an Image in one of the given formats.
139
   * Picks the "best" format from the list and creates an Image of that
140
   * Picks the "best" format from the list and creates an Image of that
140
   * format.
141
   * format.
141
   * Returns null if this backend does not support any of the formats.
142
   * Returns null if this backend does not support any of the formats.
142
   */
143
   */
143
  virtual already_AddRefed<Image> CreateImage(const Image::Format* aFormats,
144
  virtual already_AddRefed<Image> CreateImage(const Image::Format* aFormats,
144
                                              PRUint32 aNumFormats) = 0;
145
                                              PRUint32 aNumFormats) = 0;
145
146
146
  /**
147
  /**
147
   * Set an Image as the current image to display. The Image must have
148
   * Set an Image as the current image to display. The Image must have
148
   * been created by this ImageContainer.
149
   * been created by this ImageContainer.
150
   *
151
   * Implementations must call CurrentImageChanged() in a threadsafe manner.
149
   * 
152
   * 
150
   * The Image data must not be modified after this method is called!
153
   * The Image data must not be modified after this method is called!
151
   */
154
   */
152
  virtual void SetCurrentImage(Image* aImage) = 0;
155
  virtual void SetCurrentImage(Image* aImage) = 0;
153
156
154
  /**
157
  /**
155
   * Get the current Image.
158
   * Get the current Image.
156
   * This has to add a reference since otherwise there are race conditions
159
   * This has to add a reference since otherwise there are race conditions
 Lines 206-225   public: Link Here 
206
209
207
  /**
210
  /**
208
   * Get the layer manager type this image container was created with,
211
   * Get the layer manager type this image container was created with,
209
   * presumably its users might want to do something special if types do not
212
   * presumably its users might want to do something special if types do not
210
   * match.
213
   * match.
211
   */
214
   */
212
  virtual LayerManager::LayersBackend GetBackendType() = 0;
215
  virtual LayerManager::LayersBackend GetBackendType() = 0;
213
216
217
  /**
218
   * Returns the time at which the currently contained image was first
219
   * painted.  This is reset every time a new image is set as the current
220
   * image.  Note this may return a null timestamp if the current image
221
   * has not yet been painted.  Threadsafe.
222
   */
223
  virtual TimeStamp GetPaintTime() = 0;
224
225
  /**
226
   * Returns the number of images which have been contained in this container
227
   * and painted at least once.  Threadsafe.
228
   */
229
  virtual PRUint32 GetPaintCount() = 0;
230
231
  /**
232
   * Notifies the container that aImage has been painted.  Note we must pass
233
   * in a pointer to the image that has been painted, as the current image
234
   * can change while we're rendering, and in that case we don't want to
235
   * record the paint time of the just painted image as the paint time of the
236
   * current image.  Threadsafe.
237
   */
238
  virtual void NotifyPaintedImage(Image* aImage) = 0;
239
214
protected:
240
protected:
215
  LayerManager* mManager;
241
  LayerManager* mManager;
216
242
217
  ImageContainer(LayerManager* aManager) : mManager(aManager) {}
243
  ImageContainer(LayerManager* aManager)
244
    : mManager(aManager),
245
      mPaintCount(0),
246
      mPreviousImagePainted(PR_FALSE)
247
  {}
248
249
  // Increments mPaintCount if this is the first time aPainted has been
250
  // painted, and sets mPaintTime if the painted image is the current image
251
  // (aCurrent).  It's up to the ImageContainer implementation to ensure this
252
  // is called in a threadsafe manner.
253
  void RecordPaintStats(Image* aPainted, Image* aCurrent)
254
  {
255
    if (aPainted == aCurrent) {
256
      if (mPaintTime.IsNull()) {
257
        mPaintTime = TimeStamp::Now();
258
        mPaintCount++;
259
      }
260
    } else if (!mPreviousImagePainted) {
261
      // While we were painting this image, the current image changed. We
262
      // still must count it as painted, but can't set mPaintTime, since we're
263
      // no longer the current image.
264
      mPaintCount++;
265
      mPreviousImagePainted = PR_TRUE;
266
    }
267
  }
268
269
  // Performs necessary housekeeping to ensure the painted frame statistics
270
  // are accurate. Must be called by SetCurrentImage() implementations in a
271
  // thread safe manner.
272
  void CurrentImageChanged() {
273
    mPreviousImagePainted = !mPaintTime.IsNull();
274
    mPaintTime = TimeStamp();
275
  }
276
277
  // Number of contained images that have been painted at least once.  It's up
278
  // to the ImageContainer implementation to ensure accesses to this are
279
  // threadsafe.
280
  PRUint32 mPaintCount;
281
282
  // Time stamp at which the current image was first painted.  It's up to the
283
  // ImageContainer implementation to ensure accesses to this are threadsafe.
284
  TimeStamp mPaintTime;
285
286
  // Denotes whether the previous image was painted.
287
  PRBool mPreviousImagePainted;
218
};
288
};
219
289
220
/**
290
/**
221
 * A Layer which renders an Image.
291
 * A Layer which renders an Image.
222
 */
292
 */
223
class THEBES_API ImageLayer : public Layer {
293
class THEBES_API ImageLayer : public Layer {
224
public:
294
public:
225
  /**
295
  /**
(-)a/gfx/layers/basic/BasicImages.cpp (+26 lines)
Line     Link Here 
 Lines 302-317   public: Link Here 
302
  virtual already_AddRefed<Image> GetCurrentImage();
302
  virtual already_AddRefed<Image> GetCurrentImage();
303
  virtual already_AddRefed<gfxASurface> GetCurrentAsSurface(gfxIntSize* aSize);
303
  virtual already_AddRefed<gfxASurface> GetCurrentAsSurface(gfxIntSize* aSize);
304
  virtual gfxIntSize GetCurrentSize();
304
  virtual gfxIntSize GetCurrentSize();
305
  virtual PRBool SetLayerManager(LayerManager *aManager);
305
  virtual PRBool SetLayerManager(LayerManager *aManager);
306
  virtual void SetScaleHint(const gfxIntSize& aScaleHint);
306
  virtual void SetScaleHint(const gfxIntSize& aScaleHint);
307
  void SetOffscreenFormat(gfxImageFormat aFormat) { mOffscreenFormat = aFormat; }
307
  void SetOffscreenFormat(gfxImageFormat aFormat) { mOffscreenFormat = aFormat; }
308
  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_BASIC; }
308
  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_BASIC; }
309
309
310
  TimeStamp GetPaintTime();
311
  PRUint32 GetPaintCount();
312
  void NotifyPaintedImage(Image* aImage);
313
310
protected:
314
protected:
311
  Monitor mMonitor;
315
  Monitor mMonitor;
312
  nsRefPtr<Image> mImage;
316
  nsRefPtr<Image> mImage;
313
  gfxIntSize mScaleHint;
317
  gfxIntSize mScaleHint;
314
  gfxImageFormat mOffscreenFormat;
318
  gfxImageFormat mOffscreenFormat;
315
};
319
};
316
320
317
/**
321
/**
 Lines 340-360   BasicImageContainer::CreateImage(const I Link Here 
340
  } else if (FormatInList(aFormats, aNumFormats, Image::PLANAR_YCBCR)) {
344
  } else if (FormatInList(aFormats, aNumFormats, Image::PLANAR_YCBCR)) {
341
    MonitorAutoEnter mon(mMonitor);
345
    MonitorAutoEnter mon(mMonitor);
342
    image = new BasicPlanarYCbCrImage(mScaleHint);
346
    image = new BasicPlanarYCbCrImage(mScaleHint);
343
    static_cast<BasicPlanarYCbCrImage*>(image.get())->SetOffscreenFormat(mOffscreenFormat);
347
    static_cast<BasicPlanarYCbCrImage*>(image.get())->SetOffscreenFormat(mOffscreenFormat);
344
  }
348
  }
345
  return image.forget();
349
  return image.forget();
346
}
350
}
347
351
352
TimeStamp
353
BasicImageContainer::GetPaintTime()
354
{
355
  MonitorAutoEnter mon(mMonitor);
356
  return mPaintTime;
357
}
358
359
PRUint32
360
BasicImageContainer::GetPaintCount()
361
{
362
  MonitorAutoEnter mon(mMonitor);
363
  return mPaintCount;
364
}
365
366
void
367
BasicImageContainer::NotifyPaintedImage(Image* aImage)
368
{
369
  MonitorAutoEnter mon(mMonitor);
370
  RecordPaintStats(aImage, mImage);
371
}
372
348
void
373
void
349
BasicImageContainer::SetCurrentImage(Image* aImage)
374
BasicImageContainer::SetCurrentImage(Image* aImage)
350
{
375
{
351
  MonitorAutoEnter mon(mMonitor);
376
  MonitorAutoEnter mon(mMonitor);
352
  mImage = aImage;
377
  mImage = aImage;
378
  CurrentImageChanged();
353
}
379
}
354
380
355
already_AddRefed<Image>
381
already_AddRefed<Image>
356
BasicImageContainer::GetCurrentImage()
382
BasicImageContainer::GetCurrentImage()
357
{
383
{
358
  MonitorAutoEnter mon(mMonitor);
384
  MonitorAutoEnter mon(mMonitor);
359
  nsRefPtr<Image> image = mImage;
385
  nsRefPtr<Image> image = mImage;
360
  return image.forget();
386
  return image.forget();
(-)a/gfx/layers/basic/BasicLayers.cpp (-1 / +6 lines)
Line     Link Here 
 Lines 728-743   BasicImageLayer::Paint(gfxContext* aCont Link Here 
728
728
729
already_AddRefed<gfxPattern>
729
already_AddRefed<gfxPattern>
730
BasicImageLayer::GetAndPaintCurrentImage(gfxContext* aContext,
730
BasicImageLayer::GetAndPaintCurrentImage(gfxContext* aContext,
731
                                         float aOpacity)
731
                                         float aOpacity)
732
{
732
{
733
  if (!mContainer)
733
  if (!mContainer)
734
    return nsnull;
734
    return nsnull;
735
735
736
  nsRefPtr<Image> image = mContainer->GetCurrentImage();
737
736
  nsRefPtr<gfxASurface> surface = mContainer->GetCurrentAsSurface(&mSize);
738
  nsRefPtr<gfxASurface> surface = mContainer->GetCurrentAsSurface(&mSize);
737
  if (!surface) {
739
  if (!surface) {
738
    return nsnull;
740
    return nsnull;
739
  }
741
  }
740
742
741
  nsRefPtr<gfxPattern> pat = new gfxPattern(surface);
743
  nsRefPtr<gfxPattern> pat = new gfxPattern(surface);
742
  if (!pat) {
744
  if (!pat) {
743
    return nsnull;
745
    return nsnull;
 Lines 747-763   BasicImageLayer::GetAndPaintCurrentImage Link Here 
747
749
748
  // The visible region can extend outside the image.  If we're not
750
  // The visible region can extend outside the image.  If we're not
749
  // tiling, we don't want to draw into that area, so just draw within
751
  // tiling, we don't want to draw into that area, so just draw within
750
  // the image bounds.
752
  // the image bounds.
751
  const nsIntRect* tileSrcRect = GetTileSourceRect();
753
  const nsIntRect* tileSrcRect = GetTileSourceRect();
752
  PaintContext(pat,
754
  PaintContext(pat,
753
               tileSrcRect ? GetVisibleRegion() : nsIntRegion(nsIntRect(0, 0, mSize.width, mSize.height)),
755
               tileSrcRect ? GetVisibleRegion() : nsIntRegion(nsIntRect(0, 0, mSize.width, mSize.height)),
754
               tileSrcRect,
756
               tileSrcRect,
755
               aOpacity, aContext); 
757
               aOpacity, aContext);
758
759
  GetContainer()->NotifyPaintedImage(image);
760
756
  return pat.forget();
761
  return pat.forget();
757
}
762
}
758
763
759
/*static*/ void
764
/*static*/ void
760
BasicImageLayer::PaintContext(gfxPattern* aPattern,
765
BasicImageLayer::PaintContext(gfxPattern* aPattern,
761
                              const nsIntRegion& aVisible,
766
                              const nsIntRegion& aVisible,
762
                              const nsIntRect* aTileSourceRect,
767
                              const nsIntRect* aTileSourceRect,
763
                              float aOpacity,
768
                              float aOpacity,
(-)a/gfx/layers/d3d10/ImageLayerD3D10.cpp (-1 / +22 lines)
Line     Link Here 
 Lines 120-137   ImageContainerD3D10::CreateImage(const I Link Here 
120
  }
120
  }
121
  return img.forget();
121
  return img.forget();
122
}
122
}
123
123
124
void
124
void
125
ImageContainerD3D10::SetCurrentImage(Image *aImage)
125
ImageContainerD3D10::SetCurrentImage(Image *aImage)
126
{
126
{
127
  MutexAutoLock lock(mActiveImageLock);
127
  MutexAutoLock lock(mActiveImageLock);
128
  
129
  mActiveImage = aImage;
130
  CurrentImageChanged();
131
}
128
132
129
  mActiveImage = aImage;
133
TimeStamp ImageContainerD3D10::GetPaintTime() {
134
  MutexAutoLock lock(mActiveImageLock);
135
136
  return mPaintTime;
137
}
138
139
PRUint32 ImageContainerD3D10::GetPaintCount() {
140
  MutexAutoLock lock(mActiveImageLock);
141
142
  return mPaintCount;
143
}
144
145
void ImageContainerD3D10::NotifyPaintedImage(Image* aImage) {
146
  MutexAutoLock lock(mActiveImageLock);
147
148
  RecordPaintStats(aImage, mActiveImage);
130
}
149
}
131
150
132
already_AddRefed<Image>
151
already_AddRefed<Image>
133
ImageContainerD3D10::GetCurrentImage()
152
ImageContainerD3D10::GetCurrentImage()
134
{
153
{
135
  MutexAutoLock lock(mActiveImageLock);
154
  MutexAutoLock lock(mActiveImageLock);
136
155
137
  nsRefPtr<Image> retval = mActiveImage;
156
  nsRefPtr<Image> retval = mActiveImage;
 Lines 349-364   ImageLayerD3D10::RenderLayer() Link Here 
349
        (float)0,
368
        (float)0,
350
        (float)yuvImage->mSize.width,
369
        (float)yuvImage->mSize.width,
351
        (float)yuvImage->mSize.height)
370
        (float)yuvImage->mSize.height)
352
      );
371
      );
353
  }
372
  }
354
373
355
  technique->GetPassByIndex(0)->Apply(0);
374
  technique->GetPassByIndex(0)->Apply(0);
356
  device()->Draw(4, 0);
375
  device()->Draw(4, 0);
376
377
  GetContainer()->NotifyPaintedImage(image);
357
}
378
}
358
379
359
PlanarYCbCrImageD3D10::PlanarYCbCrImageD3D10(ID3D10Device1 *aDevice)
380
PlanarYCbCrImageD3D10::PlanarYCbCrImageD3D10(ID3D10Device1 *aDevice)
360
  : PlanarYCbCrImage(static_cast<ImageD3D10*>(this))
381
  : PlanarYCbCrImage(static_cast<ImageD3D10*>(this))
361
  , mDevice(aDevice)
382
  , mDevice(aDevice)
362
  , mHasData(PR_FALSE)
383
  , mHasData(PR_FALSE)
363
{
384
{
364
}
385
}
(-)a/gfx/layers/d3d10/ImageLayerD3D10.h (+4 lines)
Line     Link Here 
 Lines 65-80   public: Link Here 
65
65
66
  virtual PRBool SetLayerManager(LayerManager *aManager);
66
  virtual PRBool SetLayerManager(LayerManager *aManager);
67
67
68
  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_D3D10; }
68
  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_D3D10; }
69
69
70
  ID3D10Device1 *device() { return mDevice; }
70
  ID3D10Device1 *device() { return mDevice; }
71
  void SetDevice(ID3D10Device1 *aDevice) { mDevice = aDevice; }
71
  void SetDevice(ID3D10Device1 *aDevice) { mDevice = aDevice; }
72
72
73
  TimeStamp GetPaintTime();
74
  PRUint32 GetPaintCount();
75
  void NotifyPaintedImage(Image* aImage);
76
73
private:
77
private:
74
  typedef mozilla::Mutex Mutex;
78
  typedef mozilla::Mutex Mutex;
75
79
76
  nsRefPtr<Image> mActiveImage;
80
  nsRefPtr<Image> mActiveImage;
77
  nsRefPtr<ID3D10Device1> mDevice;
81
  nsRefPtr<ID3D10Device1> mDevice;
78
82
79
  Mutex mActiveImageLock;
83
  Mutex mActiveImageLock;
80
};
84
};
(-)a/gfx/layers/d3d9/ImageLayerD3D9.cpp (+27 lines)
Line     Link Here 
 Lines 151-172   ImageContainerD3D9::CreateImage(const Im Link Here 
151
  if (aFormats[0] == Image::PLANAR_YCBCR) {
151
  if (aFormats[0] == Image::PLANAR_YCBCR) {
152
    img = new PlanarYCbCrImageD3D9();
152
    img = new PlanarYCbCrImageD3D9();
153
  } else if (aFormats[0] == Image::CAIRO_SURFACE) {
153
  } else if (aFormats[0] == Image::CAIRO_SURFACE) {
154
    img = new CairoImageD3D9(mDevice);
154
    img = new CairoImageD3D9(mDevice);
155
  }
155
  }
156
  return img.forget();
156
  return img.forget();
157
}
157
}
158
158
159
TimeStamp
160
ImageContainerD3D9::GetPaintTime()
161
{
162
  MutexAutoLock lock(mActiveImageLock);
163
164
  return mPaintTime;
165
}
166
167
PRUint32
168
ImageContainerD3D9::GetPaintCount()
169
{
170
  MutexAutoLock lock(mActiveImageLock);
171
172
  return mPaintCount;
173
}
174
175
void
176
ImageContainerD3D9::NotifyPaintedImage(Image* aImage)
177
{
178
  MutexAutoLock lock(mActiveImageLock);
179
180
  RecordPaintStats(aImage, mActiveImage);
181
}
182
159
void
183
void
160
ImageContainerD3D9::SetCurrentImage(Image *aImage)
184
ImageContainerD3D9::SetCurrentImage(Image *aImage)
161
{
185
{
162
  MutexAutoLock lock(mActiveImageLock);
186
  MutexAutoLock lock(mActiveImageLock);
163
187
164
  mActiveImage = aImage;
188
  mActiveImage = aImage;
189
  CurrentImageChanged();
165
}
190
}
166
191
167
already_AddRefed<Image>
192
already_AddRefed<Image>
168
ImageContainerD3D9::GetCurrentImage()
193
ImageContainerD3D9::GetCurrentImage()
169
{
194
{
170
  MutexAutoLock lock(mActiveImageLock);
195
  MutexAutoLock lock(mActiveImageLock);
171
196
172
  nsRefPtr<Image> retval = mActiveImage;
197
  nsRefPtr<Image> retval = mActiveImage;
 Lines 370-385   ImageLayerD3D9::RenderLayer() Link Here 
370
    }
395
    }
371
    device()->SetTexture(0, cairoImage->GetOrCreateTexture());
396
    device()->SetTexture(0, cairoImage->GetOrCreateTexture());
372
    device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
397
    device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
373
    if (mFilter == gfxPattern::FILTER_NEAREST) {
398
    if (mFilter == gfxPattern::FILTER_NEAREST) {
374
      device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
399
      device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
375
      device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
400
      device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
376
    }
401
    }
377
  }
402
  }
403
404
  GetContainer()->NotifyPaintedImage(image);
378
}
405
}
379
406
380
PlanarYCbCrImageD3D9::PlanarYCbCrImageD3D9()
407
PlanarYCbCrImageD3D9::PlanarYCbCrImageD3D9()
381
  : PlanarYCbCrImage(static_cast<ImageD3D9*>(this))
408
  : PlanarYCbCrImage(static_cast<ImageD3D9*>(this))
382
  , mHasData(PR_FALSE)
409
  , mHasData(PR_FALSE)
383
{
410
{
384
}
411
}
385
412
(-)a/gfx/layers/d3d9/ImageLayerD3D9.h (+4 lines)
Line     Link Here 
 Lines 65-80   public: Link Here 
65
65
66
  virtual PRBool SetLayerManager(LayerManager *aManager);
66
  virtual PRBool SetLayerManager(LayerManager *aManager);
67
67
68
  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_D3D9; }
68
  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_D3D9; }
69
69
70
  IDirect3DDevice9 *device() { return mDevice; }
70
  IDirect3DDevice9 *device() { return mDevice; }
71
  void SetDevice(IDirect3DDevice9 *aDevice) { mDevice = aDevice; }
71
  void SetDevice(IDirect3DDevice9 *aDevice) { mDevice = aDevice; }
72
72
73
  TimeStamp GetPaintTime();
74
  PRUint32 GetPaintCount();
75
  void NotifyPaintedImage(Image* aImage);
76
73
private:
77
private:
74
  typedef mozilla::Mutex Mutex;
78
  typedef mozilla::Mutex Mutex;
75
79
76
  nsRefPtr<Image> mActiveImage;
80
  nsRefPtr<Image> mActiveImage;
77
81
78
  nsRefPtr<IDirect3DDevice9> mDevice;
82
  nsRefPtr<IDirect3DDevice9> mDevice;
79
83
80
  Mutex mActiveImageLock;
84
  Mutex mActiveImageLock;
(-)a/gfx/layers/opengl/ImageLayerOGL.cpp (+26 lines)
Line     Link Here 
 Lines 223-248   ImageContainerOGL::CreateImage(const Ima Link Here 
223
  else if (aFormats[0] == Image::MAC_IO_SURFACE) {
223
  else if (aFormats[0] == Image::MAC_IO_SURFACE) {
224
    img = new MacIOSurfaceImageOGL(static_cast<LayerManagerOGL*>(mManager));
224
    img = new MacIOSurfaceImageOGL(static_cast<LayerManagerOGL*>(mManager));
225
  }
225
  }
226
#endif
226
#endif
227
227
228
  return img.forget();
228
  return img.forget();
229
}
229
}
230
230
231
TimeStamp
232
ImageContainerOGL::GetPaintTime()
233
{
234
  MutexAutoLock lock(mActiveImageLock);
235
236
  return mPaintTime;
237
}
238
239
PRUint32
240
ImageContainerOGL::GetPaintCount()
241
{
242
  MutexAutoLock lock(mActiveImageLock);
243
244
  return mPaintCount;
245
}
246
247
void
248
ImageContainerOGL::NotifyPaintedImage(Image* aImage)
249
{
250
  MutexAutoLock lock(mActiveImageLock);
251
252
  RecordPaintStats(aImage, mActiveImage);
253
}
254
231
void
255
void
232
ImageContainerOGL::SetCurrentImage(Image *aImage)
256
ImageContainerOGL::SetCurrentImage(Image *aImage)
233
{
257
{
234
  nsRefPtr<Image> oldImage;
258
  nsRefPtr<Image> oldImage;
235
259
236
  {
260
  {
237
    MutexAutoLock lock(mActiveImageLock);
261
    MutexAutoLock lock(mActiveImageLock);
238
262
239
    oldImage = mActiveImage.forget();
263
    oldImage = mActiveImage.forget();
240
    mActiveImage = aImage;
264
    mActiveImage = aImage;
265
    CurrentImageChanged();
241
  }
266
  }
242
267
243
  // Make sure oldImage is released outside the lock, so it can take our
268
  // Make sure oldImage is released outside the lock, so it can take our
244
  // lock in RecycleBuffer
269
  // lock in RecycleBuffer
245
}
270
}
246
271
247
already_AddRefed<Image>
272
already_AddRefed<Image>
248
ImageContainerOGL::GetCurrentImage()
273
ImageContainerOGL::GetCurrentImage()
 Lines 496-511   ImageLayerOGL::RenderLayer(int, Link Here 
496
     program->SetLayerOpacity(GetEffectiveOpacity());
521
     program->SetLayerOpacity(GetEffectiveOpacity());
497
     program->SetRenderOffset(aOffset);
522
     program->SetRenderOffset(aOffset);
498
     program->SetTextureUnit(0);
523
     program->SetTextureUnit(0);
499
    
524
    
500
     mOGLManager->BindAndDrawQuad(program);
525
     mOGLManager->BindAndDrawQuad(program);
501
     gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0);
526
     gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0);
502
#endif
527
#endif
503
  }
528
  }
529
  GetContainer()->NotifyPaintedImage(image);
504
}
530
}
505
531
506
static void
532
static void
507
InitTexture(GLContext* aGL, GLuint aTexture, GLenum aFormat, const gfxIntSize& aSize)
533
InitTexture(GLContext* aGL, GLuint aTexture, GLenum aFormat, const gfxIntSize& aSize)
508
{
534
{
509
  aGL->fBindTexture(LOCAL_GL_TEXTURE_2D, aTexture);
535
  aGL->fBindTexture(LOCAL_GL_TEXTURE_2D, aTexture);
510
  aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
536
  aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
511
  aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
537
  aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
(-)a/gfx/layers/opengl/ImageLayerOGL.h (+4 lines)
Line     Link Here 
 Lines 153-168   public: Link Here 
153
  virtual already_AddRefed<gfxASurface> GetCurrentAsSurface(gfxIntSize* aSize);
153
  virtual already_AddRefed<gfxASurface> GetCurrentAsSurface(gfxIntSize* aSize);
154
154
155
  virtual gfxIntSize GetCurrentSize();
155
  virtual gfxIntSize GetCurrentSize();
156
156
157
  virtual PRBool SetLayerManager(LayerManager *aManager);
157
  virtual PRBool SetLayerManager(LayerManager *aManager);
158
158
159
  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_OPENGL; }
159
  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_OPENGL; }
160
160
161
  TimeStamp GetPaintTime();
162
  PRUint32 GetPaintCount();
163
  void NotifyPaintedImage(Image* aImage);
164
161
private:
165
private:
162
  typedef mozilla::Mutex Mutex;
166
  typedef mozilla::Mutex Mutex;
163
167
164
  nsRefPtr<RecycleBin> mRecycleBin;
168
  nsRefPtr<RecycleBin> mRecycleBin;
165
169
166
  // This protects mActiveImage
170
  // This protects mActiveImage
167
  Mutex mActiveImageLock;
171
  Mutex mActiveImageLock;
168
172

Return to bug 580531