Commit 46091e02 authored by hirono@chromium.org's avatar hirono@chromium.org

Check the actual size of canvas to update.

Previously the gallery checks the sequence number to find out whether the update
for canvas size is needed or not.  The sequence number is incremented when
variables that affect canvas size are updated. But sometimes, the
canvas size goes to be out of sync.

BUG=245926
TEST=manually

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284052 0039d316-1c4b-4281-b951-d872f2087c98
parent 8bef9974
...@@ -20,7 +20,6 @@ function ImageView(container, viewport) { ...@@ -20,7 +20,6 @@ function ImageView(container, viewport) {
this.document_ = container.ownerDocument; this.document_ = container.ownerDocument;
this.contentGeneration_ = 0; this.contentGeneration_ = 0;
this.displayedContentGeneration_ = 0; this.displayedContentGeneration_ = 0;
this.displayedViewportGeneration_ = 0;
this.imageLoader_ = new ImageUtil.ImageLoader(this.document_); this.imageLoader_ = new ImageUtil.ImageLoader(this.document_);
// We have a separate image loader for prefetch which does not get cancelled // We have a separate image loader for prefetch which does not get cancelled
...@@ -104,20 +103,16 @@ ImageView.prototype.draw = function() { ...@@ -104,20 +103,16 @@ ImageView.prototype.draw = function() {
return; return;
var forceRepaint = false; var forceRepaint = false;
var deviceBounds = this.viewport_.getDeviceBounds();
if (this.displayedViewportGeneration_ !== if (deviceBounds.width != this.screenImage_.width ||
this.viewport_.getCacheGeneration()) { deviceBounds.height != this.screenImage_.height) {
this.displayedViewportGeneration_ = this.viewport_.getCacheGeneration();
this.setupDeviceBuffer(this.screenImage_); this.setupDeviceBuffer(this.screenImage_);
forceRepaint = true; forceRepaint = true;
} }
if (forceRepaint || if (forceRepaint ||
this.displayedContentGeneration_ !== this.contentGeneration_) { this.displayedContentGeneration_ !== this.contentGeneration_) {
this.displayedContentGeneration_ = this.contentGeneration_; this.displayedContentGeneration_ = this.contentGeneration_;
ImageUtil.trace.resetTimer('paint'); ImageUtil.trace.resetTimer('paint');
this.paintDeviceRect(this.contentCanvas_, new Rect(this.contentCanvas_)); this.paintDeviceRect(this.contentCanvas_, new Rect(this.contentCanvas_));
ImageUtil.trace.reportTimer('paint'); ImageUtil.trace.reportTimer('paint');
...@@ -184,16 +179,9 @@ ImageView.prototype.getContentRevision = function() { ...@@ -184,16 +179,9 @@ ImageView.prototype.getContentRevision = function() {
* @param {Rect} imageRect Rectangle region of the canvas to be rendered. * @param {Rect} imageRect Rectangle region of the canvas to be rendered.
*/ */
ImageView.prototype.paintDeviceRect = function(canvas, imageRect) { ImageView.prototype.paintDeviceRect = function(canvas, imageRect) {
// Check canvas size.
var deviceBounds = this.viewport_.getDeviceBounds();
if (this.screenImage_.width != deviceBounds.width ||
this.screenImage_.height != deviceBounds.height) {
console.error('The size of canvas is invalid.', (new Error).stack);
return;
}
// Map the rectangle in full resolution image to the rectangle in the device // Map the rectangle in full resolution image to the rectangle in the device
// canvas. // canvas.
var deviceBounds = this.viewport_.getDeviceBounds();
var scaleX = deviceBounds.width / canvas.width; var scaleX = deviceBounds.width / canvas.width;
var scaleY = deviceBounds.height / canvas.height; var scaleY = deviceBounds.height / canvas.height;
var deviceRect = new Rect( var deviceRect = new Rect(
......
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