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

Unified Diff: Source/core/platform/graphics/GraphicsContext3D.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 side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/graphics/GraphicsContext3D.cpp
diff --git a/Source/core/platform/graphics/GraphicsContext3D.cpp b/Source/core/platform/graphics/GraphicsContext3D.cpp
index 24b0cc67f79d1c15065ab1b9ce5012d3d669c79e..5cbb46490b755566d4ae7a0373009b0366f69a04 100644
--- a/Source/core/platform/graphics/GraphicsContext3D.cpp
+++ b/Source/core/platform/graphics/GraphicsContext3D.cpp
@@ -29,7 +29,6 @@
#include "core/platform/graphics/GraphicsContext3D.h"
-#include "core/html/ImageData.h"
#include "core/platform/graphics/Extensions3D.h"
#include "core/platform/graphics/GraphicsContext.h"
#include "core/platform/graphics/Image.h"
@@ -524,23 +523,27 @@ void GraphicsContext3D::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer,
paintFramebufferToCanvas(framebufferId, width, height, !getContextAttributes().premultipliedAlpha, imageBuffer);
}
-PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData(DrawingBuffer* drawingBuffer)
+PassRefPtr<Uint8ClampedArray> GraphicsContext3D::paintRenderingResultsToImageData(DrawingBuffer* drawingBuffer, int& width, int& height)
{
if (getContextAttributes().premultipliedAlpha)
return 0;
Platform3DObject framebufferId;
- int width, height;
getDrawingParameters(drawingBuffer, m_impl, &framebufferId, &width, &height);
- RefPtr<ImageData> imageData = ImageData::create(IntSize(width, height));
- unsigned char* pixels = imageData->data()->data();
+ Checked<int, RecordOverflow> dataSize = 4;
+ dataSize *= width;
+ dataSize *= height;
+ if (dataSize.hasOverflowed())
+ return 0;
+
+ RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(width * height * 4);
m_impl->bindFramebuffer(FRAMEBUFFER, framebufferId);
- readBackFramebuffer(pixels, width, height, ReadbackRGBA, AlphaDoNothing);
- flipVertically(pixels, width, height);
+ readBackFramebuffer(pixels->data(), width, height, ReadbackRGBA, AlphaDoNothing);
+ flipVertically(pixels->data(), width, height);
- return imageData.release();
+ return pixels.release();
}
void GraphicsContext3D::readBackFramebuffer(unsigned char* pixels, int width, int height, ReadbackOrder readbackOrder, AlphaOp op)
« no previous file with comments | « Source/core/platform/graphics/GraphicsContext3D.h ('k') | Source/core/platform/graphics/GraphicsContext3DImagePacking.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698