fix heap-buffer-overflow by not returning string from reportBackendType
Change-Id: I2dbced29f9d43454e35e3ff9fbbb97d11fef29a2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303623 Reviewed-by: Kevin Lubick <kjlubick@google.com> Commit-Queue: Nathaniel Nifong <nifong@google.com>
This commit is contained in:
parent
f4e5737825
commit
2d7afd4824
@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
The fastest choice for gradients is the flat Float32Array, the fastest choice for drawAtlas and
|
||||
MakeSkVertices is the flat Uint32Array.
|
||||
- Color arrays may also be objects created with CanvasKit.Malloc
|
||||
- renamed `reportBackendType` to `reportBackendTypeIsGPU` and made it return a boolean
|
||||
|
||||
### Fixed
|
||||
- `TextStyle.color` can correctly be a Malloc'd Float32Array.
|
||||
|
@ -1637,16 +1637,16 @@ EMSCRIPTEN_BINDINGS(Skia) {
|
||||
return self.makeSurface(toSkImageInfo(sii));
|
||||
}), allow_raw_pointers())
|
||||
#ifdef SK_GL
|
||||
.function("reportBackendType", optional_override([](SkSurface& self)->std::string {
|
||||
return self.getCanvas()->getGrContext() == nullptr ? "CPU" : "GPU";
|
||||
.function("reportBackendTypeIsGPU", optional_override([](SkSurface& self) -> bool {
|
||||
return self.getCanvas()->getGrContext() != nullptr;
|
||||
}))
|
||||
.function("sampleCnt", optional_override([](SkSurface& self)->int {
|
||||
auto backendRT = self.getBackendRenderTarget(SkSurface::kFlushRead_BackendHandleAccess);
|
||||
return (backendRT.isValid()) ? backendRT.sampleCnt() : 0;
|
||||
}))
|
||||
#else
|
||||
.function("reportBackendType", optional_override([](SkSurface& self)->std::string {
|
||||
return "CPU";
|
||||
.function("reportBackendTypeIsGPU", optional_override([](SkSurface& self) -> bool {
|
||||
return false;
|
||||
}))
|
||||
#endif
|
||||
.function("width", &SkSurface::width);
|
||||
|
@ -551,7 +551,7 @@ var CanvasKit = {
|
||||
makeImageSnapshot: function() {},
|
||||
makeSurface: function() {},
|
||||
sampleCnt: function() {},
|
||||
reportBackendType: function() {},
|
||||
reportBackendTypeIsGPU: function() {},
|
||||
grContext: {},
|
||||
|
||||
// private API
|
||||
|
@ -846,7 +846,7 @@ describe('Core canvas behavior', () => {
|
||||
const colorSpace = CanvasKit.SkColorSpace.DISPLAY_P3;
|
||||
const surface = CanvasKit.MakeCanvasSurface('test', CanvasKit.SkColorSpace.DISPLAY_P3);
|
||||
expect(surface).toBeTruthy('Could not make surface');
|
||||
if (surface.reportBackendType() !== 'GPU') {
|
||||
if (!surface.reportBackendTypeIsGPU()) {
|
||||
console.log('Not expecting color space support in cpu backed suface.');
|
||||
return;
|
||||
}
|
||||
@ -864,7 +864,7 @@ describe('Core canvas behavior', () => {
|
||||
const colorSpace = CanvasKit.SkColorSpace.ADOBE_RGB;
|
||||
const surface = CanvasKit.MakeCanvasSurface('test', CanvasKit.SkColorSpace.ADOBE_RGB);
|
||||
expect(surface).toBeTruthy('Could not make surface');
|
||||
if (surface.reportBackendType() !== 'GPU') {
|
||||
if (!surface.reportBackendTypeIsGPU()) {
|
||||
console.log('Not expecting color space support in cpu backed suface.');
|
||||
return;
|
||||
}
|
||||
@ -882,7 +882,7 @@ describe('Core canvas behavior', () => {
|
||||
it('combine draws from several color spaces', () => {
|
||||
const surface = CanvasKit.MakeCanvasSurface('test', CanvasKit.SkColorSpace.ADOBE_RGB);
|
||||
expect(surface).toBeTruthy('Could not make surface');
|
||||
if (surface.reportBackendType() !== 'GPU') {
|
||||
if (!surface.reportBackendTypeIsGPU()) {
|
||||
console.log('Not expecting color space support in cpu backed suface.');
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user