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

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContextBase.cpp

Issue 1170523002: Removing GraphicsContext from ImageBuffer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix unit test crashes Created 5 years, 6 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 | Annotate | Revision Log
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 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after
3759 { 3759 {
3760 IntSize size(width, height); 3760 IntSize size(width, height);
3761 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); 3761 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
3762 if (!buf) { 3762 if (!buf) {
3763 synthesizeGLError(GL_OUT_OF_MEMORY, functionName, "out of memory"); 3763 synthesizeGLError(GL_OUT_OF_MEMORY, functionName, "out of memory");
3764 return nullptr; 3764 return nullptr;
3765 } 3765 }
3766 3766
3767 IntRect srcRect(IntPoint(), image->size()); 3767 IntRect srcRect(IntPoint(), image->size());
3768 IntRect destRect(0, 0, size.width(), size.height()); 3768 IntRect destRect(0, 0, size.width(), size.height());
3769 buf->context()->drawImage(image, destRect, srcRect); 3769 SkPaint paint;
3770 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient ation, Image::DoNotClampImageToSourceRect);
3770 return buf->copyImage(ImageBuffer::fastCopyImageMode()); 3771 return buf->copyImage(ImageBuffer::fastCopyImageMode());
3771 } 3772 }
3772 3773
3773 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, 3774 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat,
3774 GLsizei width, GLsizei height, GLint border, 3775 GLsizei width, GLsizei height, GLint border,
3775 GLenum format, GLenum type, DOMArrayBufferView* pixels, ExceptionState& exce ptionState) 3776 GLenum format, GLenum type, DOMArrayBufferView* pixels, ExceptionState& exce ptionState)
3776 { 3777 {
3777 if (isContextLost() || !validateTexFuncData("texImage2D", level, width, heig ht, format, type, pixels, NullAllowed) 3778 if (isContextLost() || !validateTexFuncData("texImage2D", level, width, heig ht, format, type, pixels, NullAllowed)
3778 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceArrayBufferVie w, target, level, internalformat, width, height, border, format, type, 0, 0)) 3779 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceArrayBufferVie w, target, level, internalformat, width, height, border, format, type, 0, 0))
3779 return; 3780 return;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
3949 3950
3950 // Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU. 3951 // Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU.
3951 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer Surface(IntSize(video->videoWidth(), video->videoHeight()))); 3952 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer Surface(IntSize(video->videoWidth(), video->videoHeight())));
3952 if (surface->isValid()) { 3953 if (surface->isValid()) {
3953 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release( ))); 3954 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release( )));
3954 if (imageBuffer) { 3955 if (imageBuffer) {
3955 // The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface, 3956 // The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface,
3956 // we enable the WebMediaPlayer implementation to do any necessa ry color space conversion on the GPU (though it 3957 // we enable the WebMediaPlayer implementation to do any necessa ry color space conversion on the GPU (though it
3957 // may still do a CPU conversion and upload the results). 3958 // may still do a CPU conversion and upload the results).
3958 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi deo->videoWidth(), video->videoHeight()), nullptr); 3959 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi deo->videoWidth(), video->videoHeight()), nullptr);
3959 imageBuffer->context()->canvas()->flush(); 3960 imageBuffer->canvas()->flush();
3960 3961
3961 // This is a straight GPU-GPU copy, any necessary color space co nversion was handled in the paintCurrentFrameInContext() call. 3962 // This is a straight GPU-GPU copy, any necessary color space co nversion was handled in the paintCurrentFrameInContext() call.
3962 if (imageBuffer->copyToPlatformTexture(webContext(), texture->ob ject(), internalformat, type, 3963 if (imageBuffer->copyToPlatformTexture(webContext(), texture->ob ject(), internalformat, type,
3963 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3964 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3964 texture->setLevelInfo(target, level, internalformat, video-> videoWidth(), video->videoHeight(), 1, type); 3965 texture->setLevelInfo(target, level, internalformat, video-> videoWidth(), video->videoHeight(), 1, type);
3965 return; 3966 return;
3966 } 3967 }
3967 } 3968 }
3968 } 3969 }
3969 } 3970 }
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after
6252 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; 6253 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0;
6253 } 6254 }
6254 #else 6255 #else
6255 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6256 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6256 { 6257 {
6257 return m_drawingBuffer.get(); 6258 return m_drawingBuffer.get();
6258 } 6259 }
6259 #endif 6260 #endif
6260 6261
6261 } // namespace blink 6262 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698