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

Side by Side Diff: Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 749653002: WebGL: clarify which Front or Back buffer is used by each API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 void DrawingBuffer::setPackAlignment(GLint param) 880 void DrawingBuffer::setPackAlignment(GLint param)
881 { 881 {
882 m_packAlignment = param; 882 m_packAlignment = param;
883 } 883 }
884 884
885 void DrawingBuffer::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer) 885 void DrawingBuffer::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer)
886 { 886 {
887 paintFramebufferToCanvas(framebuffer(), size().width(), size().height(), !m_ actualAttributes.premultipliedAlpha, imageBuffer); 887 paintFramebufferToCanvas(framebuffer(), size().width(), size().height(), !m_ actualAttributes.premultipliedAlpha, imageBuffer);
888 } 888 }
889 889
890 PassRefPtr<Uint8ClampedArray> DrawingBuffer::paintRenderingResultsToImageData(in t& width, int& height)
891 {
892 if (m_actualAttributes.premultipliedAlpha)
893 return nullptr;
894
895 width = size().width();
896 height = size().height();
897
898 Checked<int, RecordOverflow> dataSize = 4;
899 dataSize *= width;
900 dataSize *= height;
901 if (dataSize.hasOverflowed())
902 return nullptr;
903
904 RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(wi dth * height * 4);
905
906 m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer());
907 readBackFramebuffer(pixels->data(), width, height, ReadbackRGBA, WebGLImageC onversion::AlphaDoNothing);
908 flipVertically(pixels->data(), width, height);
909
910 return pixels.release();
911 }
912
913 void DrawingBuffer::paintFramebufferToCanvas(int framebuffer, int width, int hei ght, bool premultiplyAlpha, ImageBuffer* imageBuffer) 890 void DrawingBuffer::paintFramebufferToCanvas(int framebuffer, int width, int hei ght, bool premultiplyAlpha, ImageBuffer* imageBuffer)
914 { 891 {
915 unsigned char* pixels = 0; 892 unsigned char* pixels = 0;
916 893
917 const SkBitmap& canvasBitmap = imageBuffer->bitmap(); 894 const SkBitmap& canvasBitmap = imageBuffer->bitmap();
918 const SkBitmap* readbackBitmap = 0; 895 const SkBitmap* readbackBitmap = 0;
919 ASSERT(canvasBitmap.colorType() == kN32_SkColorType); 896 ASSERT(canvasBitmap.colorType() == kN32_SkColorType);
920 if (canvasBitmap.width() == width && canvasBitmap.height() == height) { 897 if (canvasBitmap.width() == width && canvasBitmap.height() == height) {
921 // This is the fastest and most common case. We read back 898 // This is the fastest and most common case. We read back
922 // directly into the canvas's backing store. 899 // directly into the canvas's backing store.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) 998 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info)
1022 { 999 {
1023 if (info->imageId) { 1000 if (info->imageId) {
1024 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); 1001 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId);
1025 m_context->destroyImageCHROMIUM(info->imageId); 1002 m_context->destroyImageCHROMIUM(info->imageId);
1026 info->imageId = 0; 1003 info->imageId = 0;
1027 } 1004 }
1028 } 1005 }
1029 1006
1030 } // namespace blink 1007 } // namespace blink
OLDNEW
« Source/core/html/HTMLCanvasElement.cpp ('K') | « Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698