| 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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 BackBuffer)) { | 729 BackBuffer)) { |
| 730 // copyRenderingResultsFromDrawingBuffer is expected to always succeed | 730 // copyRenderingResultsFromDrawingBuffer is expected to always succeed |
| 731 // because we've explicitly created an Accelerated surface and have already | 731 // because we've explicitly created an Accelerated surface and have already |
| 732 // validated it. | 732 // validated it. |
| 733 NOTREACHED(); | 733 NOTREACHED(); |
| 734 return nullptr; | 734 return nullptr; |
| 735 } | 735 } |
| 736 return buffer->newImageSnapshot(hint, reason); | 736 return buffer->newImageSnapshot(hint, reason); |
| 737 } | 737 } |
| 738 | 738 |
| 739 ImageData* WebGLRenderingContextBase::toImageData(SnapshotReason reason) const { |
| 740 // TODO: Furnish toImageData in webgl renderingcontext for jpeg and webp |
| 741 // images. See crbug.com/657531. |
| 742 ImageData* imageData = nullptr; |
| 743 if (this->drawingBuffer()) { |
| 744 sk_sp<SkImage> snapshot = this->drawingBuffer() |
| 745 ->transferToStaticBitmapImage() |
| 746 ->imageForCurrentFrame(); |
| 747 if (snapshot) { |
| 748 imageData = ImageData::create(this->getOffscreenCanvas()->size()); |
| 749 SkImageInfo imageInfo = SkImageInfo::Make( |
| 750 this->drawingBufferWidth(), this->drawingBufferHeight(), |
| 751 kRGBA_8888_SkColorType, kUnpremul_SkAlphaType); |
| 752 snapshot->readPixels(imageInfo, imageData->data()->data(), |
| 753 imageInfo.minRowBytes(), 0, 0); |
| 754 } |
| 755 } |
| 756 return imageData; |
| 757 } |
| 758 |
| 739 namespace { | 759 namespace { |
| 740 | 760 |
| 741 // Exposed by GL_ANGLE_depth_texture | 761 // Exposed by GL_ANGLE_depth_texture |
| 742 static const GLenum kSupportedInternalFormatsOESDepthTex[] = { | 762 static const GLenum kSupportedInternalFormatsOESDepthTex[] = { |
| 743 GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, | 763 GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, |
| 744 }; | 764 }; |
| 745 | 765 |
| 746 // Exposed by GL_EXT_sRGB | 766 // Exposed by GL_EXT_sRGB |
| 747 static const GLenum kSupportedInternalFormatsEXTsRGB[] = { | 767 static const GLenum kSupportedInternalFormatsEXTsRGB[] = { |
| 748 GL_SRGB, GL_SRGB_ALPHA_EXT, | 768 GL_SRGB, GL_SRGB_ALPHA_EXT, |
| (...skipping 6782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7531 | 7551 |
| 7532 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7552 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7533 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7553 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7534 if (canvas()) | 7554 if (canvas()) |
| 7535 result.setHTMLCanvasElement(canvas()); | 7555 result.setHTMLCanvasElement(canvas()); |
| 7536 else | 7556 else |
| 7537 result.setOffscreenCanvas(getOffscreenCanvas()); | 7557 result.setOffscreenCanvas(getOffscreenCanvas()); |
| 7538 } | 7558 } |
| 7539 | 7559 |
| 7540 } // namespace blink | 7560 } // namespace blink |
| OLD | NEW |