Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h

Issue 2420203002: Implement convertToBlob() in OffscreenCanvas (Closed)
Patch Set: rename function name Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h
diff --git a/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h b/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h
index 178a267f26468c7b492235b1cf632cfe44d4cc1a..d5689df24149ded6badcbd48636c0f43723d331e 100644
--- a/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h
+++ b/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "core/CoreExport.h"
#include "core/dom/DOMTypedArray.h"
#include "core/fileapi/BlobCallback.h"
@@ -28,9 +29,9 @@ class CORE_EXPORT CanvasAsyncBlobCreator
const IntSize&,
BlobCallback*,
double,
- Document&);
- void scheduleAsyncBlobCreation(bool canUseIdlePeriodScheduling,
- const double& quality = 0.0);
+ Document*,
+ ScriptPromiseResolver*);
+ void scheduleAsyncBlobCreation(const double& quality);
virtual ~CanvasAsyncBlobCreator();
enum MimeType {
MimeTypePng,
@@ -50,6 +51,13 @@ class CORE_EXPORT CanvasAsyncBlobCreator
// types
IdleTaskCount, // Should not be seen in production
};
+
+ enum ToBlobFunctionType {
+ HTMLCanvasToBlobCallback,
+ OffscreenCanvasToBlobPromise,
+ NumberOfToBlobFunctionTypes
+ };
+
// Methods are virtual for mocking in unit tests
virtual void signalTaskSwitchInStartTimeoutEventForTesting() {}
virtual void signalTaskSwitchInCompleteTimeoutEventForTesting() {}
@@ -62,7 +70,8 @@ class CORE_EXPORT CanvasAsyncBlobCreator
const IntSize&,
BlobCallback*,
double,
- Document&);
+ Document*,
+ ScriptPromiseResolver*);
// Methods are virtual for unit testing
virtual void scheduleInitiatePngEncoding();
virtual void scheduleInitiateJpegEncoding(const double&);
@@ -72,8 +81,8 @@ class CORE_EXPORT CanvasAsyncBlobCreator
std::unique_ptr<WTF::Closure>,
double delayMs);
virtual void signalAlternativeCodePathFinishedForTesting() {}
- virtual void createBlobAndInvokeCallback();
- virtual void createNullAndInvokeCallback();
+ virtual void createBlobAndReturnResult();
+ virtual void createNullAndReturnResult();
void initiatePngEncoding(double deadlineSeconds);
void initiateJpegEncoding(const double& quality, double deadlineSeconds);
@@ -94,12 +103,19 @@ class CORE_EXPORT CanvasAsyncBlobCreator
const IntSize m_size;
size_t m_pixelRowStride;
const MimeType m_mimeType;
- Member<BlobCallback> m_callback;
double m_startTime;
double m_scheduleInitiateStartTime;
double m_elapsedTime;
+
+ ToBlobFunctionType m_functionType;
Justin Novosad 2016/10/19 19:59:33 This additional state is not necessary, you could
xlai (Olivia) 2016/10/20 15:58:54 I think this additional state is necessary for the
+
+ // Used for HTMLCanvasElement only
+ Member<BlobCallback> m_callback;
Member<ParentFrameTaskRunners> m_parentFrameTaskRunner;
+ // Used for OffscreenCanvas only
+ Member<ScriptPromiseResolver> m_scriptPromiseResolver;
+
// PNG
bool initializePngStruct();
void

Powered by Google App Engine
This is Rietveld 408576698