Bug 884226 - Add 'willReadFrequently' getContext() option for 2D canvas r=ehsan,gwright

This commit is contained in:
James Willcox 2013-12-20 15:50:48 -06:00
Родитель c3a2373a4b
Коммит d1bcdbce0b
3 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -1055,6 +1055,26 @@ CanvasRenderingContext2D::Render(gfxContext *ctx, GraphicsFilter aFilter, uint32
return rv;
}
NS_IMETHODIMP
CanvasRenderingContext2D::SetContextOptions(JSContext* aCx, JS::Handle<JS::Value> aOptions)
{
if (aOptions.isNullOrUndefined()) {
return NS_OK;
}
ContextAttributes2D attributes;
NS_ENSURE_TRUE(attributes.Init(aCx, aOptions), NS_ERROR_UNEXPECTED);
#ifdef USE_SKIA_GPU
if (Preferences::GetBool("gfx.canvas.willReadFrequently.enable", false)) {
// Use software when there is going to be a lot of readback
mForceSoftware = attributes.mWillReadFrequently;
}
#endif
return NS_OK;
}
void
CanvasRenderingContext2D::GetImageBuffer(uint8_t** aImageBuffer,
int32_t* aFormat)

Просмотреть файл

@ -413,6 +413,7 @@ public:
// this rect is in canvas device space
void Redraw(const mozilla::gfx::Rect &r);
NS_IMETHOD Redraw(const gfxRect &r) MOZ_OVERRIDE { Redraw(ToRect(r)); return NS_OK; }
NS_IMETHOD SetContextOptions(JSContext* aCx, JS::Handle<JS::Value> aOptions) MOZ_OVERRIDE;
// this rect is in mTarget's current user space
void RedrawUser(const gfxRect &r);

Просмотреть файл

@ -15,6 +15,11 @@ interface HitRegionOptions;
enum CanvasWindingRule { "nonzero", "evenodd" };
dictionary ContextAttributes2D {
// whether or not we're planning to do a lot of readback operations
boolean willReadFrequently = false;
};
interface CanvasRenderingContext2D {
// back-reference to the canvas. Might be null if we're not