|
|
Chromium Code Reviews|
Created:
4 years, 4 months ago by zakerinasab Modified:
4 years, 4 months ago Reviewers:
Justin Novosad Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionAdding proper check for canvas type to
HTMLCanvasElement::getSourceImageForCanvas() such that
drawImage can correctly draw canvases with bitmap images.
BUG=639841
Committed: https://crrev.com/4d29ebec048d83aac139ec5edcbe22d107351b7b
Committed: https://crrev.com/d161245684a7adab144318deec691ad6fdc6251e
Cr-Original-Commit-Position: refs/heads/master@{#413731}
Cr-Commit-Position: refs/heads/master@{#413828}
Patch Set 1 #
Total comments: 6
Patch Set 2 #
Total comments: 2
Patch Set 3 : Addressing comments from patch set 2. #Patch Set 4 : Resolving the conflict with DCHECK on canvas type. #
Messages
Total messages: 39 (18 generated)
Description was changed from ========== Addressing the bug in which improper use of ImageBuffer in HTMLCanvasElement::getSourceImageForCanvas() was led to not drawning the canvases with image bitmap in drawImage(). BUG=639841 ========== to ========== Addressing the bug in which improper use of ImageBuffer in HTMLCanvasElement::getSourceImageForCanvas() was led to not drawning the canvases with image bitmap in drawImage(). BUG=639841 ==========
Patchset #1 (id:1) has been deleted
zakerinasab@chromium.org changed reviewers: + junov@chromium.org
When returning m_image from ImageBitmapRenderingContext, I tried to return RefPtr<Image> frist, but then presubmit check was failed and asked me to use PassRefPtr. I wasn't sure if it is safe to move the pointer ownership, so I returned Image* instead. Please let me know if this needs to change.
For the code review description: this will become the commit comment when the change lands. The first line should be a short summary, and the body of the description should use at most 72 characters per line.
Description was changed from ========== Addressing the bug in which improper use of ImageBuffer in HTMLCanvasElement::getSourceImageForCanvas() was led to not drawning the canvases with image bitmap in drawImage(). BUG=639841 ========== to ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 ==========
On 2016/08/22 19:28:23, Justin Novosad wrote: > For the code review description: this will become the commit comment when the > change lands. The first line should be a short summary, and the body of the > description should use at most 72 characters per line. Done.
Description was changed from ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 ========== to ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 ==========
https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp (right): https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp:1105: if (renderingContext()->getContextType() == CanvasRenderingContext::ContextImageBitmap) Avoid explicit type checks when possible. In this case, you made getImage virtual, so the type check is not necessary. Should be: RefPtr<SkImage> skImage; RefPtr<Blink::Image> image = renderingContext()->getImage(); if (image) skImage = image->imageForCurrentFrame(); else ... https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.h (right): https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.h:130: virtual Image* getImage() const { return nullptr; } Image is a ref counted type. You should not be returning a raw pointer, but rather a PassRefPtr<Image> https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/imagebitmap/ImageBitmapRenderingContext.h (right): https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/imagebitmap/ImageBitmapRenderingContext.h:40: Image* getImage() const override { return m_image.get(); } override -> final
https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp (right): https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp:1105: if (renderingContext()->getContextType() == CanvasRenderingContext::ContextImageBitmap) On 2016/08/22 19:42:25, Justin Novosad wrote: > Avoid explicit type checks when possible. In this case, you made getImage > virtual, so the type check is not necessary. > Should be: > RefPtr<SkImage> skImage; > RefPtr<Blink::Image> image = renderingContext()->getImage(); > if (image) > skImage = image->imageForCurrentFrame(); > else > ... Done. https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.h (right): https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.h:130: virtual Image* getImage() const { return nullptr; } On 2016/08/22 19:42:25, Justin Novosad wrote: > Image is a ref counted type. You should not be returning a raw pointer, but > rather a PassRefPtr<Image> Done. https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/imagebitmap/ImageBitmapRenderingContext.h (right): https://codereview.chromium.org/2267653005/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/imagebitmap/ImageBitmapRenderingContext.h:40: Image* getImage() const override { return m_image.get(); } On 2016/08/22 19:42:25, Justin Novosad wrote: > override -> final Done.
https://codereview.chromium.org/2267653005/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp (right): https://codereview.chromium.org/2267653005/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp:1109: skImage = buffer()->newSkImageSnapshot(hint, reason); Just realized this code may inadvertently allocate a permanent ImageBuffer, which should be avoided if possible. Try this: skImage = hasImageBuffer() ? buffer()->newSkImageSnapshot(hint, reason) : createTransparentImage(size());
https://codereview.chromium.org/2267653005/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp (right): https://codereview.chromium.org/2267653005/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp:1109: skImage = buffer()->newSkImageSnapshot(hint, reason); On 2016/08/22 20:03:02, Justin Novosad wrote: > Just realized this code may inadvertently allocate a permanent ImageBuffer, > which should be avoided if possible. Try this: > skImage = hasImageBuffer() ? buffer()->newSkImageSnapshot(hint, reason) : > createTransparentImage(size()); createTransparentImage(size()) returns PassRefPtr<Image>, so I added the call to imageForCurrentFrame(). Regarding hasImageBuffer(), what is the expected behavior in our case that we don't have an ImageBuffer to use and we get the info from m_context? It still returns true.
On 2016/08/22 20:19:10, zakerinasab wrote: > https://codereview.chromium.org/2267653005/diff/40001/third_party/WebKit/Sour... > File third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp (right): > > https://codereview.chromium.org/2267653005/diff/40001/third_party/WebKit/Sour... > third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp:1109: skImage = > buffer()->newSkImageSnapshot(hint, reason); > On 2016/08/22 20:03:02, Justin Novosad wrote: > > Just realized this code may inadvertently allocate a permanent ImageBuffer, > > which should be avoided if possible. Try this: > > skImage = hasImageBuffer() ? buffer()->newSkImageSnapshot(hint, reason) : > > createTransparentImage(size()); > > createTransparentImage(size()) returns PassRefPtr<Image>, so I added the call to > imageForCurrentFrame(). Regarding hasImageBuffer(), what is the expected > behavior in our case that we don't have an ImageBuffer to use and we get the > info from m_context? It still returns true. The cases where hasImageBuffer will return false here are: 1) a 2D context that is blanks (has not been drawn to), 2) an ImageBitmapRenderingContext that has no image (transferFromImageBitmap was not yet called). In these case we want to produce a transparent black image.
lgtm
The CQ bit was checked by zakerinasab@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_clobber_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by zakerinasab@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by zakerinasab@chromium.org
The CQ bit was checked by zakerinasab@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 ========== to ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 ==========
Message was sent while issue was closed.
Committed patchset #3 (id:60001)
Message was sent while issue was closed.
Description was changed from ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 ========== to ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 Committed: https://crrev.com/4d29ebec048d83aac139ec5edcbe22d107351b7b Cr-Commit-Position: refs/heads/master@{#413731} ==========
Message was sent while issue was closed.
Patchset 3 (id:??) landed as https://crrev.com/4d29ebec048d83aac139ec5edcbe22d107351b7b Cr-Commit-Position: refs/heads/master@{#413731}
Message was sent while issue was closed.
A revert of this CL (patchset #3 id:60001) has been created in https://codereview.chromium.org/2269073002/ by xidachen@chromium.org. The reason for reverting is: Causing this DCHECK: m_context->getContextType() != CanvasRenderingContext::ContextImageBitmap on this test: transferFromImageBitmap-drawImage.html .
Message was sent while issue was closed.
New patch submitted.
Message was sent while issue was closed.
Patchset #4 (id:80001) has been deleted
Message was sent while issue was closed.
Patchset #4 (id:100001) has been deleted
Message was sent while issue was closed.
Description was changed from ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 Committed: https://crrev.com/4d29ebec048d83aac139ec5edcbe22d107351b7b Cr-Commit-Position: refs/heads/master@{#413731} ========== to ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 Committed: https://crrev.com/4d29ebec048d83aac139ec5edcbe22d107351b7b Cr-Commit-Position: refs/heads/master@{#413731} ==========
On 2016/08/23 17:07:07, zakerinasab wrote: > New patch submitted. lgtm
The CQ bit was checked by zakerinasab@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 Committed: https://crrev.com/4d29ebec048d83aac139ec5edcbe22d107351b7b Cr-Commit-Position: refs/heads/master@{#413731} ========== to ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 Committed: https://crrev.com/4d29ebec048d83aac139ec5edcbe22d107351b7b Cr-Commit-Position: refs/heads/master@{#413731} ==========
Message was sent while issue was closed.
Committed patchset #4 (id:120001)
Message was sent while issue was closed.
Description was changed from ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 Committed: https://crrev.com/4d29ebec048d83aac139ec5edcbe22d107351b7b Cr-Commit-Position: refs/heads/master@{#413731} ========== to ========== Adding proper check for canvas type to HTMLCanvasElement::getSourceImageForCanvas() such that drawImage can correctly draw canvases with bitmap images. BUG=639841 Committed: https://crrev.com/4d29ebec048d83aac139ec5edcbe22d107351b7b Committed: https://crrev.com/d161245684a7adab144318deec691ad6fdc6251e Cr-Original-Commit-Position: refs/heads/master@{#413731} Cr-Commit-Position: refs/heads/master@{#413828} ==========
Message was sent while issue was closed.
Patchset 4 (id:??) landed as https://crrev.com/d161245684a7adab144318deec691ad6fdc6251e Cr-Commit-Position: refs/heads/master@{#413828} |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
