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

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

Issue 104023007: Refactoring ImageBuffer to decouple it from Canvas2DLayerBridge (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase mayhem Created 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContext.h ('k') | Source/core/platform/DragImage.cpp » ('j') | 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "core/html/canvas/WebGLUniformLocation.h" 67 #include "core/html/canvas/WebGLUniformLocation.h"
68 #include "core/inspector/InspectorInstrumentation.h" 68 #include "core/inspector/InspectorInstrumentation.h"
69 #include "core/loader/FrameLoader.h" 69 #include "core/loader/FrameLoader.h"
70 #include "core/loader/FrameLoaderClient.h" 70 #include "core/loader/FrameLoaderClient.h"
71 #include "core/frame/Frame.h" 71 #include "core/frame/Frame.h"
72 #include "core/page/Settings.h" 72 #include "core/page/Settings.h"
73 #include "core/rendering/RenderBox.h" 73 #include "core/rendering/RenderBox.h"
74 #include "platform/NotImplemented.h" 74 #include "platform/NotImplemented.h"
75 #include "platform/geometry/IntSize.h" 75 #include "platform/geometry/IntSize.h"
76 #include "platform/graphics/Extensions3D.h" 76 #include "platform/graphics/Extensions3D.h"
77 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
77 #include "platform/graphics/gpu/DrawingBuffer.h" 78 #include "platform/graphics/gpu/DrawingBuffer.h"
78 79
79 #include "wtf/PassOwnPtr.h" 80 #include "wtf/PassOwnPtr.h"
80 #include "wtf/Uint32Array.h" 81 #include "wtf/Uint32Array.h"
81 #include "wtf/text/StringBuilder.h" 82 #include "wtf/text/StringBuilder.h"
82 83
83 namespace WebCore { 84 namespace WebCore {
84 85
85 const double secondsBetweenRestoreAttempts = 1.0; 86 const double secondsBetweenRestoreAttempts = 1.0;
86 const int maxGLErrorsAllowedToConsole = 256; 87 const int maxGLErrorsAllowedToConsole = 256;
(...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after
3355 } 3356 }
3356 if (texture->getInternalFormat(target, level) != format || texture->getT ype(target, level) != type) { 3357 if (texture->getInternalFormat(target, level) != format || texture->getT ype(target, level) != type) {
3357 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "type and format do not match texture"); 3358 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "type and format do not match texture");
3358 return false; 3359 return false;
3359 } 3360 }
3360 } 3361 }
3361 3362
3362 return true; 3363 return true;
3363 } 3364 }
3364 3365
3365 PassRefPtr<Image> WebGLRenderingContext::drawImageIntoBuffer(Image* image, int w idth, int height, int deviceScaleFactor) 3366 PassRefPtr<Image> WebGLRenderingContext::drawImageIntoBuffer(Image* image, int w idth, int height)
3366 { 3367 {
3367 IntSize size(width, height); 3368 IntSize size(width, height);
3368 size.scale(deviceScaleFactor);
3369 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); 3369 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
3370 if (!buf) { 3370 if (!buf) {
3371 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out o f memory"); 3371 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out o f memory");
3372 return 0; 3372 return 0;
3373 } 3373 }
3374 3374
3375 IntRect srcRect(IntPoint(), image->size()); 3375 IntRect srcRect(IntPoint(), image->size());
3376 IntRect destRect(0, 0, size.width(), size.height()); 3376 IntRect destRect(0, 0, size.width(), size.height());
3377 buf->context()->drawImage(image, destRect, srcRect); 3377 buf->context()->drawImage(image, destRect, srcRect);
3378 return buf->copyImage(ImageBuffer::fastCopyImageMode()); 3378 return buf->copyImage(ImageBuffer::fastCopyImageMode());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3430 } 3430 }
3431 3431
3432 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, 3432 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat,
3433 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& exc eptionState) 3433 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& exc eptionState)
3434 { 3434 {
3435 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, except ionState)) 3435 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, except ionState))
3436 return; 3436 return;
3437 3437
3438 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image- >renderer()); 3438 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image- >renderer());
3439 if (imageForRender->isSVGImage()) 3439 if (imageForRender->isSVGImage())
3440 imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width( ), image->height(), canvas()->deviceScaleFactor()); 3440 imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width( ), image->height());
3441 3441
3442 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour ceHTMLImageElement, target, level, internalformat, imageForRender->width(), imag eForRender->height(), 0, format, type, 0, 0)) 3442 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour ceHTMLImageElement, target, level, internalformat, imageForRender->width(), imag eForRender->height(), 0, format, type, 0, 0))
3443 return; 3443 return;
3444 3444
3445 texImage2DImpl(target, level, internalformat, format, type, imageForRender.g et(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, exceptionState); 3445 texImage2DImpl(target, level, internalformat, format, type, imageForRender.g et(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, exceptionState);
3446 } 3446 }
3447 3447
3448 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, 3448 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat,
3449 GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionState& e xceptionState) 3449 GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionState& e xceptionState)
3450 { 3450 {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
3669 } 3669 }
3670 3670
3671 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset, 3671 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset,
3672 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& exc eptionState) 3672 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& exc eptionState)
3673 { 3673 {
3674 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, exc eptionState)) 3674 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, exc eptionState))
3675 return; 3675 return;
3676 3676
3677 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image- >renderer()); 3677 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image- >renderer());
3678 if (imageForRender->isSVGImage()) 3678 if (imageForRender->isSVGImage())
3679 imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width( ), image->height(), canvas()->deviceScaleFactor()); 3679 imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width( ), image->height());
3680 3680
3681 if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour ceHTMLImageElement, target, level, format, imageForRender->width(), imageForRend er->height(), 0, format, type, xoffset, yoffset)) 3681 if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour ceHTMLImageElement, target, level, format, imageForRender->width(), imageForRend er->height(), 0, format, type, xoffset, yoffset))
3682 return; 3682 return;
3683 3683
3684 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen der.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAl pha, exceptionState); 3684 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen der.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAl pha, exceptionState);
3685 } 3685 }
3686 3686
3687 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset, 3687 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset,
3688 GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionState& e xceptionState) 3688 GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionState& e xceptionState)
3689 { 3689 {
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after
5445 { 5445 {
5446 } 5446 }
5447 5447
5448 ImageBuffer* WebGLRenderingContext::LRUImageBufferCache::imageBuffer(const IntSi ze& size) 5448 ImageBuffer* WebGLRenderingContext::LRUImageBufferCache::imageBuffer(const IntSi ze& size)
5449 { 5449 {
5450 int i; 5450 int i;
5451 for (i = 0; i < m_capacity; ++i) { 5451 for (i = 0; i < m_capacity; ++i) {
5452 ImageBuffer* buf = m_buffers[i].get(); 5452 ImageBuffer* buf = m_buffers[i].get();
5453 if (!buf) 5453 if (!buf)
5454 break; 5454 break;
5455 if (buf->logicalSize() != size) 5455 if (buf->size() != size)
5456 continue; 5456 continue;
5457 bubbleToFront(i); 5457 bubbleToFront(i);
5458 return buf; 5458 return buf;
5459 } 5459 }
5460 5460
5461 OwnPtr<ImageBuffer> temp = ImageBuffer::create(size, 1); 5461 OwnPtr<ImageBuffer> temp(ImageBuffer::create(size));
5462 if (!temp) 5462 if (!temp)
5463 return 0; 5463 return 0;
5464 i = std::min(m_capacity - 1, i); 5464 i = std::min(m_capacity - 1, i);
5465 m_buffers[i] = temp.release(); 5465 m_buffers[i] = temp.release();
5466 5466
5467 ImageBuffer* buf = m_buffers[i].get(); 5467 ImageBuffer* buf = m_buffers[i].get();
5468 bubbleToFront(i); 5468 bubbleToFront(i);
5469 return buf; 5469 return buf;
5470 } 5470 }
5471 5471
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
5619 if (m_textureUnits[i].m_texture2DBinding 5619 if (m_textureUnits[i].m_texture2DBinding
5620 || m_textureUnits[i].m_textureCubeMapBinding) { 5620 || m_textureUnits[i].m_textureCubeMapBinding) {
5621 m_onePlusMaxNonDefaultTextureUnit = i + 1; 5621 m_onePlusMaxNonDefaultTextureUnit = i + 1;
5622 return; 5622 return;
5623 } 5623 }
5624 } 5624 }
5625 m_onePlusMaxNonDefaultTextureUnit = 0; 5625 m_onePlusMaxNonDefaultTextureUnit = 0;
5626 } 5626 }
5627 5627
5628 } // namespace WebCore 5628 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContext.h ('k') | Source/core/platform/DragImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698