Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 540033002: use tryAllocPixels to check the result, allocPixels to require success (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/platform/graphics/ImageLayerChromiumTest.cpp ('k') | Source/platform/image-decoders/ImageFrame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698