OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. 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 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1928 uint32_t height; | 1928 uint32_t height; |
1929 uint32_t pixelDataLength; | 1929 uint32_t pixelDataLength; |
1930 if (!doReadUint32(&width)) | 1930 if (!doReadUint32(&width)) |
1931 return false; | 1931 return false; |
1932 if (!doReadUint32(&height)) | 1932 if (!doReadUint32(&height)) |
1933 return false; | 1933 return false; |
1934 if (!doReadUint32(&pixelDataLength)) | 1934 if (!doReadUint32(&pixelDataLength)) |
1935 return false; | 1935 return false; |
1936 if (m_position + pixelDataLength > m_length) | 1936 if (m_position + pixelDataLength > m_length) |
1937 return false; | 1937 return false; |
1938 RefPtr<ImageData> imageData = ImageData::create(IntSize(width, height)); | 1938 RefPtrWillBeRawPtr<ImageData> imageData = ImageData::create(IntSize(widt
h, height)); |
1939 Uint8ClampedArray* pixelArray = imageData->data(); | 1939 Uint8ClampedArray* pixelArray = imageData->data(); |
1940 ASSERT(pixelArray); | 1940 ASSERT(pixelArray); |
1941 ASSERT(pixelArray->length() >= pixelDataLength); | 1941 ASSERT(pixelArray->length() >= pixelDataLength); |
1942 memcpy(pixelArray->data(), m_buffer + m_position, pixelDataLength); | 1942 memcpy(pixelArray->data(), m_buffer + m_position, pixelDataLength); |
1943 m_position += pixelDataLength; | 1943 m_position += pixelDataLength; |
1944 *value = toV8(imageData.release(), v8::Handle<v8::Object>(), m_isolate); | 1944 *value = toV8(imageData.release(), v8::Handle<v8::Object>(), m_isolate); |
1945 return true; | 1945 return true; |
1946 } | 1946 } |
1947 | 1947 |
1948 PassRefPtr<ArrayBuffer> doReadArrayBuffer() | 1948 PassRefPtr<ArrayBuffer> doReadArrayBuffer() |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2939 // If the allocated memory was not registered before, then this class is lik
ely | 2939 // If the allocated memory was not registered before, then this class is lik
ely |
2940 // used in a context other then Worker's onmessage environment and the prese
nce of | 2940 // used in a context other then Worker's onmessage environment and the prese
nce of |
2941 // current v8 context is not guaranteed. Avoid calling v8 then. | 2941 // current v8 context is not guaranteed. Avoid calling v8 then. |
2942 if (m_externallyAllocatedMemory) { | 2942 if (m_externallyAllocatedMemory) { |
2943 ASSERT(v8::Isolate::GetCurrent()); | 2943 ASSERT(v8::Isolate::GetCurrent()); |
2944 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); | 2944 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); |
2945 } | 2945 } |
2946 } | 2946 } |
2947 | 2947 |
2948 } // namespace WebCore | 2948 } // namespace WebCore |
OLD | NEW |