mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1922506: Implement CanvasRenderingContext2D::GetDebugInfo. r=tjr,jgilbert,webidl,smaug
For our data collection efforts, we want to be able to tell whether a canvas we are reading is HW accelerated or not. For that reason, we want to implement CanvasRenderingContext2D::GetDebugInfo. We are only really interested in isAccelerated property, but added 3 other properties that might be useful in the future, or for other developers. Differential Revision: https://phabricator.services.mozilla.com/D224495
This commit is contained in:
parent
e9139dadbc
commit
425bb904d8
@ -1128,6 +1128,30 @@ void CanvasRenderingContext2D::GetContextAttributes(
|
||||
// those just keep their default values.
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::GetDebugInfo(
|
||||
bool aEnsureTarget, CanvasRenderingContext2DDebugInfo& aDebugInfo,
|
||||
ErrorResult& aError) {
|
||||
if (aEnsureTarget && !EnsureTarget(aError)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mBufferProvider) {
|
||||
aError.ThrowInvalidStateError("No buffer provider available");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mTarget) {
|
||||
aError.ThrowInvalidStateError("No target available");
|
||||
return;
|
||||
}
|
||||
|
||||
aDebugInfo = CanvasRenderingContext2DDebugInfo();
|
||||
aDebugInfo.mIsAccelerated = mBufferProvider->IsAccelerated();
|
||||
aDebugInfo.mIsShared = mBufferProvider->IsShared();
|
||||
aDebugInfo.mBackendType = static_cast<int8_t>(mTarget->GetBackendType());
|
||||
aDebugInfo.mDrawTargetType = static_cast<int8_t>(mTarget->GetType());
|
||||
}
|
||||
|
||||
CanvasRenderingContext2D::ColorStyleCacheEntry
|
||||
CanvasRenderingContext2D::ParseColorSlow(const nsACString& aString) {
|
||||
ColorStyleCacheEntry result{nsCString(aString)};
|
||||
|
@ -99,6 +99,10 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal,
|
||||
|
||||
void GetContextAttributes(CanvasRenderingContext2DSettings& aSettings) const;
|
||||
|
||||
void GetDebugInfo(bool aEnsureTarget,
|
||||
CanvasRenderingContext2DDebugInfo& aDebugInfo,
|
||||
ErrorResult& aError);
|
||||
|
||||
void OnMemoryPressure() override;
|
||||
void OnBeforePaintTransaction() override;
|
||||
void OnDidPaintTransaction() override;
|
||||
|
@ -35,10 +35,21 @@ dictionary CanvasRenderingContext2DSettings {
|
||||
// whether or not we're planning to do a lot of readback operations
|
||||
boolean willReadFrequently = false;
|
||||
|
||||
[Func="nsRFPService::IsSoftwareRenderingOptionExposed"]
|
||||
[Func="nsRFPService::IsSystemPrincipalOrAboutFingerprintingProtection"]
|
||||
boolean forceSoftwareRendering = false;
|
||||
};
|
||||
|
||||
[GenerateInit]
|
||||
dictionary CanvasRenderingContext2DDebugInfo {
|
||||
required boolean isAccelerated;
|
||||
|
||||
required boolean isShared;
|
||||
|
||||
required byte backendType;
|
||||
|
||||
required byte drawTargetType;
|
||||
};
|
||||
|
||||
dictionary HitRegionOptions {
|
||||
Path2D? path = null;
|
||||
DOMString id = "";
|
||||
@ -64,6 +75,9 @@ interface CanvasRenderingContext2D {
|
||||
|
||||
CanvasRenderingContext2DSettings getContextAttributes();
|
||||
|
||||
[Throws, Func="nsRFPService::IsSystemPrincipalOrAboutFingerprintingProtection"]
|
||||
CanvasRenderingContext2DDebugInfo getDebugInfo(optional boolean ensureTarget = false);
|
||||
|
||||
// Show the caret if appropriate when drawing
|
||||
[Func="CanvasUtils::HasDrawWindowPrivilege"]
|
||||
const unsigned long DRAWWINDOW_DRAW_CARET = 0x01;
|
||||
|
@ -53,7 +53,7 @@ dictionary WebGLContextAttributes {
|
||||
GLboolean failIfMajorPerformanceCaveat = false;
|
||||
WebGLPowerPreference powerPreference = "default";
|
||||
|
||||
[Func="nsRFPService::IsSoftwareRenderingOptionExposed"]
|
||||
[Func="nsRFPService::IsSystemPrincipalOrAboutFingerprintingProtection"]
|
||||
GLboolean forceSoftwareRendering = false;
|
||||
};
|
||||
|
||||
|
@ -1919,8 +1919,8 @@ bool nsRFPService::CheckSuspiciousFingerprintingActivity(
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool nsRFPService::IsSoftwareRenderingOptionExposed(JSContext* aCx,
|
||||
JSObject* aObj) {
|
||||
bool nsRFPService::IsSystemPrincipalOrAboutFingerprintingProtection(
|
||||
JSContext* aCx, JSObject* aObj) {
|
||||
if (!NS_IsMainThread()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -223,7 +223,8 @@ class nsRFPService final : public nsIObserver, public nsIRFPService {
|
||||
bool aIsPrivateMode, RFPTarget aTarget,
|
||||
const Maybe<RFPTarget>& aOverriddenFingerprintingSettings);
|
||||
|
||||
static bool IsSoftwareRenderingOptionExposed(JSContext*, JSObject*);
|
||||
static bool IsSystemPrincipalOrAboutFingerprintingProtection(JSContext*,
|
||||
JSObject*);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
static double TimerResolution(RTPCallerType aRTPCallerType);
|
||||
|
Loading…
Reference in New Issue
Block a user