Commit b36e66be authored by davve's avatar davve Committed by Commit bot

Update comments regarding image caching

While attempting to remove the layoutObject parameter the following
observations were made:

 * The decoding forced by BitmapImage::imageForCurrentFrame will be
   deferred so the comment in the header may be removed.

 * BitmapImage::currentFrameKnownToBeOpaque() conservatively returns
   false for uncached images, not true.

 * Since decoding is deferred, there is no guarantee that the
   opaqueness metadata is available after the imageForCurrentFrame
   call has returned. It may increase the chance though, depending on
   image decoder for the particular image.

NOTRY=true
BUG=559131

Review URL: https://codereview.chromium.org/1454373005

Cr-Commit-Position: refs/heads/master@{#361094}
parent 6898e587
...@@ -451,8 +451,9 @@ bool ImageResource::currentFrameKnownToBeOpaque(const LayoutObject* layoutObject ...@@ -451,8 +451,9 @@ bool ImageResource::currentFrameKnownToBeOpaque(const LayoutObject* layoutObject
blink::Image* image = this->image(); blink::Image* image = this->image();
if (image->isBitmapImage()) { if (image->isBitmapImage()) {
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "data", InspectorPaintImageEvent::data(layoutObject, *this)); TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", "data", InspectorPaintImageEvent::data(layoutObject, *this));
// BitmapImage::currentFrameKnownToBeOpaque() conservatively returns true for uncached // BitmapImage::currentFrameKnownToBeOpaque() conservatively returns false for uncached
// frames. To get an accurate answer, we pre-cache the current frame metadata. // frames. To increase the change of an accurate answer, we pre-cache the current frame
// metadata.
image->imageForCurrentFrame(); image->imageForCurrentFrame();
} }
return image->currentFrameKnownToBeOpaque(); return image->currentFrameKnownToBeOpaque();
......
...@@ -60,8 +60,6 @@ public: ...@@ -60,8 +60,6 @@ public:
blink::Image* image(); // Returns the nullImage() if the image is not available yet. blink::Image* image(); // Returns the nullImage() if the image is not available yet.
bool hasImage() const { return m_image.get(); } bool hasImage() const { return m_image.get(); }
// Side effect: ensures decoded image is in cache, therefore should only be called when about to draw the image. // Side effect: ensures decoded image is in cache, therefore should only be called when about to draw the image.
// FIXME: Decoding image on the main thread is expensive, so rather than forcing decode, consider returning false
// when image is not decoded yet, as we do in case of deferred decoding.
bool currentFrameKnownToBeOpaque(const LayoutObject*); bool currentFrameKnownToBeOpaque(const LayoutObject*);
static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor); // Returns an image and the image's resolution scale factor. static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor); // Returns an image and the image's resolution scale factor.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment