Mercurial > hg > CommitWatcher
comparison tests/4e1a3919e741.diff @ 12:a0ff003319ec
foo
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 28 Sep 2013 06:40:25 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:546695da018c | 12:a0ff003319ec |
---|---|
1 | |
2 # HG changeset patch | |
3 # User Nicholas Cameron <ncameron@mozilla.com> | |
4 # Date 1380242239 -43200 | |
5 # Node ID 4e1a3919e741eb8e3a4f520535671df9711b5b9b | |
6 # Parent a11f8859f7d84ed1a7ab3596c9242074a8a4dc35 | |
7 Bug 882113. Azurification of compositor classes. r=mattwoodrow | |
8 | |
9 diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp | |
10 --- a/gfx/gl/GLContext.cpp | |
11 +++ b/gfx/gl/GLContext.cpp | |
12 @@ -2080,16 +2080,33 @@ GetActualReadFormats(GLContext* gl, GLen | |
13 void | |
14 GLContext::ReadScreenIntoImageSurface(gfxImageSurface* dest) | |
15 { | |
16 ScopedBindFramebuffer autoFB(this, 0); | |
17 | |
18 ReadPixelsIntoImageSurface(dest); | |
19 } | |
20 | |
21 +TemporaryRef<SourceSurface> | |
22 +GLContext::ReadPixelsToSourceSurface(const gfx::IntSize &aSize) | |
23 +{ | |
24 + // XXX we should do this properly one day without using the gfxImageSurface | |
25 + RefPtr<DataSourceSurface> dataSourceSurface = | |
26 + Factory::CreateDataSourceSurface(aSize, gfx::FORMAT_B8G8R8A8); | |
27 + nsRefPtr<gfxImageSurface> surf = | |
28 + new gfxImageSurface(dataSourceSurface->GetData(), | |
29 + gfxIntSize(aSize.width, aSize.height), | |
30 + dataSourceSurface->Stride(), | |
31 + gfxImageFormatARGB32); | |
32 + ReadPixelsIntoImageSurface(surf); | |
33 + dataSourceSurface->MarkDirty(); | |
34 + | |
35 + return dataSourceSurface; | |
36 +} | |
37 + | |
38 void | |
39 GLContext::ReadPixelsIntoImageSurface(gfxImageSurface* dest) | |
40 { | |
41 MakeCurrent(); | |
42 MOZ_ASSERT(dest->GetSize() != gfxIntSize(0, 0)); | |
43 | |
44 /* gfxImageFormatARGB32: | |
45 * RGBA+UByte: be[RGBA], le[ABGR] | |
46 diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h | |
47 --- a/gfx/gl/GLContext.h | |
48 +++ b/gfx/gl/GLContext.h | |
49 @@ -47,16 +47,17 @@ class nsIThread; | |
50 | |
51 namespace android { | |
52 class GraphicBuffer; | |
53 } | |
54 | |
55 namespace mozilla { | |
56 namespace gfx { | |
57 class SharedSurface; | |
58 + class SourceSurface; | |
59 class DataSourceSurface; | |
60 struct SurfaceCaps; | |
61 } | |
62 | |
63 namespace gl { | |
64 class GLContext; | |
65 class GLLibraryEGL; | |
66 class GLScreenBuffer; | |
67 @@ -2696,16 +2697,18 @@ public: | |
68 * ReadScreenIntoImageSurface call dest->Flush/MarkDirty. | |
69 */ | |
70 void ReadPixelsIntoImageSurface(gfxImageSurface* dest); | |
71 | |
72 // Similar to ReadPixelsIntoImageSurface, but pulls from the screen | |
73 // instead of the currently bound framebuffer. | |
74 void ReadScreenIntoImageSurface(gfxImageSurface* dest); | |
75 | |
76 + TemporaryRef<gfx::SourceSurface> ReadPixelsToSourceSurface(const gfx::IntSize &aSize); | |
77 + | |
78 /** | |
79 * Copy a rectangle from one TextureImage into another. The | |
80 * source and destination are given in integer coordinates, and | |
81 * will be converted to texture coordinates. | |
82 * | |
83 * For the source texture, the wrap modes DO apply -- it's valid | |
84 * to use REPEAT or PAD and expect appropriate behaviour if the source | |
85 * rectangle extends beyond its bounds. | |
86 diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h | |
87 --- a/gfx/layers/Compositor.h | |
88 +++ b/gfx/layers/Compositor.h | |
89 @@ -2,17 +2,16 @@ | |
90 * This Source Code Form is subject to the terms of the Mozilla Public | |
91 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
92 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
93 | |
94 #ifndef MOZILLA_GFX_COMPOSITOR_H | |
95 #define MOZILLA_GFX_COMPOSITOR_H | |
96 | |
97 #include "Units.h" // for ScreenPoint | |
98 -#include "gfxPoint.h" // for gfxIntSize | |
99 #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc | |
100 #include "mozilla/RefPtr.h" // for TemporaryRef, RefCounted | |
101 #include "mozilla/gfx/Point.h" // for IntSize, Point | |
102 #include "mozilla/gfx/Rect.h" // for Rect, IntRect | |
103 #include "mozilla/gfx/Types.h" // for Float | |
104 #include "mozilla/layers/CompositorTypes.h" // for DiagnosticTypes, etc | |
105 #include "mozilla/layers/LayersTypes.h" // for LayersBackend | |
106 #include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc | |
107 @@ -97,24 +96,24 @@ | |
108 * under gfx/layers/. To add a new backend, implement at least the following | |
109 * interfaces: | |
110 * - Compositor (ex. CompositorOGL) | |
111 * - TextureHost (ex. SharedTextureHostOGL) | |
112 * Depending on the type of data that needs to be serialized, you may need to | |
113 * add specific TextureClient implementations. | |
114 */ | |
115 | |
116 -class gfxContext; | |
117 class nsIWidget; | |
118 struct gfxMatrix; | |
119 struct nsIntSize; | |
120 | |
121 namespace mozilla { | |
122 namespace gfx { | |
123 class Matrix4x4; | |
124 +class DrawTarget; | |
125 } | |
126 | |
127 namespace layers { | |
128 | |
129 struct Effect; | |
130 struct EffectChain; | |
131 class Image; | |
132 class ISurfaceAllocator; | |
133 @@ -205,27 +204,27 @@ public: | |
134 * across process or thread boundaries that are compatible with this | |
135 * compositor. | |
136 */ | |
137 virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() = 0; | |
138 | |
139 /** | |
140 * Properties of the compositor. | |
141 */ | |
142 - virtual bool CanUseCanvasLayerForSize(const gfxIntSize& aSize) = 0; | |
143 + virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) = 0; | |
144 virtual int32_t GetMaxTextureSize() const = 0; | |
145 | |
146 /** | |
147 * Set the target for rendering. Results will have been written to aTarget by | |
148 * the time that EndFrame returns. | |
149 * | |
150 * If this method is not used, or we pass in nullptr, we target the compositor's | |
151 * usual swap chain and render to the screen. | |
152 */ | |
153 - virtual void SetTargetContext(gfxContext* aTarget) = 0; | |
154 + virtual void SetTargetContext(gfx::DrawTarget* aTarget) = 0; | |
155 | |
156 typedef uint32_t MakeCurrentFlags; | |
157 static const MakeCurrentFlags ForceMakeCurrent = 0x1; | |
158 /** | |
159 * Make this compositor's rendering context the current context for the | |
160 * underlying graphics API. This may be a global operation, depending on the | |
161 * API. Our context will remain the current one until someone else changes it. | |
162 * | |
163 diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp | |
164 --- a/gfx/layers/Layers.cpp | |
165 +++ b/gfx/layers/Layers.cpp | |
166 @@ -1166,19 +1166,20 @@ void WriteSnapshotToDumpFile(Layer* aLay | |
167 WriteSnapshotToDumpFile_internal(aLayer, aSurf); | |
168 } | |
169 | |
170 void WriteSnapshotToDumpFile(LayerManager* aManager, gfxASurface* aSurf) | |
171 { | |
172 WriteSnapshotToDumpFile_internal(aManager, aSurf); | |
173 } | |
174 | |
175 -void WriteSnapshotToDumpFile(Compositor* aCompositor, gfxASurface* aSurf) | |
176 +void WriteSnapshotToDumpFile(Compositor* aCompositor, DrawTarget* aTarget) | |
177 { | |
178 - WriteSnapshotToDumpFile_internal(aCompositor, aSurf); | |
179 + nsRefPtr<gfxASurface> surf = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(aTarget); | |
180 + WriteSnapshotToDumpFile_internal(aCompositor, surf); | |
181 } | |
182 #endif | |
183 | |
184 void | |
185 Layer::Dump(FILE* aFile, const char* aPrefix, bool aDumpHtml) | |
186 { | |
187 if (aDumpHtml) { | |
188 fprintf(aFile, "<li><a id=\"%p\" ", this); | |
189 diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h | |
190 --- a/gfx/layers/Layers.h | |
191 +++ b/gfx/layers/Layers.h | |
192 @@ -1955,15 +1955,15 @@ protected: | |
193 Layer* mTempReferent; | |
194 // 0 is a special value that means "no ID". | |
195 uint64_t mId; | |
196 }; | |
197 | |
198 #ifdef MOZ_DUMP_PAINTING | |
199 void WriteSnapshotToDumpFile(Layer* aLayer, gfxASurface* aSurf); | |
200 void WriteSnapshotToDumpFile(LayerManager* aManager, gfxASurface* aSurf); | |
201 -void WriteSnapshotToDumpFile(Compositor* aCompositor, gfxASurface* aSurf); | |
202 +void WriteSnapshotToDumpFile(Compositor* aCompositor, gfx::DrawTarget* aTarget); | |
203 #endif | |
204 | |
205 } | |
206 } | |
207 | |
208 #endif /* GFX_LAYERS_H */ | |
209 diff --git a/gfx/layers/basic/BasicCompositor.cpp b/gfx/layers/basic/BasicCompositor.cpp | |
210 --- a/gfx/layers/basic/BasicCompositor.cpp | |
211 +++ b/gfx/layers/basic/BasicCompositor.cpp | |
212 @@ -464,30 +464,27 @@ BasicCompositor::BeginFrame(const gfx::R | |
213 } | |
214 } | |
215 | |
216 void | |
217 BasicCompositor::EndFrame() | |
218 { | |
219 mRenderTarget->mDrawTarget->PopClip(); | |
220 | |
221 + RefPtr<SourceSurface> source = mRenderTarget->mDrawTarget->Snapshot(); | |
222 if (mCopyTarget) { | |
223 - nsRefPtr<gfxASurface> thebes = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mRenderTarget->mDrawTarget); | |
224 - gfxContextAutoSaveRestore restore(mCopyTarget); | |
225 - mCopyTarget->SetOperator(gfxContext::OPERATOR_SOURCE); | |
226 - mCopyTarget->SetSource(thebes); | |
227 - mCopyTarget->Paint(); | |
228 - mCopyTarget = nullptr; | |
229 + mCopyTarget->CopySurface(source, | |
230 + IntRect(0, 0, mWidgetSize.width, mWidgetSize.height), | |
231 + IntPoint(0, 0)); | |
232 } else { | |
233 // Most platforms require us to buffer drawing to the widget surface. | |
234 // That's why we don't draw to mDrawTarget directly. | |
235 - RefPtr<SourceSurface> source = mRenderTarget->mDrawTarget->Snapshot(); | |
236 mDrawTarget->CopySurface(source, | |
237 - IntRect(0, 0, mWidgetSize.width, mWidgetSize.height), | |
238 - IntPoint(0, 0)); | |
239 + IntRect(0, 0, mWidgetSize.width, mWidgetSize.height), | |
240 + IntPoint(0, 0)); | |
241 mWidget->EndRemoteDrawing(); | |
242 } | |
243 mDrawTarget = nullptr; | |
244 mRenderTarget = nullptr; | |
245 } | |
246 | |
247 void | |
248 BasicCompositor::AbortFrame() | |
249 diff --git a/gfx/layers/basic/BasicCompositor.h b/gfx/layers/basic/BasicCompositor.h | |
250 --- a/gfx/layers/basic/BasicCompositor.h | |
251 +++ b/gfx/layers/basic/BasicCompositor.h | |
252 @@ -89,20 +89,20 @@ public: | |
253 virtual void EndFrame() MOZ_OVERRIDE; | |
254 virtual void EndFrameForExternalComposition(const gfxMatrix& aTransform) MOZ_OVERRIDE | |
255 { | |
256 NS_RUNTIMEABORT("We shouldn't ever hit this"); | |
257 } | |
258 virtual void AbortFrame() MOZ_OVERRIDE; | |
259 | |
260 virtual bool SupportsPartialTextureUpdate() { return true; } | |
261 - virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) MOZ_OVERRIDE { return true; } | |
262 + virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE { return true; } | |
263 virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE { return INT32_MAX; } | |
264 virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) MOZ_OVERRIDE { } | |
265 - virtual void SetTargetContext(gfxContext* aTarget) MOZ_OVERRIDE | |
266 + virtual void SetTargetContext(gfx::DrawTarget* aTarget) MOZ_OVERRIDE | |
267 { | |
268 mCopyTarget = aTarget; | |
269 } | |
270 | |
271 virtual void SetScreenRenderOffset(const ScreenPoint& aOffset) MOZ_OVERRIDE { | |
272 } | |
273 | |
274 virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) { } | |
275 @@ -128,15 +128,15 @@ private: | |
276 nsIntSize mWidgetSize; | |
277 | |
278 // The final destination surface | |
279 RefPtr<gfx::DrawTarget> mDrawTarget; | |
280 // The current render target for drawing | |
281 RefPtr<BasicCompositingRenderTarget> mRenderTarget; | |
282 // An optional destination target to copy the results | |
283 // to after drawing is completed. | |
284 - nsRefPtr<gfxContext> mCopyTarget; | |
285 + RefPtr<gfx::DrawTarget> mCopyTarget; | |
286 }; | |
287 | |
288 } // namespace layers | |
289 } // namespace mozilla | |
290 | |
291 #endif /* MOZILLA_GFX_BASICCOMPOSITOR_H */ | |
292 diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp | |
293 --- a/gfx/layers/composite/LayerManagerComposite.cpp | |
294 +++ b/gfx/layers/composite/LayerManagerComposite.cpp | |
295 @@ -143,17 +143,17 @@ LayerManagerComposite::UpdateRenderBound | |
296 | |
297 void | |
298 LayerManagerComposite::BeginTransaction() | |
299 { | |
300 mInTransaction = true; | |
301 } | |
302 | |
303 void | |
304 -LayerManagerComposite::BeginTransactionWithTarget(gfxContext *aTarget) | |
305 +LayerManagerComposite::BeginTransactionWithDrawTarget(DrawTarget* aTarget) | |
306 { | |
307 mInTransaction = true; | |
308 | |
309 #ifdef MOZ_LAYERS_HAVE_LOG | |
310 MOZ_LAYERS_LOG(("[----- BeginTransaction")); | |
311 Log(); | |
312 #endif | |
313 | |
314 @@ -757,17 +757,18 @@ void | |
315 LayerManagerComposite::NotifyShadowTreeTransaction() | |
316 { | |
317 mCompositor->NotifyLayersTransaction(); | |
318 } | |
319 | |
320 bool | |
321 LayerManagerComposite::CanUseCanvasLayerForSize(const gfxIntSize &aSize) | |
322 { | |
323 - return mCompositor->CanUseCanvasLayerForSize(aSize); | |
324 + return mCompositor->CanUseCanvasLayerForSize(gfx::IntSize(aSize.width, | |
325 + aSize.height)); | |
326 } | |
327 | |
328 TextureFactoryIdentifier | |
329 LayerManagerComposite::GetTextureFactoryIdentifier() | |
330 { | |
331 return mCompositor->GetTextureFactoryIdentifier(); | |
332 } | |
333 | |
334 diff --git a/gfx/layers/composite/LayerManagerComposite.h b/gfx/layers/composite/LayerManagerComposite.h | |
335 --- a/gfx/layers/composite/LayerManagerComposite.h | |
336 +++ b/gfx/layers/composite/LayerManagerComposite.h | |
337 @@ -97,18 +97,22 @@ public: | |
338 */ | |
339 virtual LayerManagerComposite* AsLayerManagerComposite() MOZ_OVERRIDE | |
340 { | |
341 return this; | |
342 } | |
343 | |
344 void UpdateRenderBounds(const nsIntRect& aRect); | |
345 | |
346 - void BeginTransaction() MOZ_OVERRIDE; | |
347 - void BeginTransactionWithTarget(gfxContext* aTarget) MOZ_OVERRIDE; | |
348 + virtual void BeginTransaction() MOZ_OVERRIDE; | |
349 + virtual void BeginTransactionWithTarget(gfxContext* aTarget) MOZ_OVERRIDE | |
350 + { | |
351 + MOZ_CRASH("Use BeginTransactionWithDrawTarget"); | |
352 + } | |
353 + void BeginTransactionWithDrawTarget(gfx::DrawTarget* aTarget); | |
354 | |
355 void NotifyShadowTreeTransaction(); | |
356 | |
357 virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) MOZ_OVERRIDE; | |
358 virtual void EndTransaction(DrawThebesLayerCallback aCallback, | |
359 void* aCallbackData, | |
360 EndTransactionFlags aFlags = END_DEFAULT) MOZ_OVERRIDE; | |
361 | |
362 diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp | |
363 --- a/gfx/layers/d3d11/CompositorD3D11.cpp | |
364 +++ b/gfx/layers/d3d11/CompositorD3D11.cpp | |
365 @@ -344,17 +344,17 @@ CompositorD3D11::GetTextureFactoryIdenti | |
366 TextureFactoryIdentifier ident; | |
367 ident.mMaxTextureSize = GetMaxTextureSize(); | |
368 ident.mParentProcessId = XRE_GetProcessType(); | |
369 ident.mParentBackend = LAYERS_D3D11; | |
370 return ident; | |
371 } | |
372 | |
373 bool | |
374 -CompositorD3D11::CanUseCanvasLayerForSize(const gfxIntSize& aSize) | |
375 +CompositorD3D11::CanUseCanvasLayerForSize(const gfx::IntSize& aSize) | |
376 { | |
377 int32_t maxTextureSize = GetMaxTextureSize(); | |
378 | |
379 if (aSize.width > maxTextureSize || aSize.height > maxTextureSize) { | |
380 return false; | |
381 } | |
382 | |
383 return true; | |
384 @@ -903,23 +903,23 @@ CompositorD3D11::PaintToTarget() | |
385 nsRefPtr<ID3D11Texture2D> readTexture; | |
386 | |
387 HRESULT hr = mDevice->CreateTexture2D(&softDesc, nullptr, getter_AddRefs(readTexture)); | |
388 mContext->CopyResource(readTexture, backBuf); | |
389 | |
390 D3D11_MAPPED_SUBRESOURCE map; | |
391 mContext->Map(readTexture, 0, D3D11_MAP_READ, 0, &map); | |
392 | |
393 - nsRefPtr<gfxImageSurface> tmpSurface = | |
394 - new gfxImageSurface((unsigned char*)map.pData, | |
395 - gfxIntSize(bbDesc.Width, bbDesc.Height), | |
396 - map.RowPitch, | |
397 - gfxImageFormatARGB32); | |
398 - | |
399 - mTarget->SetSource(tmpSurface); | |
400 - mTarget->SetOperator(gfxContext::OPERATOR_SOURCE); | |
401 - mTarget->Paint(); | |
402 - | |
403 + destSurf->LockRect(&rect, NULL, D3DLOCK_READONLY); | |
404 + RefPtr<DataSourceSurface> sourceSurface = | |
405 + Factory::CreateWrappingDataSourceSurface((uint8_t*)map.pData, | |
406 + map.RowPitch, | |
407 + IntSize(bbDesc.Width, bbDesc.Height), | |
408 + FORMAT_B8G8R8A8); | |
409 + mTarget->CopySurface(sourceSurface, | |
410 + IntRect(0, 0, bbDesc.Width, bbDesc.Height), | |
411 + IntPoint()); | |
412 + mTarget->Flush(); | |
413 mContext->Unmap(readTexture, 0); | |
414 } | |
415 | |
416 } | |
417 } | |
418 diff --git a/gfx/layers/d3d11/CompositorD3D11.h b/gfx/layers/d3d11/CompositorD3D11.h | |
419 --- a/gfx/layers/d3d11/CompositorD3D11.h | |
420 +++ b/gfx/layers/d3d11/CompositorD3D11.h | |
421 @@ -1,16 +1,17 @@ | |
422 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- | |
423 * This Source Code Form is subject to the terms of the Mozilla Public | |
424 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
425 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
426 | |
427 #ifndef MOZILLA_GFX_COMPOSITORD3D11_H | |
428 #define MOZILLA_GFX_COMPOSITORD3D11_H | |
429 | |
430 +#include "mozilla/gfx/2D.h" | |
431 #include "mozilla/layers/Compositor.h" | |
432 #include "TextureD3D11.h" | |
433 #include <d3d11.h> | |
434 | |
435 class nsWidget; | |
436 | |
437 namespace mozilla { | |
438 namespace layers { | |
439 @@ -45,20 +46,20 @@ public: | |
440 virtual void Destroy() MOZ_OVERRIDE {} | |
441 | |
442 virtual TextureFactoryIdentifier | |
443 GetTextureFactoryIdentifier() MOZ_OVERRIDE; | |
444 | |
445 virtual TemporaryRef<DataTextureSource> | |
446 CreateDataTextureSource(TextureFlags aFlags = 0) MOZ_OVERRIDE { return nullptr; } | |
447 | |
448 - virtual bool CanUseCanvasLayerForSize(const gfxIntSize& aSize) MOZ_OVERRIDE; | |
449 + virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) MOZ_OVERRIDE; | |
450 virtual int32_t GetMaxTextureSize() const MOZ_FINAL; | |
451 | |
452 - virtual void SetTargetContext(gfxContext* aTarget) MOZ_OVERRIDE | |
453 + virtual void SetTargetContext(gfx::DrawTarget* aTarget) MOZ_OVERRIDE | |
454 { | |
455 mTarget = aTarget; | |
456 } | |
457 | |
458 virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) MOZ_OVERRIDE {} | |
459 | |
460 virtual TemporaryRef<CompositingRenderTarget> | |
461 CreateRenderTarget(const gfx::IntRect &aRect, | |
462 @@ -162,17 +163,17 @@ private: | |
463 RefPtr<ID3D11DeviceContext> mContext; | |
464 RefPtr<ID3D11Device> mDevice; | |
465 RefPtr<IDXGISwapChain> mSwapChain; | |
466 RefPtr<CompositingRenderTargetD3D11> mDefaultRT; | |
467 RefPtr<CompositingRenderTargetD3D11> mCurrentRT; | |
468 | |
469 DeviceAttachmentsD3D11* mAttachments; | |
470 | |
471 - nsRefPtr<gfxContext> mTarget; | |
472 + RefPtr<gfx::DrawTarget> mTarget; | |
473 | |
474 nsIWidget* mWidget; | |
475 | |
476 nsIntSize mSize; | |
477 | |
478 HWND mHwnd; | |
479 | |
480 D3D_FEATURE_LEVEL mFeatureLevel; | |
481 diff --git a/gfx/layers/d3d9/CompositorD3D9.cpp b/gfx/layers/d3d9/CompositorD3D9.cpp | |
482 --- a/gfx/layers/d3d9/CompositorD3D9.cpp | |
483 +++ b/gfx/layers/d3d9/CompositorD3D9.cpp | |
484 @@ -60,17 +60,17 @@ CompositorD3D9::GetTextureFactoryIdentif | |
485 TextureFactoryIdentifier ident; | |
486 ident.mMaxTextureSize = GetMaxTextureSize(); | |
487 ident.mParentBackend = LAYERS_D3D9; | |
488 ident.mParentProcessId = XRE_GetProcessType(); | |
489 return ident; | |
490 } | |
491 | |
492 bool | |
493 -CompositorD3D9::CanUseCanvasLayerForSize(const gfxIntSize &aSize) | |
494 +CompositorD3D9::CanUseCanvasLayerForSize(const IntSize &aSize) | |
495 { | |
496 int32_t maxTextureSize = GetMaxTextureSize(); | |
497 | |
498 if (aSize.width > maxTextureSize || aSize.height > maxTextureSize) { | |
499 return false; | |
500 } | |
501 | |
502 return true; | |
503 @@ -560,24 +560,25 @@ CompositorD3D9::PaintToTarget() | |
504 device()->CreateOffscreenPlainSurface(desc.Width, desc.Height, | |
505 D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, | |
506 getter_AddRefs(destSurf), NULL); | |
507 | |
508 device()->GetRenderTargetData(backBuff, destSurf); | |
509 | |
510 D3DLOCKED_RECT rect; | |
511 destSurf->LockRect(&rect, NULL, D3DLOCK_READONLY); | |
512 - mTarget->SetOperator(gfxContext::OPERATOR_SOURCE); | |
513 - nsRefPtr<gfxImageSurface> imageSurface = | |
514 - new gfxImageSurface((unsigned char*)rect.pBits, | |
515 - gfxIntSize(desc.Width, desc.Height), | |
516 - rect.Pitch, | |
517 - gfxImageFormatARGB32); | |
518 - mTarget->SetSource(imageSurface); | |
519 - mTarget->Paint(); | |
520 + RefPtr<DataSourceSurface> sourceSurface = | |
521 + Factory::CreateWrappingDataSourceSurface((uint8_t*)rect.pBits, | |
522 + rect.Pitch, | |
523 + IntSize(desc.Width, desc.Height), | |
524 + FORMAT_B8G8R8A8); | |
525 + mTarget->CopySurface(sourceSurface, | |
526 + IntRect(0, 0, desc.Width, desc.Height), | |
527 + IntPoint()); | |
528 + mTarget->Flush(); | |
529 destSurf->UnlockRect(); | |
530 } | |
531 | |
532 void | |
533 CompositorD3D9::ReportFailure(const nsACString &aMsg, HRESULT aCode) | |
534 { | |
535 // We could choose to abort here when hr == E_OUTOFMEMORY. | |
536 nsCString msg; | |
537 diff --git a/gfx/layers/d3d9/CompositorD3D9.h b/gfx/layers/d3d9/CompositorD3D9.h | |
538 --- a/gfx/layers/d3d9/CompositorD3D9.h | |
539 +++ b/gfx/layers/d3d9/CompositorD3D9.h | |
540 @@ -1,16 +1,17 @@ | |
541 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- | |
542 * This Source Code Form is subject to the terms of the Mozilla Public | |
543 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
544 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
545 | |
546 #ifndef MOZILLA_GFX_COMPOSITORD3D9_H | |
547 #define MOZILLA_GFX_COMPOSITORD3D9_H | |
548 | |
549 +#include "mozilla/gfx/2D.h" | |
550 #include "mozilla/layers/Compositor.h" | |
551 #include "mozilla/layers/TextureD3D9.h" | |
552 #include "DeviceManagerD3D9.h" | |
553 | |
554 class nsWidget; | |
555 | |
556 namespace mozilla { | |
557 namespace layers { | |
558 @@ -22,20 +23,20 @@ public: | |
559 ~CompositorD3D9(); | |
560 | |
561 virtual bool Initialize() MOZ_OVERRIDE; | |
562 virtual void Destroy() MOZ_OVERRIDE {} | |
563 | |
564 virtual TextureFactoryIdentifier | |
565 GetTextureFactoryIdentifier() MOZ_OVERRIDE; | |
566 | |
567 - virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) MOZ_OVERRIDE; | |
568 + virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE; | |
569 virtual int32_t GetMaxTextureSize() const MOZ_FINAL; | |
570 | |
571 - virtual void SetTargetContext(gfxContext *aTarget) MOZ_OVERRIDE | |
572 + virtual void SetTargetContext(gfx::DrawTarget *aTarget) MOZ_OVERRIDE | |
573 { | |
574 mTarget = aTarget; | |
575 } | |
576 | |
577 virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) MOZ_OVERRIDE {} | |
578 | |
579 virtual TemporaryRef<CompositingRenderTarget> | |
580 CreateRenderTarget(const gfx::IntRect &aRect, | |
581 @@ -123,17 +124,17 @@ private: | |
582 nsRefPtr<SwapChainD3D9> mSwapChain; | |
583 | |
584 /* Widget associated with this layer manager */ | |
585 nsIWidget *mWidget; | |
586 | |
587 /* | |
588 * Context target, NULL when drawing directly to our swap chain. | |
589 */ | |
590 - nsRefPtr<gfxContext> mTarget; | |
591 + RefPtr<gfx::DrawTarget> mTarget; | |
592 | |
593 RefPtr<CompositingRenderTargetD3D9> mDefaultRT; | |
594 RefPtr<CompositingRenderTargetD3D9> mCurrentRT; | |
595 | |
596 nsIntSize mSize; | |
597 }; | |
598 | |
599 } | |
600 diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp | |
601 --- a/gfx/layers/ipc/CompositorParent.cpp | |
602 +++ b/gfx/layers/ipc/CompositorParent.cpp | |
603 @@ -18,16 +18,17 @@ | |
604 #include "base/task.h" // for CancelableTask, etc | |
605 #include "base/thread.h" // for Thread | |
606 #include "base/tracked.h" // for FROM_HERE | |
607 #include "gfxContext.h" // for gfxContext | |
608 #include "gfxPlatform.h" // for gfxPlatform | |
609 #include "ipc/ShadowLayersManager.h" // for ShadowLayersManager | |
610 #include "mozilla/AutoRestore.h" // for AutoRestore | |
611 #include "mozilla/DebugOnly.h" // for DebugOnly | |
612 +#include "mozilla/gfx/2D.h" // for DrawTarget | |
613 #include "mozilla/gfx/Point.h" // for IntSize | |
614 #include "mozilla/ipc/Transport.h" // for Transport | |
615 #include "mozilla/layers/APZCTreeManager.h" // for APZCTreeManager | |
616 #include "mozilla/layers/AsyncCompositionManager.h" | |
617 #include "mozilla/layers/BasicCompositor.h" // for BasicCompositor | |
618 #include "mozilla/layers/Compositor.h" // for Compositor | |
619 #include "mozilla/layers/CompositorOGL.h" // for CompositorOGL | |
620 #include "mozilla/layers/CompositorTypes.h" | |
621 @@ -47,16 +48,17 @@ | |
622 #include "mozilla/layers/CompositorD3D11.h" | |
623 #include "mozilla/layers/CompositorD3D9.h" | |
624 #endif | |
625 #include "GeckoProfiler.h" | |
626 | |
627 using namespace base; | |
628 using namespace mozilla; | |
629 using namespace mozilla::ipc; | |
630 +using namespace mozilla::gfx; | |
631 using namespace std; | |
632 | |
633 namespace mozilla { | |
634 namespace layers { | |
635 | |
636 CompositorParent::LayerTreeState::LayerTreeState() | |
637 : mParent(nullptr) | |
638 { | |
639 @@ -290,17 +292,23 @@ CompositorParent::RecvResume() | |
640 return true; | |
641 } | |
642 | |
643 bool | |
644 CompositorParent::RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot, | |
645 SurfaceDescriptor* aOutSnapshot) | |
646 { | |
647 AutoOpenSurface opener(OPEN_READ_WRITE, aInSnapshot); | |
648 - nsRefPtr<gfxContext> target = new gfxContext(opener.Get()); | |
649 + gfxIntSize size = opener.Size(); | |
650 + // XXX CreateDrawTargetForSurface will always give us a Cairo surface, we can | |
651 + // do better if AutoOpenSurface uses Moz2D directly. | |
652 + RefPtr<DrawTarget> target = | |
653 + gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(opener.Get(), | |
654 + IntSize(size.width, | |
655 + size.height)); | |
656 ComposeToTarget(target); | |
657 *aOutSnapshot = aInSnapshot; | |
658 return true; | |
659 } | |
660 | |
661 bool | |
662 CompositorParent::RecvFlushRendering() | |
663 { | |
664 @@ -536,26 +544,26 @@ CompositorParent::Composite() | |
665 if (mExpectedComposeTime + TimeDuration::FromMilliseconds(15) < TimeStamp::Now()) { | |
666 printf_stderr("Compositor: Composite took %i ms.\n", | |
667 15 + (int)(TimeStamp::Now() - mExpectedComposeTime).ToMilliseconds()); | |
668 } | |
669 #endif | |
670 } | |
671 | |
672 void | |
673 -CompositorParent::ComposeToTarget(gfxContext* aTarget) | |
674 +CompositorParent::ComposeToTarget(DrawTarget* aTarget) | |
675 { | |
676 PROFILER_LABEL("CompositorParent", "ComposeToTarget"); | |
677 AutoRestore<bool> override(mOverrideComposeReadiness); | |
678 mOverrideComposeReadiness = true; | |
679 | |
680 if (!CanComposite()) { | |
681 return; | |
682 } | |
683 - mLayerManager->BeginTransactionWithTarget(aTarget); | |
684 + mLayerManager->BeginTransactionWithDrawTarget(aTarget); | |
685 // Since CanComposite() is true, Composite() must end the layers txn | |
686 // we opened above. | |
687 Composite(); | |
688 } | |
689 | |
690 bool | |
691 CompositorParent::CanComposite() | |
692 { | |
693 diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h | |
694 --- a/gfx/layers/ipc/CompositorParent.h | |
695 +++ b/gfx/layers/ipc/CompositorParent.h | |
696 @@ -34,16 +34,20 @@ | |
697 #include "nsSize.h" // for nsIntSize | |
698 | |
699 class CancelableTask; | |
700 class MessageLoop; | |
701 class gfxContext; | |
702 class nsIWidget; | |
703 | |
704 namespace mozilla { | |
705 +namespace gfx { | |
706 +class DrawTarget; | |
707 +} | |
708 + | |
709 namespace layers { | |
710 | |
711 class APZCTreeManager; | |
712 class AsyncCompositionManager; | |
713 class LayerManagerComposite; | |
714 class LayerTransactionParent; | |
715 | |
716 struct ScopedLayerTreeRegistration | |
717 @@ -216,17 +220,17 @@ protected: | |
718 virtual PLayerTransactionParent* | |
719 AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints, | |
720 const uint64_t& aId, | |
721 TextureFactoryIdentifier* aTextureFactoryIdentifier, | |
722 bool* aSuccess); | |
723 virtual bool DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers); | |
724 virtual void ScheduleTask(CancelableTask*, int); | |
725 virtual void Composite(); | |
726 - virtual void ComposeToTarget(gfxContext* aTarget); | |
727 + virtual void ComposeToTarget(gfx::DrawTarget* aTarget); | |
728 | |
729 void SetEGLSurfaceSize(int width, int height); | |
730 | |
731 private: | |
732 void InitializeLayerManager(const nsTArray<LayersBackend>& aBackendHints); | |
733 void PauseComposition(); | |
734 void ResumeComposition(); | |
735 void ResumeCompositionAndResize(int width, int height); | |
736 diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp | |
737 --- a/gfx/layers/ipc/LayerTransactionParent.cpp | |
738 +++ b/gfx/layers/ipc/LayerTransactionParent.cpp | |
739 @@ -195,17 +195,17 @@ LayerTransactionParent::RecvUpdate(const | |
740 MOZ_LAYERS_LOG(("[ParentSide] received txn with %d edits", cset.Length())); | |
741 | |
742 if (mDestroyed || !layer_manager() || layer_manager()->IsDestroyed()) { | |
743 return true; | |
744 } | |
745 | |
746 EditReplyVector replyv; | |
747 | |
748 - layer_manager()->BeginTransactionWithTarget(nullptr); | |
749 + layer_manager()->BeginTransactionWithDrawTarget(nullptr); | |
750 | |
751 for (EditArray::index_type i = 0; i < cset.Length(); ++i) { | |
752 const Edit& edit = cset[i]; | |
753 | |
754 switch (edit.type()) { | |
755 // Create* ops | |
756 case Edit::TOpCreateThebesLayer: { | |
757 MOZ_LAYERS_LOG(("[ParentSide] CreateThebesLayer")); | |
758 diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp | |
759 --- a/gfx/layers/opengl/CompositorOGL.cpp | |
760 +++ b/gfx/layers/opengl/CompositorOGL.cpp | |
761 @@ -1256,21 +1256,20 @@ CompositorOGL::EndFrame() | |
762 #ifdef MOZ_DUMP_PAINTING | |
763 if (gfxUtils::sDumpPainting) { | |
764 nsIntRect rect; | |
765 if (mUseExternalSurfaceSize) { | |
766 rect = nsIntRect(0, 0, mSurfaceSize.width, mSurfaceSize.height); | |
767 } else { | |
768 mWidget->GetBounds(rect); | |
769 } | |
770 - nsRefPtr<gfxASurface> surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(rect.Size(), GFX_CONTENT_COLOR_ALPHA); | |
771 - nsRefPtr<gfxContext> ctx = new gfxContext(surf); | |
772 - CopyToTarget(ctx, mCurrentRenderTarget->GetTransform()); | |
773 + RefPtr<DrawTarget> target = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(rect.width, rect.height), FORMAT_B8G8R8A8); | |
774 + CopyToTarget(target, mCurrentRenderTarget->GetTransform()); | |
775 | |
776 - WriteSnapshotToDumpFile(this, surf); | |
777 + WriteSnapshotToDumpFile(this, target); | |
778 } | |
779 #endif | |
780 | |
781 mFrameInProgress = false; | |
782 | |
783 if (mTarget) { | |
784 CopyToTarget(mTarget, mCurrentRenderTarget->GetTransform()); | |
785 mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0); | |
786 @@ -1330,60 +1329,55 @@ CompositorOGL::AbortFrame() | |
787 void | |
788 CompositorOGL::SetDestinationSurfaceSize(const gfx::IntSize& aSize) | |
789 { | |
790 mSurfaceSize.width = aSize.width; | |
791 mSurfaceSize.height = aSize.height; | |
792 } | |
793 | |
794 void | |
795 -CompositorOGL::CopyToTarget(gfxContext *aTarget, const gfxMatrix& aTransform) | |
796 +CompositorOGL::CopyToTarget(DrawTarget *aTarget, const gfxMatrix& aTransform) | |
797 { | |
798 - nsIntRect rect; | |
799 + IntRect rect; | |
800 if (mUseExternalSurfaceSize) { | |
801 - rect = nsIntRect(0, 0, mSurfaceSize.width, mSurfaceSize.height); | |
802 + rect = IntRect(0, 0, mSurfaceSize.width, mSurfaceSize.height); | |
803 } else { | |
804 - rect = nsIntRect(0, 0, mWidgetSize.width, mWidgetSize.height); | |
805 + rect = IntRect(0, 0, mWidgetSize.width, mWidgetSize.height); | |
806 } | |
807 GLint width = rect.width; | |
808 GLint height = rect.height; | |
809 | |
810 if ((int64_t(width) * int64_t(height) * int64_t(4)) > PR_INT32_MAX) { | |
811 NS_ERROR("Widget size too big - integer overflow!"); | |
812 return; | |
813 } | |
814 | |
815 - nsRefPtr<gfxImageSurface> imageSurface = | |
816 - new gfxImageSurface(gfxIntSize(width, height), | |
817 - gfxImageFormatARGB32); | |
818 - | |
819 mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0); | |
820 | |
821 if (!mGLContext->IsGLES2()) { | |
822 // GLES2 promises that binding to any custom FBO will attach | |
823 // to GL_COLOR_ATTACHMENT0 attachment point. | |
824 mGLContext->fReadBuffer(LOCAL_GL_BACK); | |
825 } | |
826 | |
827 - NS_ASSERTION(imageSurface->Stride() == width * 4, | |
828 - "Image Surfaces being created with weird stride!"); | |
829 - | |
830 - mGLContext->ReadPixelsIntoImageSurface(imageSurface); | |
831 + RefPtr<SourceSurface> source = | |
832 + mGLContext->ReadPixelsToSourceSurface(IntSize(width, height)); | |
833 | |
834 // Map from GL space to Cairo space and reverse the world transform. | |
835 - gfxMatrix glToCairoTransform = aTransform; | |
836 + Matrix glToCairoTransform = MatrixForThebesMatrix(aTransform); | |
837 glToCairoTransform.Invert(); | |
838 glToCairoTransform.Scale(1.0, -1.0); | |
839 - glToCairoTransform.Translate(-gfxPoint(0.0, height)); | |
840 + glToCairoTransform.Translate(0.0, -height); | |
841 | |
842 - gfxContextAutoSaveRestore restore(aTarget); | |
843 - aTarget->SetOperator(gfxContext::OPERATOR_SOURCE); | |
844 - aTarget->SetMatrix(glToCairoTransform); | |
845 - aTarget->SetSource(imageSurface); | |
846 - aTarget->Paint(); | |
847 + Matrix oldMatrix = aTarget->GetTransform(); | |
848 + aTarget->SetTransform(glToCairoTransform); | |
849 + Rect floatRect = Rect(rect.x, rect.y, rect.width, rect.height); | |
850 + aTarget->DrawSurface(source, floatRect, floatRect, DrawSurfaceOptions(), DrawOptions(1.0f, OP_SOURCE)); | |
851 + aTarget->SetTransform(oldMatrix); | |
852 + aTarget->Flush(); | |
853 } | |
854 | |
855 double | |
856 CompositorOGL::AddFrameAndGetFps(const TimeStamp& timestamp) | |
857 { | |
858 if (sDrawFPS) { | |
859 if (!mFPS) { | |
860 mFPS = new FPSState(); | |
861 diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h | |
862 --- a/gfx/layers/opengl/CompositorOGL.h | |
863 +++ b/gfx/layers/opengl/CompositorOGL.h | |
864 @@ -5,32 +5,30 @@ | |
865 | |
866 #ifndef MOZILLA_GFX_COMPOSITOROGL_H | |
867 #define MOZILLA_GFX_COMPOSITOROGL_H | |
868 | |
869 #include "GLContextTypes.h" // for GLContext, etc | |
870 #include "GLDefs.h" // for GLuint, LOCAL_GL_TEXTURE_2D, etc | |
871 #include "LayerManagerOGLProgram.h" // for ShaderProgramOGL, etc | |
872 #include "Units.h" // for ScreenPoint | |
873 -#include "gfxContext.h" // for gfxContext | |
874 -#include "gfxPoint.h" // for gfxIntSize | |
875 #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc | |
876 #include "mozilla/Attributes.h" // for MOZ_OVERRIDE, MOZ_FINAL | |
877 #include "mozilla/RefPtr.h" // for TemporaryRef, RefPtr | |
878 +#include "mozilla/gfx/2D.h" // for DrawTarget | |
879 #include "mozilla/gfx/BaseSize.h" // for BaseSize | |
880 #include "mozilla/gfx/Point.h" // for IntSize, Point | |
881 #include "mozilla/gfx/Rect.h" // for Rect, IntRect | |
882 #include "mozilla/gfx/Types.h" // for Float, SurfaceFormat, etc | |
883 #include "mozilla/layers/Compositor.h" // for SurfaceInitMode, Compositor, etc | |
884 #include "mozilla/layers/CompositorTypes.h" // for MaskType::NumMaskTypes, etc | |
885 #include "mozilla/layers/LayersTypes.h" | |
886 #include "nsAutoPtr.h" // for nsRefPtr, nsAutoPtr | |
887 #include "nsCOMPtr.h" // for already_AddRefed | |
888 #include "nsDebug.h" // for NS_ASSERTION, NS_WARNING | |
889 -#include "nsISupportsImpl.h" // for gfxContext::AddRef, etc | |
890 #include "nsSize.h" // for nsIntSize | |
891 #include "nsTArray.h" // for nsAutoTArray, nsTArray, etc | |
892 #include "nsThreadUtils.h" // for nsRunnable | |
893 #include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc | |
894 #include "nsXULAppAPI.h" // for XRE_GetProcessType | |
895 #include "nscore.h" // for NS_IMETHOD | |
896 #include "VBOArena.h" // for gl::VBOArena | |
897 | |
898 @@ -101,39 +99,39 @@ public: | |
899 const gfx::Point& aOffset) MOZ_OVERRIDE; | |
900 | |
901 virtual void EndFrame() MOZ_OVERRIDE; | |
902 virtual void EndFrameForExternalComposition(const gfxMatrix& aTransform) MOZ_OVERRIDE; | |
903 virtual void AbortFrame() MOZ_OVERRIDE; | |
904 | |
905 virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE; | |
906 | |
907 - virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) MOZ_OVERRIDE | |
908 + virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE | |
909 { | |
910 if (!mGLContext) | |
911 return false; | |
912 int32_t maxSize = GetMaxTextureSize(); | |
913 - return aSize <= gfxIntSize(maxSize, maxSize); | |
914 + return aSize <= gfx::IntSize(maxSize, maxSize); | |
915 } | |
916 | |
917 virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE; | |
918 | |
919 /** | |
920 * Set the size of the EGL surface we're rendering to, if we're rendering to | |
921 * an EGL surface. | |
922 */ | |
923 virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) MOZ_OVERRIDE; | |
924 | |
925 virtual void SetScreenRenderOffset(const ScreenPoint& aOffset) MOZ_OVERRIDE { | |
926 mRenderOffset = aOffset; | |
927 } | |
928 | |
929 virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) MOZ_OVERRIDE; | |
930 | |
931 - virtual void SetTargetContext(gfxContext* aTarget) MOZ_OVERRIDE | |
932 + virtual void SetTargetContext(gfx::DrawTarget* aTarget) MOZ_OVERRIDE | |
933 { | |
934 mTarget = aTarget; | |
935 } | |
936 | |
937 virtual void PrepareViewport(const gfx::IntSize& aSize, | |
938 const gfxMatrix& aWorldTransform) MOZ_OVERRIDE; | |
939 | |
940 | |
941 @@ -166,17 +164,17 @@ public: | |
942 * Doing so lets us use gralloc the way it has been designed to be used | |
943 * (see https://wiki.mozilla.org/Platform/GFX/Gralloc) | |
944 */ | |
945 GLuint GetTemporaryTexture(GLenum aUnit); | |
946 private: | |
947 /** | |
948 * Context target, nullptr when drawing directly to our swap chain. | |
949 */ | |
950 - nsRefPtr<gfxContext> mTarget; | |
951 + RefPtr<gfx::DrawTarget> mTarget; | |
952 | |
953 /** Widget associated with this compositor */ | |
954 nsIWidget *mWidget; | |
955 nsIntSize mWidgetSize; | |
956 nsRefPtr<GLContext> mGLContext; | |
957 | |
958 /** The size of the surface we are rendering to */ | |
959 nsIntSize mSurfaceSize; | |
960 @@ -295,17 +293,17 @@ private: | |
961 TextureSource *aTexture); | |
962 | |
963 void CleanupResources(); | |
964 | |
965 /** | |
966 * Copies the content of our backbuffer to the set transaction target. | |
967 * Does not restore the target FBO, so only call from EndFrame. | |
968 */ | |
969 - void CopyToTarget(gfxContext *aTarget, const gfxMatrix& aWorldMatrix); | |
970 + void CopyToTarget(gfx::DrawTarget* aTarget, const gfxMatrix& aWorldMatrix); | |
971 | |
972 /** | |
973 * Records the passed frame timestamp and returns the current estimated FPS. | |
974 */ | |
975 double AddFrameAndGetFps(const TimeStamp& timestamp); | |
976 | |
977 bool mDestroyed; | |
978 | |
979 diff --git a/gfx/thebes/gfx2DGlue.h b/gfx/thebes/gfx2DGlue.h | |
980 --- a/gfx/thebes/gfx2DGlue.h | |
981 +++ b/gfx/thebes/gfx2DGlue.h | |
982 @@ -194,16 +194,22 @@ inline JoinStyle ToJoinStyle(gfxContext: | |
983 } | |
984 | |
985 inline gfxMatrix ThebesMatrix(const Matrix &aMatrix) | |
986 { | |
987 return gfxMatrix(aMatrix._11, aMatrix._12, aMatrix._21, | |
988 aMatrix._22, aMatrix._31, aMatrix._32); | |
989 } | |
990 | |
991 +inline Matrix MatrixForThebesMatrix(const gfxMatrix &aMatrix) | |
992 +{ | |
993 + return Matrix(aMatrix.xx, aMatrix.yx, aMatrix.xy, | |
994 + aMatrix.yy, aMatrix.x0, aMatrix.y0); | |
995 +} | |
996 + | |
997 inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat) | |
998 { | |
999 switch (aFormat) { | |
1000 case FORMAT_B8G8R8A8: | |
1001 return gfxImageFormatARGB32; | |
1002 case FORMAT_B8G8R8X8: | |
1003 return gfxImageFormatRGB24; | |
1004 case FORMAT_R5G6B5: | |
1005 |