Closed
Bug 1328543
Opened 7 years ago
Closed 7 years ago
[Mortar] colors are wrong while changing, resizing, scrolling pages on pdf
Categories
(Firefox :: PDF Viewer, defect, P2)
Firefox
PDF Viewer
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: ywu, Assigned: ywu)
References
Details
Attachments
(1 file, 3 obsolete files)
Right now, we have problems with rendering right colors as we saw some pdf with weird colors. As far as I studied, we mismatch red pixel to blue pixel and blue to red. We need to fix it.
Assignee | ||
Updated•7 years ago
|
Assignee: nobody → ywu
Comment 3•7 years ago
|
||
I also found sometimes, the wrong pixel rendering happened when you resize window.
Assignee | ||
Comment 4•7 years ago
|
||
(In reply to Ya-Chieh Wu from comment #0) > Right now, we have problems with rendering right colors as we saw some pdf > with weird colors. As far as I studied, we mismatch red pixel to blue pixel > and blue to red. We need to fix it. After investigating, the root cause of this problem is that we didn't perform the color conversion right on mortar's image buffer. Now, we did color conversion per 2d operation. However, several 2d operations might use one same image buffer so every time we executed a 2d operation, we exchange the place of red and blue pixels. That's why some times the colors are right, some times the colors are wrong.
Summary: [jsplugins] problems with rendering right pixel data in Graphics2D → [jsplugins] colors are wrong while changing, resizing, scrolling pages on pdf
Assignee | ||
Comment 6•7 years ago
|
||
This patch is basically the same as Comment 5. This should fix the issue that was mentioned on Comment 4.
Attachment #8827073 -
Attachment is obsolete: true
Assignee | ||
Comment 7•7 years ago
|
||
Comment on attachment 8827333 [details] [diff] [review] fix the wrong colors on pdf while scrolling, changing pages and resizing Peter, thank you for your reviewing. This patch is trying to avoid we convert GBRA format of |imageData| to RGBA format more than once. As the fact that one |imageData| is using in different 2doperations, we should only convert the color form of |imageData| once.
Attachment #8827333 -
Flags: review?(peterv)
Comment 8•7 years ago
|
||
Comment on attachment 8827333 [details] [diff] [review] fix the wrong colors on pdf while scrolling, changing pages and resizing Review of attachment 8827333 [details] [diff] [review]: ----------------------------------------------------------------- ::: browser/extensions/mortar/host/common/ppapi-runtime.jsm @@ +968,5 @@ > this.operations = []; > } > > flush(callback) { > + let RGBABuffers = []; I think I'd prefer to store whether we've converted the colors on the ImageData object itself. For example with a boolean member that we check in getDOMImageData before calling _colorConvert. I'm not entirely sure if it's possible, but it seems like we should then also be able to throw an error in beginDrawing if we've already converted the colors.
Assignee | ||
Comment 9•7 years ago
|
||
(In reply to Peter Van der Beken [:peterv] from comment #8) > ::: browser/extensions/mortar/host/common/ppapi-runtime.jsm > @@ +968,5 @@ > > this.operations = []; > > } > > > > flush(callback) { > > + let RGBABuffers = []; > > I think I'd prefer to store whether we've converted the colors on the ImageData object itself. For example with a boolean member that we check in getDOMImageData before calling _colorConvert. Thanks, Peter. I was thinking the same thing at first but I choose another way to implement because I was thinking that if it will be better that we implement in this way so it is clear that we convert the color bits in one flush operation or the boolean check we scatter in getDOMImageData, PPB_Graphics2D_PaintImageData, and PPB_Graphics2D_ReplaceContents. I will provide another version and you can make the call. > > I'm not entirely sure if it's possible, but it seems like we should then also be able to throw an error in beginDrawing if we've already converted the colors. The operation here is different from |Graphics2DPaintOperation|. The code surround by |beginDrawing| and |endDrawing| are drawing by ourself[1] so we might not need to do anything here? no? [1] https://dxr.mozilla.org/mozilla-central/source/browser/extensions/mortar/host/common/ppapi-runtime.jsm#2227
Assignee | ||
Comment 10•7 years ago
|
||
Peter, In this patch, I save a boolean in the image class to indicate if the color has been converted. However, how pdfium operates the buffer is not that intuitive so I would prefer to use our previous' patch. Let me explain it to you below. PPAPI calls: 1.PaintImageData - imageData_x(BGRA format) 2.PaintImageData - imageData_x(BGRA format) 3.PaintImageData - imageData_y(BGRA format) 4.flush // we apply BGRA to RGBA here. 5.PaintImageData - imageData_x(*BGRA format*) // Still use *imageData_x*, but the data is back to BGRA format not RGBA format. So we shouldn't do any conversion here. 6.flush // we apply BGRA to RGBA here. As you can see, after the first flush, we assume that the imageData_x has been converted but it turns out that pdfium somehow replace the whole buffer so the buffer state is back to unconverted. That's why I would prefer to check if the color is been converted when we do flush instead of saving a boolean in the imageData. how do you think?
Attachment #8863968 -
Flags: feedback?(peterv)
Assignee | ||
Comment 11•7 years ago
|
||
Note: I just had a discussion with astley yesterday and he gave a valuable input that we probably can find out if we can configure pdfium to draw the imageData into RGBA format so that we can avoide to do the color conversion which can improve the scolling perfomance or in general when users change pages. Anyway, this bug still needs to be reolved to take care of the case of "BGRA format".
Comment 12•7 years ago
|
||
(In reply to Ya-Chieh Wu from comment #11) > Note: I just had a discussion with astley yesterday and he gave a valuable > input that we probably can find out if we can configure pdfium to draw the > imageData into RGBA format so that we can avoide to do the color conversion > which can improve the scolling perfomance or in general when users change > pages. I looked into that when I first wrote this code, the PDF plugin specifically asks for BGRA (see https://chromium.googlesource.com/chromium/src.git/+/ec747d5400f2930853e1f90c8365916393803606/pdf/out_of_process_instance.cc#647).
Comment 13•7 years ago
|
||
Comment on attachment 8863968 [details] [diff] [review] 0001-Bug1328543-wip.patch Review of attachment 8863968 [details] [diff] [review]: ----------------------------------------------------------------- ::: browser/extensions/mortar/host/common/ppapi-runtime.jsm @@ +2814,5 @@ > */ > PPB_Graphics2D_ReplaceContents: function(json) { > let graphics = PP_Resource.lookup(json.graphics_2d); > let imageData = PP_Resource.lookup(json.image_data); > + imageData.colorConverted = false; I think I'd prefer if you did this inside the Graphics2DPaintOperation constructor when x == y == 0 and dirtyRect == []. I think that would work? It doesn't make sense to set colorConverted to false if we're not overwriting the whole imageData (from ReplaceContents), because we'd leave pieces in the wrong format.
Assignee | ||
Comment 14•7 years ago
|
||
Peter, I think that we shouldn't convert the origin buffer at all because it is not right that we don't convert it back and keep pdfium using it afterward. I think what we should do is do not contaminate the origin buffer and save a copy of RGBA buffer. I know this is not that perfect but by doing so, we guarantee the pure of the origin buffer and save the efforts to convert it back. How do you think?
Attachment #8827333 -
Attachment is obsolete: true
Attachment #8863968 -
Attachment is obsolete: true
Attachment #8827333 -
Flags: review?(peterv)
Attachment #8863968 -
Flags: feedback?(peterv)
Attachment #8866623 -
Flags: review?(peterv)
Updated•7 years ago
|
Severity: normal → major
Component: General → PDF Viewer
Priority: -- → P2
Updated•7 years ago
|
Summary: [jsplugins] colors are wrong while changing, resizing, scrolling pages on pdf → [Mortar] colors are wrong while changing, resizing, scrolling pages on pdf
Assignee | ||
Comment 15•7 years ago
|
||
has no plan for this. close it now.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WORKSFORME
Assignee | ||
Updated•6 years ago
|
Attachment #8866623 -
Flags: review?(peterv)
You need to log in
before you can comment on or make changes to this bug.
Description
•