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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2249853008: Reject createImageBitmap promise when the cropRect or resize is too big (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update tests Created 4 years, 3 months 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
« no previous file with comments | « third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4507 matching lines...) Expand 10 before | Expand all | Expand 10 after
4518 if (functionID == TexImage2D) { 4518 if (functionID == TexImage2D) {
4519 texImage2DBase(target, level, internalformat, bitmap->width(), bitma p->height(), 0, format, type, 0); 4519 texImage2DBase(target, level, internalformat, bitmap->width(), bitma p->height(), 0, format, type, 0);
4520 texImageByGPU(TexImage2DByGPU, texture, target, level, internalforma t, type, 0, 0, 0, bitmap); 4520 texImageByGPU(TexImage2DByGPU, texture, target, level, internalforma t, type, 0, 0, 0, bitmap);
4521 } else if (functionID == TexSubImage2D) { 4521 } else if (functionID == TexSubImage2D) {
4522 texImageByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, t ype, xoffset, yoffset, 0, bitmap); 4522 texImageByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, t ype, xoffset, yoffset, 0, bitmap);
4523 } 4523 }
4524 return; 4524 return;
4525 } 4525 }
4526 RefPtr<SkImage> skImage = bitmap->bitmapImage()->imageForCurrentFrame(); 4526 RefPtr<SkImage> skImage = bitmap->bitmapImage()->imageForCurrentFrame();
4527 SkPixmap pixmap; 4527 SkPixmap pixmap;
4528 std::unique_ptr<uint8_t[]> pixelData;
4529 uint8_t* pixelDataPtr = nullptr; 4528 uint8_t* pixelDataPtr = nullptr;
4529 RefPtr<Uint8Array> pixelData;
4530 // In the case where an ImageBitmap is not texture backed, peekPixels() alwa ys succeed. 4530 // In the case where an ImageBitmap is not texture backed, peekPixels() alwa ys succeed.
4531 // However, when it is texture backed and !canUseTexImageByGPU, we do a GPU read back. 4531 // However, when it is texture backed and !canUseTexImageByGPU, we do a GPU read back.
4532 bool peekSucceed = skImage->peekPixels(&pixmap); 4532 bool peekSucceed = skImage->peekPixels(&pixmap);
4533 if (peekSucceed) { 4533 if (peekSucceed) {
4534 pixelDataPtr = static_cast<uint8_t*>(pixmap.writable_addr()); 4534 pixelDataPtr = static_cast<uint8_t*>(pixmap.writable_addr());
4535 } else { 4535 } else {
4536 pixelData = bitmap->copyBitmapData(bitmap->isPremultiplied() ? Premultip lyAlpha : DontPremultiplyAlpha); 4536 pixelData = bitmap->copyBitmapData(bitmap->isPremultiplied() ? Premultip lyAlpha : DontPremultiplyAlpha);
4537 pixelDataPtr = pixelData.get(); 4537 pixelDataPtr = pixelData->data();
4538 } 4538 }
4539 Vector<uint8_t> data; 4539 Vector<uint8_t> data;
4540 bool needConversion = true; 4540 bool needConversion = true;
4541 bool havePeekableRGBA = (peekSucceed && pixmap.colorType() == SkColorType::k RGBA_8888_SkColorType); 4541 bool havePeekableRGBA = (peekSucceed && pixmap.colorType() == SkColorType::k RGBA_8888_SkColorType);
4542 bool isPixelDataRGBA = (havePeekableRGBA || !peekSucceed); 4542 bool isPixelDataRGBA = (havePeekableRGBA || !peekSucceed);
4543 if (isPixelDataRGBA && format == GL_RGBA && type == GL_UNSIGNED_BYTE) { 4543 if (isPixelDataRGBA && format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
4544 needConversion = false; 4544 needConversion = false;
4545 } else { 4545 } else {
4546 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { 4546 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) {
4547 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implement ed. 4547 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implement ed.
(...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after
6492 6492
6493 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const 6493 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const
6494 { 6494 {
6495 if (canvas()) 6495 if (canvas())
6496 result.setHTMLCanvasElement(canvas()); 6496 result.setHTMLCanvasElement(canvas());
6497 else 6497 else
6498 result.setOffscreenCanvas(getOffscreenCanvas()); 6498 result.setOffscreenCanvas(getOffscreenCanvas());
6499 } 6499 }
6500 6500
6501 } // namespace blink 6501 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698