OLD | NEW |
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 4500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4511 return; | 4511 return; |
4512 TexImageFunctionType functionType; | 4512 TexImageFunctionType functionType; |
4513 if (functionID == TexImage2D) | 4513 if (functionID == TexImage2D) |
4514 functionType = TexImage; | 4514 functionType = TexImage; |
4515 else | 4515 else |
4516 functionType = TexSubImage; | 4516 functionType = TexSubImage; |
4517 if (!validateTexFunc(funcName, functionType, SourceImageBitmap, target, leve
l, internalformat, bitmap->width(), bitmap->height(), 1, 0, format, type, xoffse
t, yoffset, zoffset)) | 4517 if (!validateTexFunc(funcName, functionType, SourceImageBitmap, target, leve
l, internalformat, bitmap->width(), bitmap->height(), 1, 0, format, type, xoffse
t, yoffset, zoffset)) |
4518 return; | 4518 return; |
4519 ASSERT(bitmap->bitmapImage()); | 4519 ASSERT(bitmap->bitmapImage()); |
4520 | 4520 |
| 4521 fprintf(stderr, "uploading to texture, before calling isTextureBacked()\n"); |
4521 if (functionID != TexSubImage3D && bitmap->isTextureBacked() && canUseTexIma
geByGPU(functionID, internalformat, type)) { | 4522 if (functionID != TexSubImage3D && bitmap->isTextureBacked() && canUseTexIma
geByGPU(functionID, internalformat, type)) { |
| 4523 fprintf(stderr, "done calling isTextureBacked()\n"); |
4522 if (functionID == TexImage2D) { | 4524 if (functionID == TexImage2D) { |
4523 texImage2DBase(target, level, internalformat, bitmap->width(), bitma
p->height(), 0, format, type, 0); | 4525 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); | 4526 texImageByGPU(TexImage2DByGPU, texture, target, level, internalforma
t, type, 0, 0, 0, bitmap); |
4525 } else if (functionID == TexSubImage2D) { | 4527 } else if (functionID == TexSubImage2D) { |
4526 texImageByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, t
ype, xoffset, yoffset, 0, bitmap); | 4528 texImageByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, t
ype, xoffset, yoffset, 0, bitmap); |
4527 } | 4529 } |
4528 return; | 4530 return; |
4529 } | 4531 } |
4530 RefPtr<SkImage> skImage = bitmap->bitmapImage()->imageForCurrentFrame(); | 4532 RefPtr<SkImage> skImage = bitmap->bitmapImage()->imageForCurrentFrame(); |
4531 SkPixmap pixmap; | 4533 SkPixmap pixmap; |
4532 std::unique_ptr<uint8_t[]> pixelData; | |
4533 uint8_t* pixelDataPtr = nullptr; | 4534 uint8_t* pixelDataPtr = nullptr; |
4534 // In the case where an ImageBitmap is not texture backed, peekPixels() alwa
ys succeed. | 4535 // 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. | 4536 // However, when it is texture backed and !canUseTexImageByGPU, we do a GPU
read back. |
4536 bool peekSucceed = skImage->peekPixels(&pixmap); | 4537 bool peekSucceed = skImage->peekPixels(&pixmap); |
4537 if (peekSucceed) { | 4538 if (peekSucceed) { |
4538 pixelDataPtr = static_cast<uint8_t*>(pixmap.writable_addr()); | 4539 pixelDataPtr = static_cast<uint8_t*>(pixmap.writable_addr()); |
4539 } else { | 4540 } else { |
4540 pixelData = bitmap->copyBitmapData(bitmap->isPremultiplied() ? Premultip
lyAlpha : DontPremultiplyAlpha); | 4541 pixelDataPtr = bitmap->copyBitmapData(bitmap->isPremultiplied() ? Premul
tiplyAlpha : DontPremultiplyAlpha).leakRef()->data(); |
4541 pixelDataPtr = pixelData.get(); | |
4542 } | 4542 } |
4543 Vector<uint8_t> data; | 4543 Vector<uint8_t> data; |
4544 bool needConversion = true; | 4544 bool needConversion = true; |
4545 bool havePeekableRGBA = (peekSucceed && pixmap.colorType() == SkColorType::k
RGBA_8888_SkColorType); | 4545 bool havePeekableRGBA = (peekSucceed && pixmap.colorType() == SkColorType::k
RGBA_8888_SkColorType); |
4546 bool isPixelDataRGBA = (havePeekableRGBA || !peekSucceed); | 4546 bool isPixelDataRGBA = (havePeekableRGBA || !peekSucceed); |
4547 if (isPixelDataRGBA && format == GL_RGBA && type == GL_UNSIGNED_BYTE) { | 4547 if (isPixelDataRGBA && format == GL_RGBA && type == GL_UNSIGNED_BYTE) { |
4548 needConversion = false; | 4548 needConversion = false; |
4549 } else { | 4549 } else { |
4550 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { | 4550 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { |
4551 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implement
ed. | 4551 // 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 Loading... |
6491 | 6491 |
6492 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs
creenCanvas& result) const | 6492 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs
creenCanvas& result) const |
6493 { | 6493 { |
6494 if (canvas()) | 6494 if (canvas()) |
6495 result.setHTMLCanvasElement(canvas()); | 6495 result.setHTMLCanvasElement(canvas()); |
6496 else | 6496 else |
6497 result.setOffscreenCanvas(getOffscreenCanvas()); | 6497 result.setOffscreenCanvas(getOffscreenCanvas()); |
6498 } | 6498 } |
6499 | 6499 |
6500 } // namespace blink | 6500 } // namespace blink |
OLD | NEW |