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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 return ImageBitmap::create(drawingBuffer()->transferToStaticBitmapImage()); | 649 return ImageBitmap::create(drawingBuffer()->transferToStaticBitmapImage()); |
650 } | 650 } |
651 | 651 |
| 652 PassRefPtr<Image> WebGLRenderingContextBase::getImage(SnapshotReason reason) con
st |
| 653 { |
| 654 if (!drawingBuffer()) |
| 655 return nullptr; |
| 656 |
| 657 drawingBuffer()->commit(); |
| 658 IntSize size = clampedCanvasSize(); |
| 659 OpacityMode opacityMode = creationAttributes().hasAlpha() ? NonOpaque : Opaq
ue; |
| 660 std::unique_ptr<AcceleratedImageBufferSurface> surface = wrapUnique(new Acce
leratedImageBufferSurface(size, opacityMode)); |
| 661 if (!surface->isValid()) |
| 662 return nullptr; |
| 663 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(std::move(surface)
); |
| 664 if (!buffer->copyRenderingResultsFromDrawingBuffer(drawingBuffer(), BackBuff
er)) { |
| 665 // copyRenderingResultsFromDrawingBuffer is expected to always succeed b
ecause we've |
| 666 // explicitly created an Accelerated surface and have already validated
it. |
| 667 NOTREACHED(); |
| 668 return nullptr; |
| 669 } |
| 670 return buffer->newImageSnapshot(PreferAcceleration, reason); |
| 671 } |
| 672 |
652 namespace { | 673 namespace { |
653 | 674 |
654 // ES2 enums | 675 // ES2 enums |
655 static const GLenum kSupportedInternalFormatsES2[] = { | 676 static const GLenum kSupportedInternalFormatsES2[] = { |
656 GL_RGB, | 677 GL_RGB, |
657 GL_RGBA, | 678 GL_RGBA, |
658 GL_LUMINANCE_ALPHA, | 679 GL_LUMINANCE_ALPHA, |
659 GL_LUMINANCE, | 680 GL_LUMINANCE, |
660 GL_ALPHA, | 681 GL_ALPHA, |
661 }; | 682 }; |
(...skipping 5632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6294 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) | 6315 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) |
6295 { | 6316 { |
6296 if (isContextLost()) | 6317 if (isContextLost()) |
6297 return; | 6318 return; |
6298 if (enable) | 6319 if (enable) |
6299 contextGL()->Enable(capability); | 6320 contextGL()->Enable(capability); |
6300 else | 6321 else |
6301 contextGL()->Disable(capability); | 6322 contextGL()->Disable(capability); |
6302 } | 6323 } |
6303 | 6324 |
6304 IntSize WebGLRenderingContextBase::clampedCanvasSize() | 6325 IntSize WebGLRenderingContextBase::clampedCanvasSize() const |
6305 { | 6326 { |
6306 int width, height; | 6327 int width, height; |
6307 if (canvas()) { | 6328 if (canvas()) { |
6308 width = canvas()->width(); | 6329 width = canvas()->width(); |
6309 height = canvas()->height(); | 6330 height = canvas()->height(); |
6310 } else { | 6331 } else { |
6311 width = getOffscreenCanvas()->width(); | 6332 width = getOffscreenCanvas()->width(); |
6312 height = getOffscreenCanvas()->height(); | 6333 height = getOffscreenCanvas()->height(); |
6313 } | 6334 } |
6314 return IntSize(clamp(width, 1, m_maxViewportDims[0]), | 6335 return IntSize(clamp(width, 1, m_maxViewportDims[0]), |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6492 | 6513 |
6493 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs
creenCanvas& result) const | 6514 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs
creenCanvas& result) const |
6494 { | 6515 { |
6495 if (canvas()) | 6516 if (canvas()) |
6496 result.setHTMLCanvasElement(canvas()); | 6517 result.setHTMLCanvasElement(canvas()); |
6497 else | 6518 else |
6498 result.setOffscreenCanvas(getOffscreenCanvas()); | 6519 result.setOffscreenCanvas(getOffscreenCanvas()); |
6499 } | 6520 } |
6500 | 6521 |
6501 } // namespace blink | 6522 } // namespace blink |
OLD | NEW |