Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContext.cpp

Issue 54653004: Break dependency of platform/graphics on html/ImageData.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move struct into ImageBuffer.h Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 m_drawingBuffer->bind(); 933 m_drawingBuffer->bind();
934 } 934 }
935 935
936 PassRefPtr<ImageData> WebGLRenderingContext::paintRenderingResultsToImageData() 936 PassRefPtr<ImageData> WebGLRenderingContext::paintRenderingResultsToImageData()
937 { 937 {
938 if (isContextLost()) 938 if (isContextLost())
939 return 0; 939 return 0;
940 940
941 clearIfComposited(); 941 clearIfComposited();
942 m_drawingBuffer->commit(); 942 m_drawingBuffer->commit();
943 RefPtr<ImageData> imageData = m_context->paintRenderingResultsToImageData(m_ drawingBuffer.get()); 943 int width, height;
944 RefPtr<Uint8ClampedArray> imageDataPixels = m_context->paintRenderingResults ToImageData(m_drawingBuffer.get(), width, height);
945 if (!imageDataPixels)
946 return 0;
944 947
945 if (m_framebufferBinding) 948 if (m_framebufferBinding)
946 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get())); 949 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get()));
947 else 950 else
948 m_drawingBuffer->bind(); 951 m_drawingBuffer->bind();
949 952
950 return imageData; 953 return ImageData::create(IntSize(width, height), imageDataPixels);
951 } 954 }
952 955
953 void WebGLRenderingContext::reshape(int width, int height) 956 void WebGLRenderingContext::reshape(int width, int height)
954 { 957 {
955 if (isContextLost()) 958 if (isContextLost())
956 return; 959 return;
957 960
958 // This is an approximation because at WebGLRenderingContext level we don't 961 // This is an approximation because at WebGLRenderingContext level we don't
959 // know if the underlying FBO uses textures or renderbuffers. 962 // know if the underlying FBO uses textures or renderbuffers.
960 GC3Dint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize); 963 GC3Dint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize);
(...skipping 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after
3428 { 3431 {
3429 if (isContextLost() || !pixels || !validateTexFunc("texImage2D", NotTexSubIm age2D, SourceImageData, target, level, internalformat, pixels->width(), pixels-> height(), 0, format, type, 0, 0)) 3432 if (isContextLost() || !pixels || !validateTexFunc("texImage2D", NotTexSubIm age2D, SourceImageData, target, level, internalformat, pixels->width(), pixels-> height(), 0, format, type, 0, 0))
3430 return; 3433 return;
3431 Vector<uint8_t> data; 3434 Vector<uint8_t> data;
3432 bool needConversion = true; 3435 bool needConversion = true;
3433 // The data from ImageData is always of format RGBA8. 3436 // The data from ImageData is always of format RGBA8.
3434 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required. 3437 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required.
3435 if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GraphicsContext 3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE) 3438 if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GraphicsContext 3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE)
3436 needConversion = false; 3439 needConversion = false;
3437 else { 3440 else {
3438 if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_ unpackPremultiplyAlpha, data)) { 3441 if (!m_context->extractImageData(pixels->data()->data(), pixels->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
3439 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "b ad image data"); 3442 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "b ad image data");
3440 return; 3443 return;
3441 } 3444 }
3442 } 3445 }
3443 if (m_unpackAlignment != 1) 3446 if (m_unpackAlignment != 1)
3444 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); 3447 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
3445 texImage2DBase(target, level, internalformat, pixels->width(), pixels->heigh t(), 0, format, type, needConversion ? data.data() : pixels->data()->data(), es) ; 3448 texImage2DBase(target, level, internalformat, pixels->width(), pixels->heigh t(), 0, format, type, needConversion ? data.data() : pixels->data()->data(), es) ;
3446 if (m_unpackAlignment != 1) 3449 if (m_unpackAlignment != 1)
3447 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); 3450 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment);
3448 } 3451 }
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
3667 if (isContextLost() || !pixels || !validateTexFunc("texSubImage2D", TexSubIm age2D, SourceImageData, target, level, format, pixels->width(), pixels->height( ), 0, format, type, xoffset, yoffset)) 3670 if (isContextLost() || !pixels || !validateTexFunc("texSubImage2D", TexSubIm age2D, SourceImageData, target, level, format, pixels->width(), pixels->height( ), 0, format, type, xoffset, yoffset))
3668 return; 3671 return;
3669 3672
3670 Vector<uint8_t> data; 3673 Vector<uint8_t> data;
3671 bool needConversion = true; 3674 bool needConversion = true;
3672 // The data from ImageData is always of format RGBA8. 3675 // The data from ImageData is always of format RGBA8.
3673 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required. 3676 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required.
3674 if (format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED _BYTE && !m_unpackFlipY && !m_unpackPremultiplyAlpha) 3677 if (format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED _BYTE && !m_unpackFlipY && !m_unpackPremultiplyAlpha)
3675 needConversion = false; 3678 needConversion = false;
3676 else { 3679 else {
3677 if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_ unpackPremultiplyAlpha, data)) { 3680 if (!m_context->extractImageData(pixels->data()->data(), pixels->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
3678 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data"); 3681 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data");
3679 return; 3682 return;
3680 } 3683 }
3681 } 3684 }
3682 if (m_unpackAlignment != 1) 3685 if (m_unpackAlignment != 1)
3683 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); 3686 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
3684 texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels-> height(), format, type, needConversion ? data.data() : pixels->data()->data(), e s); 3687 texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels-> height(), format, type, needConversion ? data.data() : pixels->data()->data(), e s);
3685 if (m_unpackAlignment != 1) 3688 if (m_unpackAlignment != 1)
3686 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); 3689 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment);
3687 } 3690 }
(...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after
5637 if (m_textureUnits[i].m_texture2DBinding 5640 if (m_textureUnits[i].m_texture2DBinding
5638 || m_textureUnits[i].m_textureCubeMapBinding) { 5641 || m_textureUnits[i].m_textureCubeMapBinding) {
5639 m_onePlusMaxNonDefaultTextureUnit = i + 1; 5642 m_onePlusMaxNonDefaultTextureUnit = i + 1;
5640 return; 5643 return;
5641 } 5644 }
5642 } 5645 }
5643 m_onePlusMaxNonDefaultTextureUnit = 0; 5646 m_onePlusMaxNonDefaultTextureUnit = 0;
5644 } 5647 }
5645 5648
5646 } // namespace WebCore 5649 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/HTMLCanvasElement.cpp ('k') | Source/core/platform/graphics/GraphicsContext3D.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698