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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 if (canvasBitmap.width() == width && canvasBitmap.height() == height) { | 946 if (canvasBitmap.width() == width && canvasBitmap.height() == height) { |
947 // This is the fastest and most common case. We read back | 947 // This is the fastest and most common case. We read back |
948 // directly into the canvas's backing store. | 948 // directly into the canvas's backing store. |
949 readbackBitmap = &canvasBitmap; | 949 readbackBitmap = &canvasBitmap; |
950 m_resizingBitmap.reset(); | 950 m_resizingBitmap.reset(); |
951 } else { | 951 } else { |
952 // We need to allocate a temporary bitmap for reading back the | 952 // We need to allocate a temporary bitmap for reading back the |
953 // pixel data. We will then use Skia to rescale this bitmap to | 953 // pixel data. We will then use Skia to rescale this bitmap to |
954 // the size of the canvas's backing store. | 954 // the size of the canvas's backing store. |
955 if (m_resizingBitmap.width() != width || m_resizingBitmap.height() != he
ight) { | 955 if (m_resizingBitmap.width() != width || m_resizingBitmap.height() != he
ight) { |
956 if (!m_resizingBitmap.allocN32Pixels(width, height)) | 956 if (!m_resizingBitmap.tryAllocN32Pixels(width, height)) |
957 return; | 957 return; |
958 } | 958 } |
959 readbackBitmap = &m_resizingBitmap; | 959 readbackBitmap = &m_resizingBitmap; |
960 } | 960 } |
961 | 961 |
962 // Read back the frame buffer. | 962 // Read back the frame buffer. |
963 SkAutoLockPixels bitmapLock(*readbackBitmap); | 963 SkAutoLockPixels bitmapLock(*readbackBitmap); |
964 pixels = static_cast<unsigned char*>(readbackBitmap->getPixels()); | 964 pixels = static_cast<unsigned char*>(readbackBitmap->getPixels()); |
965 | 965 |
966 m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer); | 966 m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 1047 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
1048 { | 1048 { |
1049 if (info->imageId) { | 1049 if (info->imageId) { |
1050 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 1050 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
1051 m_context->destroyImageCHROMIUM(info->imageId); | 1051 m_context->destroyImageCHROMIUM(info->imageId); |
1052 info->imageId = 0; | 1052 info->imageId = 0; |
1053 } | 1053 } |
1054 } | 1054 } |
1055 | 1055 |
1056 } // namespace blink | 1056 } // namespace blink |
OLD | NEW |