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

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

Issue 2878333004: Use SkJpegEncoder in WebKit platform (Closed)
Patch Set: Created 3 years, 7 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 b4fbe72e483b3d46712ae1bfb8ddc043c47de667..c88bf4fd0397c4457da794a416026f5d828fe31e 100644
--- a/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h
+++ b/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h
@@ -16,12 +16,11 @@
#include "platform/wtf/Vector.h"
#include "platform/wtf/text/WTFString.h"
#include "public/platform/WebTraceLocation.h"
+#include "third_party/skia/include/encode/SkEncoder.h"
namespace blink {
class Document;
-class JPEGImageEncoderState;
-class PNGImageEncoderState;
class CORE_EXPORT CanvasAsyncBlobCreator
: public GarbageCollectedFinalized<CanvasAsyncBlobCreator> {
@@ -82,10 +81,8 @@ class CORE_EXPORT CanvasAsyncBlobCreator
Document*,
ScriptPromiseResolver*);
// Methods are virtual for unit testing
- virtual void ScheduleInitiatePngEncoding();
- virtual void ScheduleInitiateJpegEncoding(const double&);
- virtual void IdleEncodeRowsPng(double deadline_seconds);
- virtual void IdleEncodeRowsJpeg(double deadline_seconds);
+ virtual void ScheduleInitiateEncoding(double quality);
+ virtual void IdleEncodeRows(double deadline_seconds);
virtual void PostDelayedTaskToCurrentThread(const WebTraceLocation&,
std::unique_ptr<WTF::Closure>,
double delay_ms);
@@ -93,8 +90,7 @@ class CORE_EXPORT CanvasAsyncBlobCreator
virtual void CreateBlobAndReturnResult();
virtual void CreateNullAndReturnResult();
- void InitiatePngEncoding(double deadline_seconds);
- void InitiateJpegEncoding(const double& quality, double deadline_seconds);
+ void InitiateEncoding(double quality, double deadline_seconds);
IdleTaskStatus idle_task_status_;
private:
@@ -102,15 +98,14 @@ class CORE_EXPORT CanvasAsyncBlobCreator
void Dispose();
- std::unique_ptr<PNGImageEncoderState> png_encoder_state_;
- std::unique_ptr<JPEGImageEncoderState> jpeg_encoder_state_;
Member<DOMUint8ClampedArray> data_;
+ std::unique_ptr<SkEncoder> encoder_;
f(malita) 2017/05/15 19:53:26 For encapsulation, I wonder if it'd make sense to
msarett1 2017/05/15 23:49:08 I wrote a wrapper class, let me know if it is alon
std::unique_ptr<Vector<unsigned char>> encoded_image_;
+ std::unique_ptr<SkWStream> dst_;
int num_rows_completed_;
Member<Document> document_;
- const IntSize size_;
- size_t pixel_row_stride_;
+ SkPixmap src_data_;
const MimeType mime_type_;
double start_time_;
double schedule_initiate_start_time_;
@@ -127,16 +122,10 @@ class CORE_EXPORT CanvasAsyncBlobCreator
// Used for OffscreenCanvas only
Member<ScriptPromiseResolver> script_promise_resolver_;
- // PNG
- bool InitializePngStruct();
- void ForceEncodeRowsPngOnCurrentThread(); // Similar to idleEncodeRowsPng
- // without deadline
-
- // JPEG
- bool InitializeJpegStruct(double quality);
- void ForceEncodeRowsJpegOnCurrentThread(); // Similar to idleEncodeRowsJpeg
- // without
- // deadline
+ // PNG, JPEG
+ bool InitializeEncoder(double quality);
+ void ForceEncodeRowsOnCurrentThread(); // Similar to IdleEncodeRows
+ // without deadline
// WEBP
void EncodeImageOnEncoderThread(double quality);

Powered by Google App Engine
This is Rietveld 408576698