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

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: size_t + Uint8Array + null check (lots) 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
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 4511 matching lines...) Expand 10 before | Expand all | Expand 10 after
4522 if (functionID == TexImage2D) { 4522 if (functionID == TexImage2D) {
4523 texImage2DBase(target, level, internalformat, bitmap->width(), bitma p->height(), 0, format, type, 0); 4523 texImage2DBase(target, level, internalformat, bitmap->width(), bitma p->height(), 0, format, type, 0);
4524 texImageByGPU(TexImage2DByGPU, texture, target, level, internalforma t, type, 0, 0, 0, bitmap); 4524 texImageByGPU(TexImage2DByGPU, texture, target, level, internalforma t, type, 0, 0, 0, bitmap);
4525 } else if (functionID == TexSubImage2D) { 4525 } else if (functionID == TexSubImage2D) {
4526 texImageByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, t ype, xoffset, yoffset, 0, bitmap); 4526 texImageByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, t ype, xoffset, yoffset, 0, bitmap);
4527 } 4527 }
4528 return; 4528 return;
4529 } 4529 }
4530 RefPtr<SkImage> skImage = bitmap->bitmapImage()->imageForCurrentFrame(); 4530 RefPtr<SkImage> skImage = bitmap->bitmapImage()->imageForCurrentFrame();
4531 SkPixmap pixmap; 4531 SkPixmap pixmap;
4532 std::unique_ptr<uint8_t[]> pixelData;
4533 uint8_t* pixelDataPtr = nullptr; 4532 uint8_t* pixelDataPtr = nullptr;
4534 // In the case where an ImageBitmap is not texture backed, peekPixels() alwa ys succeed. 4533 // In the case where an ImageBitmap is not texture backed, peekPixels() alwa ys succeed.
4535 // However, when it is texture backed and !canUseTexImageByGPU, we do a GPU read back. 4534 // However, when it is texture backed and !canUseTexImageByGPU, we do a GPU read back.
4536 bool peekSucceed = skImage->peekPixels(&pixmap); 4535 bool peekSucceed = skImage->peekPixels(&pixmap);
4537 if (peekSucceed) { 4536 if (peekSucceed) {
4538 pixelDataPtr = static_cast<uint8_t*>(pixmap.writable_addr()); 4537 pixelDataPtr = static_cast<uint8_t*>(pixmap.writable_addr());
4539 } else { 4538 } else {
4540 pixelData = bitmap->copyBitmapData(bitmap->isPremultiplied() ? Premultip lyAlpha : DontPremultiplyAlpha); 4539 pixelDataPtr = bitmap->copyBitmapData(bitmap->isPremultiplied() ? Premul tiplyAlpha : DontPremultiplyAlpha).leakRef()->data();
4541 pixelDataPtr = pixelData.get();
4542 } 4540 }
4543 Vector<uint8_t> data; 4541 Vector<uint8_t> data;
4544 bool needConversion = true; 4542 bool needConversion = true;
4545 bool havePeekableRGBA = (peekSucceed && pixmap.colorType() == SkColorType::k RGBA_8888_SkColorType); 4543 bool havePeekableRGBA = (peekSucceed && pixmap.colorType() == SkColorType::k RGBA_8888_SkColorType);
4546 bool isPixelDataRGBA = (havePeekableRGBA || !peekSucceed); 4544 bool isPixelDataRGBA = (havePeekableRGBA || !peekSucceed);
4547 if (isPixelDataRGBA && format == GL_RGBA && type == GL_UNSIGNED_BYTE) { 4545 if (isPixelDataRGBA && format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
4548 needConversion = false; 4546 needConversion = false;
4549 } else { 4547 } else {
4550 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { 4548 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) {
4551 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implement ed. 4549 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implement ed.
(...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after
6491 6489
6492 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const 6490 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const
6493 { 6491 {
6494 if (canvas()) 6492 if (canvas())
6495 result.setHTMLCanvasElement(canvas()); 6493 result.setHTMLCanvasElement(canvas());
6496 else 6494 else
6497 result.setOffscreenCanvas(getOffscreenCanvas()); 6495 result.setOffscreenCanvas(getOffscreenCanvas());
6498 } 6496 }
6499 6497
6500 } // namespace blink 6498 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698