| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 | 639 |
| 640 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail() | 640 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail() |
| 641 { | 641 { |
| 642 shouldFailContextCreationForTesting = true; | 642 shouldFailContextCreationForTesting = true; |
| 643 } | 643 } |
| 644 | 644 |
| 645 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase() | 645 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase() |
| 646 { | 646 { |
| 647 if (!drawingBuffer()) | 647 if (!drawingBuffer()) |
| 648 return nullptr; | 648 return nullptr; |
| 649 WebExternalTextureMailbox mailbox; | 649 return ImageBitmap::create(drawingBuffer()->transferToStaticBitmapImage()); |
| 650 drawingBuffer()->prepareMailbox(&mailbox, 0); | |
| 651 ImageBitmap* imageBitmap; | |
| 652 // If the mailbox is invalid, return an transparent black ImageBitmap. | |
| 653 // The only situation this could happen is when two or more calls to transfe
rToImageBitmap are made back-to-back. | |
| 654 if (mailbox.textureSize.width == 0 && mailbox.textureSize.height == 0) { | |
| 655 sk_sp<SkSurface>surface = SkSurface::MakeRasterN32Premul(drawingBuffer()
->size().width(), drawingBuffer()->size().height()); | |
| 656 imageBitmap = ImageBitmap::create(StaticBitmapImage::create(fromSkSp(sur
face->makeImageSnapshot()))); | |
| 657 } else { | |
| 658 imageBitmap = ImageBitmap::create(mailbox); | |
| 659 } | |
| 660 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmap
RenderingContext's | |
| 661 // transferFromImageBitmap, and try to use them in DrawingBuffer. | |
| 662 return imageBitmap; | |
| 663 } | 650 } |
| 664 | 651 |
| 665 namespace { | 652 namespace { |
| 666 | 653 |
| 667 // ES2 enums | 654 // ES2 enums |
| 668 static const GLenum kSupportedInternalFormatsES2[] = { | 655 static const GLenum kSupportedInternalFormatsES2[] = { |
| 669 GL_RGB, | 656 GL_RGB, |
| 670 GL_RGBA, | 657 GL_RGBA, |
| 671 GL_LUMINANCE_ALPHA, | 658 GL_LUMINANCE_ALPHA, |
| 672 GL_LUMINANCE, | 659 GL_LUMINANCE, |
| (...skipping 5831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6504 | 6491 |
| 6505 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs
creenCanvas& result) const | 6492 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs
creenCanvas& result) const |
| 6506 { | 6493 { |
| 6507 if (canvas()) | 6494 if (canvas()) |
| 6508 result.setHTMLCanvasElement(canvas()); | 6495 result.setHTMLCanvasElement(canvas()); |
| 6509 else | 6496 else |
| 6510 result.setOffscreenCanvas(getOffscreenCanvas()); | 6497 result.setOffscreenCanvas(getOffscreenCanvas()); |
| 6511 } | 6498 } |
| 6512 | 6499 |
| 6513 } // namespace blink | 6500 } // namespace blink |
| OLD | NEW |