OLD | NEW |
1 // Copyright (c) 2009, Google Inc. | 1 // Copyright (c) 2009, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 // Get the specified value from the pixel buffer and return it wrapped as a | 41 // Get the specified value from the pixel buffer and return it wrapped as a |
42 // JavaScript Number object to V8. Accesses outside the valid pixel buffer | 42 // JavaScript Number object to V8. Accesses outside the valid pixel buffer |
43 // range return "undefined". | 43 // range return "undefined". |
44 INDEXED_PROPERTY_GETTER(CanvasPixelArray) { | 44 INDEXED_PROPERTY_GETTER(CanvasPixelArray) { |
45 INC_STATS("DOM.CanvasPixelArray.IndexedPropertyGetter"); | 45 INC_STATS("DOM.CanvasPixelArray.IndexedPropertyGetter"); |
46 CanvasPixelArray* pixelBuffer = | 46 CanvasPixelArray* pixelBuffer = |
47 V8Proxy::ToNativeObject<CanvasPixelArray>( | 47 V8Proxy::ToNativeObject<CanvasPixelArray>( |
48 V8ClassIndex::CANVASPIXELARRAY, | 48 V8ClassIndex::CANVASPIXELARRAY, |
49 info.Holder()); | 49 info.Holder()); |
50 | 50 |
51 if ((index < 0) || (index >= pixelBuffer->length())) { | 51 if ((index < 0) || (index >= pixelBuffer->length())) { |
52 return v8::Undefined(); | 52 return v8::Undefined(); |
53 } | 53 } |
54 return v8::Number::New(pixelBuffer->get(index)); | 54 unsigned char result; |
| 55 if (!pixelBuffer->get(index, result)) { |
| 56 return v8::Undefined(); |
| 57 } |
| 58 return v8::Number::New(result); |
55 } | 59 } |
56 | 60 |
57 | 61 |
58 // Set the specified value in the pixel buffer. Accesses outside the valid pixel | 62 // Set the specified value in the pixel buffer. Accesses outside the valid pixel |
59 // buffer range are silently ignored. | 63 // buffer range are silently ignored. |
60 INDEXED_PROPERTY_SETTER(CanvasPixelArray) { | 64 INDEXED_PROPERTY_SETTER(CanvasPixelArray) { |
61 INC_STATS("DOM.CanvasPixelArray.IndexedPropertySetter"); | 65 INC_STATS("DOM.CanvasPixelArray.IndexedPropertySetter"); |
62 CanvasPixelArray* pixelBuffer = | 66 CanvasPixelArray* pixelBuffer = |
63 V8Proxy::ToNativeObject<CanvasPixelArray>( | 67 V8Proxy::ToNativeObject<CanvasPixelArray>( |
64 V8ClassIndex::CANVASPIXELARRAY, | 68 V8ClassIndex::CANVASPIXELARRAY, |
65 info.Holder()); | 69 info.Holder()); |
66 | 70 |
67 if ((index >= 0) && (index < pixelBuffer->length())) { | 71 if ((index >= 0) && (index < pixelBuffer->length())) { |
68 pixelBuffer->set(index, value->NumberValue()); | 72 pixelBuffer->set(index, value->NumberValue()); |
69 } | 73 } |
70 return value; | 74 return value; |
71 } | 75 } |
72 | 76 |
73 | 77 |
74 } // namespace WebCore | 78 } // namespace WebCore |
OLD | NEW |