| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 4 * Copyright (C) 2010 Mozilla Corporation. All rights reserved. | 4 * Copyright (C) 2010 Mozilla Corporation. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 DELEGATE_TO_WEBCONTEXT_1R(isFramebuffer, Platform3DObject, GC3Dboolean) | 423 DELEGATE_TO_WEBCONTEXT_1R(isFramebuffer, Platform3DObject, GC3Dboolean) |
| 424 DELEGATE_TO_WEBCONTEXT_1R(isProgram, Platform3DObject, GC3Dboolean) | 424 DELEGATE_TO_WEBCONTEXT_1R(isProgram, Platform3DObject, GC3Dboolean) |
| 425 DELEGATE_TO_WEBCONTEXT_1R(isRenderbuffer, Platform3DObject, GC3Dboolean) | 425 DELEGATE_TO_WEBCONTEXT_1R(isRenderbuffer, Platform3DObject, GC3Dboolean) |
| 426 DELEGATE_TO_WEBCONTEXT_1R(isShader, Platform3DObject, GC3Dboolean) | 426 DELEGATE_TO_WEBCONTEXT_1R(isShader, Platform3DObject, GC3Dboolean) |
| 427 DELEGATE_TO_WEBCONTEXT_1R(isTexture, Platform3DObject, GC3Dboolean) | 427 DELEGATE_TO_WEBCONTEXT_1R(isTexture, Platform3DObject, GC3Dboolean) |
| 428 DELEGATE_TO_WEBCONTEXT_1(lineWidth, GC3Dfloat) | 428 DELEGATE_TO_WEBCONTEXT_1(lineWidth, GC3Dfloat) |
| 429 DELEGATE_TO_WEBCONTEXT_1(linkProgram, Platform3DObject) | 429 DELEGATE_TO_WEBCONTEXT_1(linkProgram, Platform3DObject) |
| 430 | 430 |
| 431 void GraphicsContext3D::pixelStorei(GC3Denum pname, GC3Dint param) | 431 void GraphicsContext3D::pixelStorei(GC3Denum pname, GC3Dint param) |
| 432 { | 432 { |
| 433 if (pname == PACK_ALIGNMENT) | 433 if (pname == GL_PACK_ALIGNMENT) |
| 434 m_packAlignment = param; | 434 m_packAlignment = param; |
| 435 m_impl->pixelStorei(pname, param); | 435 m_impl->pixelStorei(pname, param); |
| 436 } | 436 } |
| 437 | 437 |
| 438 DELEGATE_TO_WEBCONTEXT_2(polygonOffset, GC3Dfloat, GC3Dfloat) | 438 DELEGATE_TO_WEBCONTEXT_2(polygonOffset, GC3Dfloat, GC3Dfloat) |
| 439 | 439 |
| 440 DELEGATE_TO_WEBCONTEXT_7(readPixels, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3
Denum, GC3Denum, void*) | 440 DELEGATE_TO_WEBCONTEXT_7(readPixels, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3
Denum, GC3Denum, void*) |
| 441 | 441 |
| 442 DELEGATE_TO_WEBCONTEXT(releaseShaderCompiler) | 442 DELEGATE_TO_WEBCONTEXT(releaseShaderCompiler) |
| 443 DELEGATE_TO_WEBCONTEXT_4(renderbufferStorage, GC3Denum, GC3Denum, GC3Dsizei, GC3
Dsizei) | 443 DELEGATE_TO_WEBCONTEXT_4(renderbufferStorage, GC3Denum, GC3Denum, GC3Dsizei, GC3
Dsizei) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 getDrawingParameters(drawingBuffer, m_impl, &framebufferId, &width, &height)
; | 528 getDrawingParameters(drawingBuffer, m_impl, &framebufferId, &width, &height)
; |
| 529 | 529 |
| 530 Checked<int, RecordOverflow> dataSize = 4; | 530 Checked<int, RecordOverflow> dataSize = 4; |
| 531 dataSize *= width; | 531 dataSize *= width; |
| 532 dataSize *= height; | 532 dataSize *= height; |
| 533 if (dataSize.hasOverflowed()) | 533 if (dataSize.hasOverflowed()) |
| 534 return 0; | 534 return 0; |
| 535 | 535 |
| 536 RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(wi
dth * height * 4); | 536 RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(wi
dth * height * 4); |
| 537 | 537 |
| 538 m_impl->bindFramebuffer(FRAMEBUFFER, framebufferId); | 538 m_impl->bindFramebuffer(GL_FRAMEBUFFER, framebufferId); |
| 539 readBackFramebuffer(pixels->data(), width, height, ReadbackRGBA, AlphaDoNoth
ing); | 539 readBackFramebuffer(pixels->data(), width, height, ReadbackRGBA, AlphaDoNoth
ing); |
| 540 flipVertically(pixels->data(), width, height); | 540 flipVertically(pixels->data(), width, height); |
| 541 | 541 |
| 542 return pixels.release(); | 542 return pixels.release(); |
| 543 } | 543 } |
| 544 | 544 |
| 545 void GraphicsContext3D::readBackFramebuffer(unsigned char* pixels, int width, in
t height, ReadbackOrder readbackOrder, AlphaOp op) | 545 void GraphicsContext3D::readBackFramebuffer(unsigned char* pixels, int width, in
t height, ReadbackOrder readbackOrder, AlphaOp op) |
| 546 { | 546 { |
| 547 if (m_packAlignment > 4) | 547 if (m_packAlignment > 4) |
| 548 m_impl->pixelStorei(PACK_ALIGNMENT, 1); | 548 m_impl->pixelStorei(GL_PACK_ALIGNMENT, 1); |
| 549 m_impl->readPixels(0, 0, width, height, RGBA, UNSIGNED_BYTE, pixels); | 549 m_impl->readPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 550 if (m_packAlignment > 4) | 550 if (m_packAlignment > 4) |
| 551 m_impl->pixelStorei(PACK_ALIGNMENT, m_packAlignment); | 551 m_impl->pixelStorei(GL_PACK_ALIGNMENT, m_packAlignment); |
| 552 | 552 |
| 553 size_t bufferSize = 4 * width * height; | 553 size_t bufferSize = 4 * width * height; |
| 554 | 554 |
| 555 if (readbackOrder == ReadbackSkia) { | 555 if (readbackOrder == ReadbackSkia) { |
| 556 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT | 556 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT |
| 557 // Swizzle red and blue channels to match SkBitmap's byte ordering. | 557 // Swizzle red and blue channels to match SkBitmap's byte ordering. |
| 558 // TODO(kbr): expose GL_BGRA as extension. | 558 // TODO(kbr): expose GL_BGRA as extension. |
| 559 for (size_t i = 0; i < bufferSize; i += 4) { | 559 for (size_t i = 0; i < bufferSize; i += 4) { |
| 560 std::swap(pixels[i], pixels[i + 2]); | 560 std::swap(pixels[i], pixels[i + 2]); |
| 561 } | 561 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 texImage2D(target, level, internalformat, width, height, border, format, typ
e, 0); | 602 texImage2D(target, level, internalformat, width, height, border, format, typ
e, 0); |
| 603 return true; | 603 return true; |
| 604 } | 604 } |
| 605 | 605 |
| 606 bool GraphicsContext3D::computeFormatAndTypeParameters(GC3Denum format, | 606 bool GraphicsContext3D::computeFormatAndTypeParameters(GC3Denum format, |
| 607 GC3Denum type, | 607 GC3Denum type, |
| 608 unsigned int* componentsP
erPixel, | 608 unsigned int* componentsP
erPixel, |
| 609 unsigned int* bytesPerCom
ponent) | 609 unsigned int* bytesPerCom
ponent) |
| 610 { | 610 { |
| 611 switch (format) { | 611 switch (format) { |
| 612 case GraphicsContext3D::ALPHA: | 612 case GL_ALPHA: |
| 613 case GraphicsContext3D::LUMINANCE: | 613 case GL_LUMINANCE: |
| 614 case GraphicsContext3D::DEPTH_COMPONENT: | 614 case GL_DEPTH_COMPONENT: |
| 615 case GraphicsContext3D::DEPTH_STENCIL: | 615 case GL_DEPTH_STENCIL_OES: |
| 616 *componentsPerPixel = 1; | 616 *componentsPerPixel = 1; |
| 617 break; | 617 break; |
| 618 case GraphicsContext3D::LUMINANCE_ALPHA: | 618 case GL_LUMINANCE_ALPHA: |
| 619 *componentsPerPixel = 2; | 619 *componentsPerPixel = 2; |
| 620 break; | 620 break; |
| 621 case GraphicsContext3D::RGB: | 621 case GL_RGB: |
| 622 *componentsPerPixel = 3; | 622 *componentsPerPixel = 3; |
| 623 break; | 623 break; |
| 624 case GraphicsContext3D::RGBA: | 624 case GL_RGBA: |
| 625 case Extensions3D::BGRA_EXT: // GL_EXT_texture_format_BGRA8888 | 625 case Extensions3D::BGRA_EXT: // GL_EXT_texture_format_BGRA8888 |
| 626 *componentsPerPixel = 4; | 626 *componentsPerPixel = 4; |
| 627 break; | 627 break; |
| 628 default: | 628 default: |
| 629 return false; | 629 return false; |
| 630 } | 630 } |
| 631 switch (type) { | 631 switch (type) { |
| 632 case GraphicsContext3D::UNSIGNED_BYTE: | 632 case GL_UNSIGNED_BYTE: |
| 633 *bytesPerComponent = sizeof(GC3Dubyte); | 633 *bytesPerComponent = sizeof(GC3Dubyte); |
| 634 break; | 634 break; |
| 635 case GraphicsContext3D::UNSIGNED_SHORT: | 635 case GL_UNSIGNED_SHORT: |
| 636 *bytesPerComponent = sizeof(GC3Dushort); | 636 *bytesPerComponent = sizeof(GC3Dushort); |
| 637 break; | 637 break; |
| 638 case GraphicsContext3D::UNSIGNED_SHORT_5_6_5: | 638 case GL_UNSIGNED_SHORT_5_6_5: |
| 639 case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4: | 639 case GL_UNSIGNED_SHORT_4_4_4_4: |
| 640 case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1: | 640 case GL_UNSIGNED_SHORT_5_5_5_1: |
| 641 *componentsPerPixel = 1; | 641 *componentsPerPixel = 1; |
| 642 *bytesPerComponent = sizeof(GC3Dushort); | 642 *bytesPerComponent = sizeof(GC3Dushort); |
| 643 break; | 643 break; |
| 644 case GraphicsContext3D::UNSIGNED_INT_24_8: | 644 case GL_UNSIGNED_INT_24_8_OES: |
| 645 case GraphicsContext3D::UNSIGNED_INT: | 645 case GL_UNSIGNED_INT: |
| 646 *bytesPerComponent = sizeof(GC3Duint); | 646 *bytesPerComponent = sizeof(GC3Duint); |
| 647 break; | 647 break; |
| 648 case GraphicsContext3D::FLOAT: // OES_texture_float | 648 case GL_FLOAT: // OES_texture_float |
| 649 *bytesPerComponent = sizeof(GC3Dfloat); | 649 *bytesPerComponent = sizeof(GC3Dfloat); |
| 650 break; | 650 break; |
| 651 case GraphicsContext3D::HALF_FLOAT_OES: // OES_texture_half_float | 651 case GL_HALF_FLOAT_OES: // OES_texture_half_float |
| 652 *bytesPerComponent = sizeof(GC3Dhalffloat); | 652 *bytesPerComponent = sizeof(GC3Dhalffloat); |
| 653 break; | 653 break; |
| 654 default: | 654 default: |
| 655 return false; | 655 return false; |
| 656 } | 656 } |
| 657 return true; | 657 return true; |
| 658 } | 658 } |
| 659 | 659 |
| 660 GC3Denum GraphicsContext3D::computeImageSizeInBytes(GC3Denum format, GC3Denum ty
pe, GC3Dsizei width, GC3Dsizei height, GC3Dint alignment, | 660 GC3Denum GraphicsContext3D::computeImageSizeInBytes(GC3Denum format, GC3Denum ty
pe, GC3Dsizei width, GC3Dsizei height, GC3Dint alignment, |
| 661 unsigned int* imageSizeInByt
es, unsigned int* paddingInBytes) | 661 unsigned int* imageSizeInByt
es, unsigned int* paddingInBytes) |
| 662 { | 662 { |
| 663 ASSERT(imageSizeInBytes); | 663 ASSERT(imageSizeInBytes); |
| 664 ASSERT(alignment == 1 || alignment == 2 || alignment == 4 || alignment == 8)
; | 664 ASSERT(alignment == 1 || alignment == 2 || alignment == 4 || alignment == 8)
; |
| 665 if (width < 0 || height < 0) | 665 if (width < 0 || height < 0) |
| 666 return GraphicsContext3D::INVALID_VALUE; | 666 return GL_INVALID_VALUE; |
| 667 unsigned int bytesPerComponent, componentsPerPixel; | 667 unsigned int bytesPerComponent, componentsPerPixel; |
| 668 if (!computeFormatAndTypeParameters(format, type, &bytesPerComponent, &compo
nentsPerPixel)) | 668 if (!computeFormatAndTypeParameters(format, type, &bytesPerComponent, &compo
nentsPerPixel)) |
| 669 return GraphicsContext3D::INVALID_ENUM; | 669 return GL_INVALID_ENUM; |
| 670 if (!width || !height) { | 670 if (!width || !height) { |
| 671 *imageSizeInBytes = 0; | 671 *imageSizeInBytes = 0; |
| 672 if (paddingInBytes) | 672 if (paddingInBytes) |
| 673 *paddingInBytes = 0; | 673 *paddingInBytes = 0; |
| 674 return GraphicsContext3D::NO_ERROR; | 674 return GL_NO_ERROR; |
| 675 } | 675 } |
| 676 CheckedInt<uint32_t> checkedValue(bytesPerComponent * componentsPerPixel); | 676 CheckedInt<uint32_t> checkedValue(bytesPerComponent * componentsPerPixel); |
| 677 checkedValue *= width; | 677 checkedValue *= width; |
| 678 if (!checkedValue.isValid()) | 678 if (!checkedValue.isValid()) |
| 679 return GraphicsContext3D::INVALID_VALUE; | 679 return GL_INVALID_VALUE; |
| 680 unsigned int validRowSize = checkedValue.value(); | 680 unsigned int validRowSize = checkedValue.value(); |
| 681 unsigned int padding = 0; | 681 unsigned int padding = 0; |
| 682 unsigned int residual = validRowSize % alignment; | 682 unsigned int residual = validRowSize % alignment; |
| 683 if (residual) { | 683 if (residual) { |
| 684 padding = alignment - residual; | 684 padding = alignment - residual; |
| 685 checkedValue += padding; | 685 checkedValue += padding; |
| 686 } | 686 } |
| 687 // Last row needs no padding. | 687 // Last row needs no padding. |
| 688 checkedValue *= (height - 1); | 688 checkedValue *= (height - 1); |
| 689 checkedValue += validRowSize; | 689 checkedValue += validRowSize; |
| 690 if (!checkedValue.isValid()) | 690 if (!checkedValue.isValid()) |
| 691 return GraphicsContext3D::INVALID_VALUE; | 691 return GL_INVALID_VALUE; |
| 692 *imageSizeInBytes = checkedValue.value(); | 692 *imageSizeInBytes = checkedValue.value(); |
| 693 if (paddingInBytes) | 693 if (paddingInBytes) |
| 694 *paddingInBytes = padding; | 694 *paddingInBytes = padding; |
| 695 return GraphicsContext3D::NO_ERROR; | 695 return GL_NO_ERROR; |
| 696 } | 696 } |
| 697 | 697 |
| 698 GraphicsContext3D::ImageExtractor::ImageExtractor(Image* image, ImageHtmlDomSour
ce imageHtmlDomSource, bool premultiplyAlpha, bool ignoreGammaAndColorProfile) | 698 GraphicsContext3D::ImageExtractor::ImageExtractor(Image* image, ImageHtmlDomSour
ce imageHtmlDomSource, bool premultiplyAlpha, bool ignoreGammaAndColorProfile) |
| 699 { | 699 { |
| 700 m_image = image; | 700 m_image = image; |
| 701 m_imageHtmlDomSource = imageHtmlDomSource; | 701 m_imageHtmlDomSource = imageHtmlDomSource; |
| 702 m_extractSucceeded = extractImage(premultiplyAlpha, ignoreGammaAndColorProfi
le); | 702 m_extractSucceeded = extractImage(premultiplyAlpha, ignoreGammaAndColorProfi
le); |
| 703 } | 703 } |
| 704 | 704 |
| 705 GraphicsContext3D::ImageExtractor::~ImageExtractor() | 705 GraphicsContext3D::ImageExtractor::~ImageExtractor() |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 return false; | 756 return false; |
| 757 m_imageSourceUnpackAlignment = 0; | 757 m_imageSourceUnpackAlignment = 0; |
| 758 m_skiaImage->bitmap().lockPixels(); | 758 m_skiaImage->bitmap().lockPixels(); |
| 759 m_imagePixelData = m_skiaImage->bitmap().getPixels(); | 759 m_imagePixelData = m_skiaImage->bitmap().getPixels(); |
| 760 return true; | 760 return true; |
| 761 } | 761 } |
| 762 | 762 |
| 763 unsigned GraphicsContext3D::getClearBitsByFormat(GC3Denum format) | 763 unsigned GraphicsContext3D::getClearBitsByFormat(GC3Denum format) |
| 764 { | 764 { |
| 765 switch (format) { | 765 switch (format) { |
| 766 case GraphicsContext3D::ALPHA: | 766 case GL_ALPHA: |
| 767 case GraphicsContext3D::LUMINANCE: | 767 case GL_LUMINANCE: |
| 768 case GraphicsContext3D::LUMINANCE_ALPHA: | 768 case GL_LUMINANCE_ALPHA: |
| 769 case GraphicsContext3D::RGB: | 769 case GL_RGB: |
| 770 case GraphicsContext3D::RGB565: | 770 case GL_RGB565: |
| 771 case GraphicsContext3D::RGBA: | 771 case GL_RGBA: |
| 772 case GraphicsContext3D::RGBA4: | 772 case GL_RGBA4: |
| 773 case GraphicsContext3D::RGB5_A1: | 773 case GL_RGB5_A1: |
| 774 return GraphicsContext3D::COLOR_BUFFER_BIT; | 774 return GL_COLOR_BUFFER_BIT; |
| 775 case GraphicsContext3D::DEPTH_COMPONENT16: | 775 case GL_DEPTH_COMPONENT16: |
| 776 case GraphicsContext3D::DEPTH_COMPONENT: | 776 case GL_DEPTH_COMPONENT: |
| 777 return GraphicsContext3D::DEPTH_BUFFER_BIT; | 777 return GL_DEPTH_BUFFER_BIT; |
| 778 case GraphicsContext3D::STENCIL_INDEX8: | 778 case GL_STENCIL_INDEX8: |
| 779 return GraphicsContext3D::STENCIL_BUFFER_BIT; | 779 return GL_STENCIL_BUFFER_BIT; |
| 780 case GraphicsContext3D::DEPTH_STENCIL: | 780 case GL_DEPTH_STENCIL_OES: |
| 781 return GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_
BUFFER_BIT; | 781 return GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; |
| 782 default: | 782 default: |
| 783 return 0; | 783 return 0; |
| 784 } | 784 } |
| 785 } | 785 } |
| 786 | 786 |
| 787 unsigned GraphicsContext3D::getChannelBitsByFormat(GC3Denum format) | 787 unsigned GraphicsContext3D::getChannelBitsByFormat(GC3Denum format) |
| 788 { | 788 { |
| 789 switch (format) { | 789 switch (format) { |
| 790 case GraphicsContext3D::ALPHA: | 790 case GL_ALPHA: |
| 791 return ChannelAlpha; | 791 return ChannelAlpha; |
| 792 case GraphicsContext3D::LUMINANCE: | 792 case GL_LUMINANCE: |
| 793 return ChannelRGB; | 793 return ChannelRGB; |
| 794 case GraphicsContext3D::LUMINANCE_ALPHA: | 794 case GL_LUMINANCE_ALPHA: |
| 795 return ChannelRGBA; | 795 return ChannelRGBA; |
| 796 case GraphicsContext3D::RGB: | 796 case GL_RGB: |
| 797 case GraphicsContext3D::RGB565: | 797 case GL_RGB565: |
| 798 return ChannelRGB; | 798 return ChannelRGB; |
| 799 case GraphicsContext3D::RGBA: | 799 case GL_RGBA: |
| 800 case GraphicsContext3D::RGBA4: | 800 case GL_RGBA4: |
| 801 case GraphicsContext3D::RGB5_A1: | 801 case GL_RGB5_A1: |
| 802 return ChannelRGBA; | 802 return ChannelRGBA; |
| 803 case GraphicsContext3D::DEPTH_COMPONENT16: | 803 case GL_DEPTH_COMPONENT16: |
| 804 case GraphicsContext3D::DEPTH_COMPONENT: | 804 case GL_DEPTH_COMPONENT: |
| 805 return ChannelDepth; | 805 return ChannelDepth; |
| 806 case GraphicsContext3D::STENCIL_INDEX8: | 806 case GL_STENCIL_INDEX8: |
| 807 return ChannelStencil; | 807 return ChannelStencil; |
| 808 case GraphicsContext3D::DEPTH_STENCIL: | 808 case GL_DEPTH_STENCIL_OES: |
| 809 return ChannelDepth | ChannelStencil; | 809 return ChannelDepth | ChannelStencil; |
| 810 default: | 810 default: |
| 811 return 0; | 811 return 0; |
| 812 } | 812 } |
| 813 } | 813 } |
| 814 | 814 |
| 815 void GraphicsContext3D::paintFramebufferToCanvas(int framebuffer, int width, int
height, bool premultiplyAlpha, ImageBuffer* imageBuffer) | 815 void GraphicsContext3D::paintFramebufferToCanvas(int framebuffer, int width, int
height, bool premultiplyAlpha, ImageBuffer* imageBuffer) |
| 816 { | 816 { |
| 817 unsigned char* pixels = 0; | 817 unsigned char* pixels = 0; |
| 818 | 818 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 833 if (!m_resizingBitmap.allocPixels()) | 833 if (!m_resizingBitmap.allocPixels()) |
| 834 return; | 834 return; |
| 835 } | 835 } |
| 836 readbackBitmap = &m_resizingBitmap; | 836 readbackBitmap = &m_resizingBitmap; |
| 837 } | 837 } |
| 838 | 838 |
| 839 // Read back the frame buffer. | 839 // Read back the frame buffer. |
| 840 SkAutoLockPixels bitmapLock(*readbackBitmap); | 840 SkAutoLockPixels bitmapLock(*readbackBitmap); |
| 841 pixels = static_cast<unsigned char*>(readbackBitmap->getPixels()); | 841 pixels = static_cast<unsigned char*>(readbackBitmap->getPixels()); |
| 842 | 842 |
| 843 m_impl->bindFramebuffer(FRAMEBUFFER, framebuffer); | 843 m_impl->bindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
| 844 readBackFramebuffer(pixels, width, height, ReadbackSkia, premultiplyAlpha ?
AlphaDoPremultiply : AlphaDoNothing); | 844 readBackFramebuffer(pixels, width, height, ReadbackSkia, premultiplyAlpha ?
AlphaDoPremultiply : AlphaDoNothing); |
| 845 flipVertically(pixels, width, height); | 845 flipVertically(pixels, width, height); |
| 846 | 846 |
| 847 readbackBitmap->notifyPixelsChanged(); | 847 readbackBitmap->notifyPixelsChanged(); |
| 848 if (m_resizingBitmap.readyToDraw()) { | 848 if (m_resizingBitmap.readyToDraw()) { |
| 849 // We need to draw the resizing bitmap into the canvas's backing store. | 849 // We need to draw the resizing bitmap into the canvas's backing store. |
| 850 SkCanvas canvas(*canvasBitmap); | 850 SkCanvas canvas(*canvasBitmap); |
| 851 SkRect dst; | 851 SkRect dst; |
| 852 dst.set(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(canvasBitmap->
width()), SkIntToScalar(canvasBitmap->height())); | 852 dst.set(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(canvasBitmap->
width()), SkIntToScalar(canvasBitmap->height())); |
| 853 canvas.drawBitmapRect(m_resizingBitmap, 0, dst); | 853 canvas.drawBitmapRect(m_resizingBitmap, 0, dst); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 878 { | 878 { |
| 879 if (m_initializedAvailableExtensions) | 879 if (m_initializedAvailableExtensions) |
| 880 return; | 880 return; |
| 881 | 881 |
| 882 m_initializedAvailableExtensions = true; | 882 m_initializedAvailableExtensions = true; |
| 883 bool success = m_impl->makeContextCurrent(); | 883 bool success = m_impl->makeContextCurrent(); |
| 884 ASSERT(success); | 884 ASSERT(success); |
| 885 if (!success) | 885 if (!success) |
| 886 return; | 886 return; |
| 887 | 887 |
| 888 String extensionsString = m_impl->getString(GraphicsContext3D::EXTENSIONS); | 888 String extensionsString = m_impl->getString(GL_EXTENSIONS); |
| 889 splitStringHelper(extensionsString, m_enabledExtensions); | 889 splitStringHelper(extensionsString, m_enabledExtensions); |
| 890 | 890 |
| 891 String requestableExtensionsString = m_impl->getRequestableExtensionsCHROMIU
M(); | 891 String requestableExtensionsString = m_impl->getRequestableExtensionsCHROMIU
M(); |
| 892 splitStringHelper(requestableExtensionsString, m_requestableExtensions); | 892 splitStringHelper(requestableExtensionsString, m_requestableExtensions); |
| 893 } | 893 } |
| 894 | 894 |
| 895 | 895 |
| 896 bool GraphicsContext3D::supportsExtension(const String& name) | 896 bool GraphicsContext3D::supportsExtension(const String& name) |
| 897 { | 897 { |
| 898 initializeExtensions(); | 898 initializeExtensions(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 for (unsigned i = 0; i < count; i++) { | 936 for (unsigned i = 0; i < count; i++) { |
| 937 uint8* rowA = framebuffer + i * rowBytes; | 937 uint8* rowA = framebuffer + i * rowBytes; |
| 938 uint8* rowB = framebuffer + (height - i - 1) * rowBytes; | 938 uint8* rowB = framebuffer + (height - i - 1) * rowBytes; |
| 939 memcpy(scanline, rowB, rowBytes); | 939 memcpy(scanline, rowB, rowBytes); |
| 940 memcpy(rowB, rowA, rowBytes); | 940 memcpy(rowB, rowA, rowBytes); |
| 941 memcpy(rowA, scanline, rowBytes); | 941 memcpy(rowA, scanline, rowBytes); |
| 942 } | 942 } |
| 943 } | 943 } |
| 944 | 944 |
| 945 } // namespace WebCore | 945 } // namespace WebCore |
| OLD | NEW |