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

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: Rebase to ToT Created 6 years 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) 890 PassRefPtr<Uint8ClampedArray> DrawingBuffer::paintRenderingResultsToImageData(in t& width, int& height, SourceBuffer sourceBuffer)
891 { 891 {
892 if (m_actualAttributes.premultipliedAlpha) 892 if (m_actualAttributes.premultipliedAlpha)
893 return nullptr; 893 return nullptr;
894 894
895 width = size().width(); 895 width = size().width();
896 height = size().height(); 896 height = size().height();
897 897
898 Checked<int, RecordOverflow> dataSize = 4; 898 Checked<int, RecordOverflow> dataSize = 4;
899 dataSize *= width; 899 dataSize *= width;
900 dataSize *= height; 900 dataSize *= height;
901 if (dataSize.hasOverflowed()) 901 if (dataSize.hasOverflowed())
902 return nullptr; 902 return nullptr;
903 903
904 RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(wi dth * height * 4); 904 RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(wi dth * height * 4);
905 905
906 m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer()); 906 GLint fbo = 0;
907 if (sourceBuffer == Front && m_frontColorBuffer.texInfo.textureId) {
908 GLint fbo = m_context->createFramebuffer();
909 m_context->bindFramebuffer(GL_FRAMEBUFFER, fbo);
910 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL _TEXTURE_2D, m_frontColorBuffer.texInfo.textureId, 0);
911 } else {
912 m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer());
913 }
914
907 readBackFramebuffer(pixels->data(), width, height, ReadbackRGBA, WebGLImageC onversion::AlphaDoNothing); 915 readBackFramebuffer(pixels->data(), width, height, ReadbackRGBA, WebGLImageC onversion::AlphaDoNothing);
908 flipVertically(pixels->data(), width, height); 916 flipVertically(pixels->data(), width, height);
909 917
918 if (fbo) {
919 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL _TEXTURE_2D, 0, 0);
920 m_context->deleteFramebuffer(fbo);
Ken Russell (switch to Gerrit) 2014/11/26 00:49:10 Please bind either the 0 framebuffer or framebuffe
dshwang 2014/11/26 13:37:30 I intentionally don't bind FBO because WebGLRender
921 }
922
910 return pixels.release(); 923 return pixels.release();
911 } 924 }
912 925
913 void DrawingBuffer::paintFramebufferToCanvas(int framebuffer, int width, int hei ght, bool premultiplyAlpha, ImageBuffer* imageBuffer) 926 void DrawingBuffer::paintFramebufferToCanvas(int framebuffer, int width, int hei ght, bool premultiplyAlpha, ImageBuffer* imageBuffer)
914 { 927 {
915 unsigned char* pixels = 0; 928 unsigned char* pixels = 0;
916 929
917 const SkBitmap& canvasBitmap = imageBuffer->bitmap(); 930 const SkBitmap& canvasBitmap = imageBuffer->bitmap();
918 const SkBitmap* readbackBitmap = 0; 931 const SkBitmap* readbackBitmap = 0;
919 ASSERT(canvasBitmap.colorType() == kN32_SkColorType); 932 ASSERT(canvasBitmap.colorType() == kN32_SkColorType);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) 1034 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info)
1022 { 1035 {
1023 if (info->imageId) { 1036 if (info->imageId) {
1024 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); 1037 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId);
1025 m_context->destroyImageCHROMIUM(info->imageId); 1038 m_context->destroyImageCHROMIUM(info->imageId);
1026 info->imageId = 0; 1039 info->imageId = 0;
1027 } 1040 }
1028 } 1041 }
1029 1042
1030 } // namespace blink 1043 } // namespace blink
OLDNEW
« Source/core/html/HTMLCanvasElement.h ('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