Attachment #516105: Patch: add paint time to Images for bug #580531

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

(-)a/gfx/layers/ImageLayers.h (-3 / +59 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 105-142   public: Link Here 
105
     * It wraps an IOSurface object and binds it directly to a GL texture.
106
     * It wraps an IOSurface object and binds it directly to a GL texture.
106
     */
107
     */
107
    MAC_IO_SURFACE
108
    MAC_IO_SURFACE
108
  };
109
  };
109
110
110
  Format GetFormat() { return mFormat; }
111
  Format GetFormat() { return mFormat; }
111
  void* GetImplData() { return mImplData; }
112
  void* GetImplData() { return mImplData; }
112
113
114
  /**
115
   * Return PR_TRUE if this image has been painted at least once.
116
   * Call on main thread only.
117
   */
118
  PRBool HasBeenPainted() const {
119
    NS_PRECONDITION(NS_IsMainThread(), "Must be called on main thread");
120
    return mPainted;
121
  }
122
123
  /**
124
   * Marks this image as having been painted.
125
   * Call on main thread only.
126
   */
127
  void MarkPainted() {
128
    NS_PRECONDITION(NS_IsMainThread(), "Must be called on main thread");
129
    mPainted = PR_TRUE;
130
  }
131
113
protected:
132
protected:
114
  Image(void* aImplData, Format aFormat) :
133
  Image(void* aImplData, Format aFormat) :
115
    mImplData(aImplData),
134
    mImplData(aImplData),
116
    mFormat(aFormat)
135
    mFormat(aFormat),
136
    mPainted(PR_FALSE)
117
  {}
137
  {}
118
138
119
  void* mImplData;
139
  void* mImplData;
120
  Format mFormat;
140
  Format mFormat;
141
142
  // PR_TRUE if the image has been painted at least once.
143
  // Accessed on main thread only.
144
  PRBool mPainted;
121
};
145
};
122
146
123
/**
147
/**
124
 * A class that manages Images for an ImageLayer. The only reason
148
 * A class that manages Images for an ImageLayer. The only reason
125
 * we need a separate class here is that ImageLayers aren't threadsafe
149
 * we need a separate class here is that ImageLayers aren't threadsafe
126
 * (because layers can only be used on the main thread) and we want to
150
 * (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
151
 * be able to set the current Image from any thread, to facilitate
128
 * video playback without involving the main thread, for example.
152
 * video playback without involving the main thread, for example.
129
 */
153
 */
130
class THEBES_API ImageContainer {
154
class THEBES_API ImageContainer {
131
  THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageContainer)
155
  THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageContainer)
132
156
133
public:
157
public:
134
  ImageContainer() {}
158
  ImageContainer() : mPaintCount(0) {}
135
  virtual ~ImageContainer() {}
159
  virtual ~ImageContainer() {}
136
160
137
  /**
161
  /**
138
   * Create an Image in one of the given formats.
162
   * Create an Image in one of the given formats.
139
   * Picks the "best" format from the list and creates an Image of that
163
   * Picks the "best" format from the list and creates an Image of that
140
   * format.
164
   * format.
141
   * Returns null if this backend does not support any of the formats.
165
   * Returns null if this backend does not support any of the formats.
142
   */
166
   */
 Lines 206-225   public: Link Here 
206
230
207
  /**
231
  /**
208
   * Get the layer manager type this image container was created with,
232
   * 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
233
   * presumably its users might want to do something special if types do not
210
   * match.
234
   * match.
211
   */
235
   */
212
  virtual LayerManager::LayersBackend GetBackendType() = 0;
236
  virtual LayerManager::LayersBackend GetBackendType() = 0;
213
237
238
  /**
239
   * Returns the time at which the currently contained image was first
240
   * painted.  This is reset every time a new image is set as the current
241
   * image.  Note this may return a null timestamp if the current image
242
   * has not yet been painted.  Threadsafe.
243
   */
244
  virtual TimeStamp GetPaintTime() = 0;
245
246
  /**
247
   * Returns the number of images which have been contained in this container
248
   * and painted at least once.  Threadsafe.
249
   */
250
  virtual PRUint32 GetPaintCount() = 0;
251
252
  /**
253
   * Notifies the container that aImage has been painted.  Note we must pass
254
   * in a pointer to the image that has been painted, as the current image
255
   * can change while we're rendering, and in that case we don't want to
256
   * record the paint time of the just painted image as the paint time of the
257
   * current image.  Threadsafe.
258
   */
259
  virtual void NotifyPaintedImage(Image* aImage) = 0;
260
214
protected:
261
protected:
215
  LayerManager* mManager;
262
  LayerManager* mManager;
216
263
217
  ImageContainer(LayerManager* aManager) : mManager(aManager) {}
264
  ImageContainer(LayerManager* aManager) : mManager(aManager), mPaintCount(0) {}
265
266
  // Number of contained images that have been painted at least once.  It's up
267
  // to the ImageContainer implementation to ensure accesses to this are
268
  // threadsafe.
269
  PRUint32 mPaintCount;
270
271
  // Time stamp at which the current image was first painted.  It's up to the
272
  // ImageContainer implementation to ensure accesses to this are threadsafe.
273
  TimeStamp mPaintTime;
218
};
274
};
219
275
220
/**
276
/**
221
 * A Layer which renders an Image.
277
 * A Layer which renders an Image.
222
 */
278
 */
223
class THEBES_API ImageLayer : public Layer {
279
class THEBES_API ImageLayer : public Layer {
224
public:
280
public:
225
  /**
281
  /**
(-)a/gfx/layers/basic/BasicImages.cpp (+29 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-359   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
  mPaintCount++;
371
  if (aImage == mImage) {
372
    mPaintTime = TimeStamp::Now();
373
  }
374
}
375
348
void
376
void
349
BasicImageContainer::SetCurrentImage(Image* aImage)
377
BasicImageContainer::SetCurrentImage(Image* aImage)
350
{
378
{
351
  MonitorAutoEnter mon(mMonitor);
379
  MonitorAutoEnter mon(mMonitor);
380
  mPaintTime = TimeStamp();
352
  mImage = aImage;
381
  mImage = aImage;
353
}
382
}
354
383
355
already_AddRefed<Image>
384
already_AddRefed<Image>
356
BasicImageContainer::GetCurrentImage()
385
BasicImageContainer::GetCurrentImage()
357
{
386
{
358
  MonitorAutoEnter mon(mMonitor);
387
  MonitorAutoEnter mon(mMonitor);
359
  nsRefPtr<Image> image = mImage;
388
  nsRefPtr<Image> image = mImage;
(-)a/gfx/layers/basic/BasicLayers.cpp (-1 / +9 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
  if (!image->HasBeenPainted()) {
760
    image->MarkPainted();
761
    GetContainer()->NotifyPaintedImage(image);
762
  }
763
756
  return pat.forget();
764
  return pat.forget();
757
}
765
}
758
766
759
/*static*/ void
767
/*static*/ void
760
BasicImageLayer::PaintContext(gfxPattern* aPattern,
768
BasicImageLayer::PaintContext(gfxPattern* aPattern,
761
                              const nsIntRegion& aVisible,
769
                              const nsIntRegion& aVisible,
762
                              const nsIntRect* aTileSourceRect,
770
                              const nsIntRect* aTileSourceRect,
763
                              float aOpacity,
771
                              float aOpacity,
(-)a/gfx/layers/d3d10/ImageLayerD3D10.cpp (-1 / +28 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
  mPaintTime = TimeStamp();
130
  mActiveImage = aImage;
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
  mPaintCount++;
149
  if (aImage == mActiveImage) {
150
    mPaintTime = TimeStamp::Now();
151
  }
130
}
152
}
131
153
132
already_AddRefed<Image>
154
already_AddRefed<Image>
133
ImageContainerD3D10::GetCurrentImage()
155
ImageContainerD3D10::GetCurrentImage()
134
{
156
{
135
  MutexAutoLock lock(mActiveImageLock);
157
  MutexAutoLock lock(mActiveImageLock);
136
158
137
  nsRefPtr<Image> retval = mActiveImage;
159
  nsRefPtr<Image> retval = mActiveImage;
 Lines 349-364   ImageLayerD3D10::RenderLayer() Link Here 
349
        (float)0,
371
        (float)0,
350
        (float)yuvImage->mSize.width,
372
        (float)yuvImage->mSize.width,
351
        (float)yuvImage->mSize.height)
373
        (float)yuvImage->mSize.height)
352
      );
374
      );
353
  }
375
  }
354
376
355
  technique->GetPassByIndex(0)->Apply(0);
377
  technique->GetPassByIndex(0)->Apply(0);
356
  device()->Draw(4, 0);
378
  device()->Draw(4, 0);
379
380
  if (!image->HasBeenPainted()) {
381
    image->MarkPainted();
382
    GetContainer()->NotifyPaintedImage(image);
383
  }
357
}
384
}
358
385
359
PlanarYCbCrImageD3D10::PlanarYCbCrImageD3D10(ID3D10Device1 *aDevice)
386
PlanarYCbCrImageD3D10::PlanarYCbCrImageD3D10(ID3D10Device1 *aDevice)
360
  : PlanarYCbCrImage(static_cast<ImageD3D10*>(this))
387
  : PlanarYCbCrImage(static_cast<ImageD3D10*>(this))
361
  , mDevice(aDevice)
388
  , mDevice(aDevice)
362
  , mHasData(PR_FALSE)
389
  , mHasData(PR_FALSE)
363
{
390
{
364
}
391
}
(-)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 (+33 lines)
Line     Link Here 
 Lines 151-171   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
  mPaintCount++;
181
  if (aImage == mActiveImage) {
182
    mPaintTime = TimeStamp::Now();
183
  }
184
}
185
159
void
186
void
160
ImageContainerD3D9::SetCurrentImage(Image *aImage)
187
ImageContainerD3D9::SetCurrentImage(Image *aImage)
161
{
188
{
162
  MutexAutoLock lock(mActiveImageLock);
189
  MutexAutoLock lock(mActiveImageLock);
163
190
191
  mPaintTime = TimeStamp();
164
  mActiveImage = aImage;
192
  mActiveImage = aImage;
165
}
193
}
166
194
167
already_AddRefed<Image>
195
already_AddRefed<Image>
168
ImageContainerD3D9::GetCurrentImage()
196
ImageContainerD3D9::GetCurrentImage()
169
{
197
{
170
  MutexAutoLock lock(mActiveImageLock);
198
  MutexAutoLock lock(mActiveImageLock);
171
199
 Lines 370-385   ImageLayerD3D9::RenderLayer() Link Here 
370
    }
398
    }
371
    device()->SetTexture(0, cairoImage->GetOrCreateTexture());
399
    device()->SetTexture(0, cairoImage->GetOrCreateTexture());
372
    device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
400
    device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
373
    if (mFilter == gfxPattern::FILTER_NEAREST) {
401
    if (mFilter == gfxPattern::FILTER_NEAREST) {
374
      device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
402
      device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
375
      device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
403
      device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
376
    }
404
    }
377
  }
405
  }
406
407
  if (!image->HasBeenPainted()) {
408
    image->MarkPainted();
409
    GetContainer()->NotifyPaintedImage(image);
410
  }
378
}
411
}
379
412
380
PlanarYCbCrImageD3D9::PlanarYCbCrImageD3D9()
413
PlanarYCbCrImageD3D9::PlanarYCbCrImageD3D9()
381
  : PlanarYCbCrImage(static_cast<ImageD3D9*>(this))
414
  : PlanarYCbCrImage(static_cast<ImageD3D9*>(this))
382
  , mHasData(PR_FALSE)
415
  , mHasData(PR_FALSE)
383
{
416
{
384
}
417
}
385
418
(-)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 (+32 lines)
Line     Link Here 
 Lines 223-246   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
  mPaintCount++;
253
  if (aImage == mActiveImage) {
254
    mPaintTime = TimeStamp::Now();
255
  }
256
}
257
231
void
258
void
232
ImageContainerOGL::SetCurrentImage(Image *aImage)
259
ImageContainerOGL::SetCurrentImage(Image *aImage)
233
{
260
{
234
  nsRefPtr<Image> oldImage;
261
  nsRefPtr<Image> oldImage;
235
262
236
  {
263
  {
237
    MutexAutoLock lock(mActiveImageLock);
264
    MutexAutoLock lock(mActiveImageLock);
238
265
266
    mPaintTime = TimeStamp();
239
    oldImage = mActiveImage.forget();
267
    oldImage = mActiveImage.forget();
240
    mActiveImage = aImage;
268
    mActiveImage = aImage;
241
  }
269
  }
242
270
243
  // Make sure oldImage is released outside the lock, so it can take our
271
  // Make sure oldImage is released outside the lock, so it can take our
244
  // lock in RecycleBuffer
272
  // lock in RecycleBuffer
245
}
273
}
246
274
 Lines 496-511   ImageLayerOGL::RenderLayer(int, Link Here 
496
     program->SetLayerOpacity(GetEffectiveOpacity());
524
     program->SetLayerOpacity(GetEffectiveOpacity());
497
     program->SetRenderOffset(aOffset);
525
     program->SetRenderOffset(aOffset);
498
     program->SetTextureUnit(0);
526
     program->SetTextureUnit(0);
499
    
527
    
500
     mOGLManager->BindAndDrawQuad(program);
528
     mOGLManager->BindAndDrawQuad(program);
501
     gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0);
529
     gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0);
502
#endif
530
#endif
503
  }
531
  }
532
  if (!image->HasBeenPainted()) {
533
    image->MarkPainted();
534
    GetContainer()->NotifyPaintedImage(image);
535
  }
504
}
536
}
505
537
506
static void
538
static void
507
InitTexture(GLContext* aGL, GLuint aTexture, GLenum aFormat, const gfxIntSize& aSize)
539
InitTexture(GLContext* aGL, GLuint aTexture, GLenum aFormat, const gfxIntSize& aSize)
508
{
540
{
509
  aGL->fBindTexture(LOCAL_GL_TEXTURE_2D, aTexture);
541
  aGL->fBindTexture(LOCAL_GL_TEXTURE_2D, aTexture);
510
  aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
542
  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);
543
  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