OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * The base class for simple filters that only modify the image content | 6 * The base class for simple filters that only modify the image content |
7 * but do not modify the image dimensions. | 7 * but do not modify the image dimensions. |
8 */ | 8 */ |
9 ImageEditor.Mode.Adjust = function(displayName, filterFunc) { | 9 ImageEditor.Mode.Adjust = function(displayName, filterFunc) { |
10 ImageEditor.Mode.call(this, displayName); | 10 ImageEditor.Mode.call(this, displayName); |
11 this.filterFunc_ = filterFunc; | 11 this.filterFunc_ = filterFunc; |
12 } | 12 } |
13 | 13 |
14 ImageEditor.Mode.Adjust.prototype = {__proto__: ImageEditor.Mode.prototype}; | 14 ImageEditor.Mode.Adjust.prototype = {__proto__: ImageEditor.Mode.prototype}; |
15 | 15 |
16 ImageEditor.Mode.Adjust.prototype.rollback = function() { | 16 ImageEditor.Mode.Adjust.prototype.rollback = function() { |
17 if (!this.backup_) return; // Did not do anything yet. | 17 if (!this.backup_) return; // Did not do anything yet. |
18 this.getBuffer().drawImageData(this.backup_); | 18 this.getContent().drawImageData(this.backup_, 0, 0); |
19 this.backup_ = null; | 19 this.backup_ = null; |
20 this.repaint(); | 20 this.repaint(); |
21 }; | 21 }; |
22 | 22 |
23 ImageEditor.Mode.Adjust.prototype.update = function(options) { | 23 ImageEditor.Mode.Adjust.prototype.update = function(options) { |
24 if (!this.backup_) { | 24 if (!this.backup_) { |
25 this.backup_ = this.getBuffer().copyImageData(); | 25 this.backup_ = this.getContent().copyImageData(); |
26 this.scratch_ = this.getBuffer().copyImageData(); | 26 this.scratch_ = this.getContent().copyImageData(); |
27 } | 27 } |
28 | 28 |
29 ImageUtil.trace.resetTimer('filter'); | 29 ImageUtil.trace.resetTimer('filter'); |
30 this.filterFunc_(this.scratch_, this.backup_, options); | 30 this.filterFunc_(this.scratch_, this.backup_, options); |
31 ImageUtil.trace.reportTimer('filter'); | 31 ImageUtil.trace.reportTimer('filter'); |
32 this.getBuffer().drawImageData(this.scratch_); | 32 this.getContent().drawImageData(this.scratch_, 0, 0); |
33 this.repaint(); | 33 this.repaint(); |
34 }; | 34 }; |
35 | 35 |
36 /** | 36 /** |
37 * A simple filter that multiplies every component of a pixel by some number. | 37 * A simple filter that multiplies every component of a pixel by some number. |
38 */ | 38 */ |
39 ImageEditor.Mode.Brightness = function() { | 39 ImageEditor.Mode.Brightness = function() { |
40 ImageEditor.Mode.Adjust.call( | 40 ImageEditor.Mode.Adjust.call( |
41 this, 'Brightness', ImageEditor.Mode.Brightness.filter); | 41 this, 'Brightness', ImageEditor.Mode.Brightness.filter); |
42 } | 42 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 for (var y = 0; y != height; y++) { | 76 for (var y = 0; y != height; y++) { |
77 for (var x = 0; x != width; x++ ) { | 77 for (var x = 0; x != width; x++ ) { |
78 dstData[index] = values[srcData[index]]; index++; | 78 dstData[index] = values[srcData[index]]; index++; |
79 dstData[index] = values[srcData[index]]; index++; | 79 dstData[index] = values[srcData[index]]; index++; |
80 dstData[index] = values[srcData[index]]; index++; | 80 dstData[index] = values[srcData[index]]; index++; |
81 dstData[index] = 0xFF; index++; | 81 dstData[index] = 0xFF; index++; |
82 } | 82 } |
83 } | 83 } |
84 }; | 84 }; |
85 | 85 |
OLD | NEW |