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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 { | 635 { |
636 shouldFailContextCreationForTesting = true; | 636 shouldFailContextCreationForTesting = true; |
637 } | 637 } |
638 | 638 |
639 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase() | 639 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase() |
640 { | 640 { |
641 if (!drawingBuffer()) | 641 if (!drawingBuffer()) |
642 return nullptr; | 642 return nullptr; |
643 WebExternalTextureMailbox mailbox; | 643 WebExternalTextureMailbox mailbox; |
644 drawingBuffer()->prepareMailbox(&mailbox, 0); | 644 drawingBuffer()->prepareMailbox(&mailbox, 0); |
645 ImageBitmap* imageBitmap = ImageBitmap::create(mailbox); | 645 ImageBitmap* imageBitmap; |
| 646 // If the mailbox is invalid, return an transparent black ImageBitmap. |
| 647 // The only situation this could happen is when two or more calls to transfe
rToImageBitmap are made back-to-back. |
| 648 if (mailbox.textureSize.width == 0 && mailbox.textureSize.height == 0) { |
| 649 sk_sp<SkSurface>surface = SkSurface::MakeRasterN32Premul(drawingBuffer()
->size().width(), drawingBuffer()->size().height()); |
| 650 imageBitmap = ImageBitmap::create(StaticBitmapImage::create(fromSkSp(sur
face->makeImageSnapshot()))); |
| 651 } else { |
| 652 imageBitmap = ImageBitmap::create(mailbox); |
| 653 } |
646 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmap
RenderingContext's | 654 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmap
RenderingContext's |
647 // transferFromImageBitmap, and try to use them in DrawingBuffer. | 655 // transferFromImageBitmap, and try to use them in DrawingBuffer. |
648 return imageBitmap; | 656 return imageBitmap; |
649 } | 657 } |
650 | 658 |
651 namespace { | 659 namespace { |
652 | 660 |
653 // ES2 enums | 661 // ES2 enums |
654 static const GLenum kSupportedInternalFormatsES2[] = { | 662 static const GLenum kSupportedInternalFormatsES2[] = { |
655 GL_RGB, | 663 GL_RGB, |
(...skipping 5827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6483 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6491 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
6484 } | 6492 } |
6485 | 6493 |
6486 void WebGLRenderingContextBase::restoreUnpackParameters() | 6494 void WebGLRenderingContextBase::restoreUnpackParameters() |
6487 { | 6495 { |
6488 if (m_unpackAlignment != 1) | 6496 if (m_unpackAlignment != 1) |
6489 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6497 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
6490 } | 6498 } |
6491 | 6499 |
6492 } // namespace blink | 6500 } // namespace blink |
OLD | NEW |