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

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

Issue 2559013002: Add ColorBehavior to blink::Image draw methods (Closed)
Patch Set: Rebase Created 4 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) 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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 NOTREACHED(); 766 NOTREACHED();
767 return nullptr; 767 return nullptr;
768 } 768 }
769 return buffer->newImageSnapshot(hint, reason); 769 return buffer->newImageSnapshot(hint, reason);
770 } 770 }
771 771
772 ImageData* WebGLRenderingContextBase::toImageData(SnapshotReason reason) const { 772 ImageData* WebGLRenderingContextBase::toImageData(SnapshotReason reason) const {
773 // TODO: Furnish toImageData in webgl renderingcontext for jpeg and webp 773 // TODO: Furnish toImageData in webgl renderingcontext for jpeg and webp
774 // images. See crbug.com/657531. 774 // images. See crbug.com/657531.
775 ImageData* imageData = nullptr; 775 ImageData* imageData = nullptr;
776 // TODO(ccameron): WebGL should produce sRGB images.
777 // https://crbug.com/672299
776 if (this->drawingBuffer()) { 778 if (this->drawingBuffer()) {
777 sk_sp<SkImage> snapshot = this->drawingBuffer() 779 sk_sp<SkImage> snapshot =
778 ->transferToStaticBitmapImage() 780 this->drawingBuffer()
779 ->imageForCurrentFrame(); 781 ->transferToStaticBitmapImage()
782 ->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget());
780 if (snapshot) { 783 if (snapshot) {
781 imageData = ImageData::create(this->getOffscreenCanvas()->size()); 784 imageData = ImageData::create(this->getOffscreenCanvas()->size());
782 SkImageInfo imageInfo = SkImageInfo::Make( 785 SkImageInfo imageInfo = SkImageInfo::Make(
783 this->drawingBufferWidth(), this->drawingBufferHeight(), 786 this->drawingBufferWidth(), this->drawingBufferHeight(),
784 kRGBA_8888_SkColorType, kUnpremul_SkAlphaType); 787 kRGBA_8888_SkColorType, kUnpremul_SkAlphaType);
785 snapshot->readPixels(imageInfo, imageData->data()->data(), 788 snapshot->readPixels(imageInfo, imageData->data()->data(),
786 imageInfo.minRowBytes(), 0, 0); 789 imageInfo.minRowBytes(), 0, 0);
787 } 790 }
788 } 791 }
789 return imageData; 792 return imageData;
(...skipping 3730 matching lines...) Expand 10 before | Expand all | Expand 10 after
4520 synthesizeGLError(GL_OUT_OF_MEMORY, functionName, "out of memory"); 4523 synthesizeGLError(GL_OUT_OF_MEMORY, functionName, "out of memory");
4521 return nullptr; 4524 return nullptr;
4522 } 4525 }
4523 4526
4524 if (!image->currentFrameKnownToBeOpaque()) 4527 if (!image->currentFrameKnownToBeOpaque())
4525 buf->canvas()->clear(SK_ColorTRANSPARENT); 4528 buf->canvas()->clear(SK_ColorTRANSPARENT);
4526 4529
4527 IntRect srcRect(IntPoint(), image->size()); 4530 IntRect srcRect(IntPoint(), image->size());
4528 IntRect destRect(0, 0, size.width(), size.height()); 4531 IntRect destRect(0, 0, size.width(), size.height());
4529 SkPaint paint; 4532 SkPaint paint;
4533 // TODO(ccameron): WebGL should produce sRGB images.
4534 // https://crbug.com/672299
4530 image->draw(buf->canvas(), paint, destRect, srcRect, 4535 image->draw(buf->canvas(), paint, destRect, srcRect,
4531 DoNotRespectImageOrientation, Image::DoNotClampImageToSourceRect); 4536 DoNotRespectImageOrientation, Image::DoNotClampImageToSourceRect,
4537 ColorBehavior::transformToGlobalTarget());
4532 return buf->newImageSnapshot(PreferNoAcceleration, 4538 return buf->newImageSnapshot(PreferNoAcceleration,
4533 SnapshotReasonWebGLDrawImageIntoBuffer); 4539 SnapshotReasonWebGLDrawImageIntoBuffer);
4534 } 4540 }
4535 4541
4536 WebGLTexture* WebGLRenderingContextBase::validateTexImageBinding( 4542 WebGLTexture* WebGLRenderingContextBase::validateTexImageBinding(
4537 const char* funcName, 4543 const char* funcName,
4538 TexImageFunctionID functionID, 4544 TexImageFunctionID functionID,
4539 GLenum target) { 4545 GLenum target) {
4540 return validateTexture2DBinding(funcName, target); 4546 return validateTexture2DBinding(funcName, target);
4541 } 4547 }
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
5285 texImage2DBase(target, level, internalformat, width, height, 0, format, 5291 texImage2DBase(target, level, internalformat, width, height, 0, format,
5286 type, 0); 5292 type, 0);
5287 texImageByGPU(TexImage2DByGPU, texture, target, level, internalformat, 5293 texImageByGPU(TexImage2DByGPU, texture, target, level, internalformat,
5288 type, 0, 0, 0, bitmap, sourceSubRect); 5294 type, 0, 0, 0, bitmap, sourceSubRect);
5289 } else if (functionID == TexSubImage2D) { 5295 } else if (functionID == TexSubImage2D) {
5290 texImageByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, type, 5296 texImageByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, type,
5291 xoffset, yoffset, 0, bitmap, sourceSubRect); 5297 xoffset, yoffset, 0, bitmap, sourceSubRect);
5292 } 5298 }
5293 return; 5299 return;
5294 } 5300 }
5295 sk_sp<SkImage> skImage = bitmap->bitmapImage()->imageForCurrentFrame(); 5301 // TODO(ccameron): WebGL should produce sRGB images.
5302 // https://crbug.com/672299
5303 sk_sp<SkImage> skImage = bitmap->bitmapImage()->imageForCurrentFrame(
5304 ColorBehavior::transformToGlobalTarget());
5296 SkPixmap pixmap; 5305 SkPixmap pixmap;
5297 uint8_t* pixelDataPtr = nullptr; 5306 uint8_t* pixelDataPtr = nullptr;
5298 RefPtr<Uint8Array> pixelData; 5307 RefPtr<Uint8Array> pixelData;
5299 // In the case where an ImageBitmap is not texture backed, peekPixels() always 5308 // In the case where an ImageBitmap is not texture backed, peekPixels() always
5300 // succeed. However, when it is texture backed and !canUseTexImageByGPU, we 5309 // succeed. However, when it is texture backed and !canUseTexImageByGPU, we
5301 // do a GPU read back. 5310 // do a GPU read back.
5302 bool peekSucceed = skImage->peekPixels(&pixmap); 5311 bool peekSucceed = skImage->peekPixels(&pixmap);
5303 if (peekSucceed) { 5312 if (peekSucceed) {
5304 pixelDataPtr = static_cast<uint8_t*>(pixmap.writable_addr()); 5313 pixelDataPtr = static_cast<uint8_t*>(pixmap.writable_addr());
5305 } else { 5314 } else {
(...skipping 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after
7741 7750
7742 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7751 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7743 HTMLCanvasElementOrOffscreenCanvas& result) const { 7752 HTMLCanvasElementOrOffscreenCanvas& result) const {
7744 if (canvas()) 7753 if (canvas())
7745 result.setHTMLCanvasElement(canvas()); 7754 result.setHTMLCanvasElement(canvas());
7746 else 7755 else
7747 result.setOffscreenCanvas(getOffscreenCanvas()); 7756 result.setOffscreenCanvas(getOffscreenCanvas());
7748 } 7757 }
7749 7758
7750 } // namespace blink 7759 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp ('k') | third_party/WebKit/Source/platform/DragImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698