| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2009 Google Inc. All rights reserved. | 2  * Copyright (C) 2009 Google 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 are | 5  * modification, are permitted provided that the following conditions are | 
| 6  * met: | 6  * met: | 
| 7  * | 7  * | 
| 8  *     * Redistributions of source code must retain the above copyright | 8  *     * Redistributions of source code must retain the above copyright | 
| 9  * notice, this list of conditions and the following disclaimer. | 9  * notice, this list of conditions and the following disclaimer. | 
| 10  *     * Redistributions in binary form must reproduce the above | 10  *     * Redistributions in binary form must reproduce the above | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 44 #include "HTMLCanvasElement.h" | 44 #include "HTMLCanvasElement.h" | 
| 45 #include "HTMLImageElement.h" | 45 #include "HTMLImageElement.h" | 
| 46 #include "ImageBuffer.h" | 46 #include "ImageBuffer.h" | 
| 47 #include "ImageData.h" | 47 #include "ImageData.h" | 
| 48 #include "WebGraphicsContext3D.h" | 48 #include "WebGraphicsContext3D.h" | 
| 49 #include "WebKit.h" | 49 #include "WebKit.h" | 
| 50 #include "WebKitClient.h" | 50 #include "WebKitClient.h" | 
| 51 #include "WebViewImpl.h" | 51 #include "WebViewImpl.h" | 
| 52 | 52 | 
| 53 #include <stdio.h> | 53 #include <stdio.h> | 
|  | 54 #include <wtf/Assertions.h> | 
| 54 #include <wtf/FastMalloc.h> | 55 #include <wtf/FastMalloc.h> | 
| 55 #include <wtf/text/CString.h> | 56 #include <wtf/text/CString.h> | 
| 56 | 57 | 
| 57 #if USE(CG) | 58 #if USE(CG) | 
| 58 #include "GraphicsContext.h" | 59 #include "GraphicsContext.h" | 
| 59 #include "WebGLRenderingContext.h" | 60 #include "WebGLRenderingContext.h" | 
| 60 #include <CoreGraphics/CGContext.h> | 61 #include <CoreGraphics/CGContext.h> | 
| 61 #include <CoreGraphics/CGImage.h> | 62 #include <CoreGraphics/CGImage.h> | 
| 62 #endif | 63 #endif | 
| 63 | 64 | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 115     webAttributes.stencil = attrs.stencil; | 116     webAttributes.stencil = attrs.stencil; | 
| 116     webAttributes.antialias = attrs.antialias; | 117     webAttributes.antialias = attrs.antialias; | 
| 117     webAttributes.premultipliedAlpha = attrs.premultipliedAlpha; | 118     webAttributes.premultipliedAlpha = attrs.premultipliedAlpha; | 
| 118     webAttributes.canRecoverFromContextLoss = attrs.canRecoverFromContextLoss; | 119     webAttributes.canRecoverFromContextLoss = attrs.canRecoverFromContextLoss; | 
| 119     webAttributes.noExtensions = attrs.noExtensions; | 120     webAttributes.noExtensions = attrs.noExtensions; | 
| 120     OwnPtr<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::webKitCli
      ent()->createGraphicsContext3D()); | 121     OwnPtr<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::webKitCli
      ent()->createGraphicsContext3D()); | 
| 121     if (!webContext) | 122     if (!webContext) | 
| 122         return false; | 123         return false; | 
| 123 | 124 | 
| 124     Chrome* chrome = static_cast<Chrome*>(hostWindow); | 125     Chrome* chrome = static_cast<Chrome*>(hostWindow); | 
| 125     m_webViewImpl = static_cast<WebKit::WebViewImpl*>(chrome->client()->webView(
      )); | 126     m_webViewImpl = chrome ? static_cast<WebKit::WebViewImpl*>(chrome->client()-
      >webView()) : 0; | 
| 126 | 127 | 
| 127     if (!m_webViewImpl) |  | 
| 128         return false; |  | 
| 129     if (!webContext->initialize(webAttributes, m_webViewImpl, renderDirectlyToHo
      stWindow)) | 128     if (!webContext->initialize(webAttributes, m_webViewImpl, renderDirectlyToHo
      stWindow)) | 
| 130         return false; | 129         return false; | 
| 131     m_impl = webContext.release(); | 130     m_impl = webContext.release(); | 
| 132 | 131 | 
| 133 #if USE(ACCELERATED_COMPOSITING) | 132 #if USE(ACCELERATED_COMPOSITING) | 
| 134     m_compositingLayer = WebGLLayerChromium::create(0); | 133     m_compositingLayer = WebGLLayerChromium::create(0); | 
| 135 #endif | 134 #endif | 
| 136     return true; | 135     return true; | 
| 137 } | 136 } | 
| 138 | 137 | 
| 139 WebKit::WebGraphicsContext3D* GraphicsContext3DInternal::extractWebGraphicsConte
      xt3D(GraphicsContext3D* context) | 138 WebKit::WebGraphicsContext3D* GraphicsContext3DInternal::extractWebGraphicsConte
      xt3D(GraphicsContext3D* context) | 
| 140 { | 139 { | 
| 141     if (!context) | 140     if (!context) | 
| 142         return 0; | 141         return 0; | 
| 143     return context->m_internal->m_impl.get(); | 142     return context->m_internal->m_impl.get(); | 
| 144 } | 143 } | 
| 145 | 144 | 
| 146 PlatformGraphicsContext3D GraphicsContext3DInternal::platformGraphicsContext3D()
       const | 145 PlatformGraphicsContext3D GraphicsContext3DInternal::platformGraphicsContext3D()
       const | 
| 147 { | 146 { | 
| 148     return m_impl.get(); | 147     return m_impl.get(); | 
| 149 } | 148 } | 
| 150 | 149 | 
| 151 Platform3DObject GraphicsContext3DInternal::platformTexture() const | 150 Platform3DObject GraphicsContext3DInternal::platformTexture() const | 
| 152 { | 151 { | 
|  | 152     ASSERT(m_webViewImpl); | 
| 153     m_impl->setParentContext(m_webViewImpl->graphicsContext3D()); | 153     m_impl->setParentContext(m_webViewImpl->graphicsContext3D()); | 
| 154     return m_impl->getPlatformTextureId(); | 154     return m_impl->getPlatformTextureId(); | 
| 155 } | 155 } | 
| 156 | 156 | 
| 157 #if USE(SKIA) | 157 #if USE(SKIA) | 
| 158 GrContext* GraphicsContext3DInternal::grContext() | 158 GrContext* GraphicsContext3DInternal::grContext() | 
| 159 { | 159 { | 
| 160     // Limit the number of textures we hold in the bitmap->texture cache. | 160     // Limit the number of textures we hold in the bitmap->texture cache. | 
| 161     static const int maxTextureCacheCount = 512; | 161     static const int maxTextureCacheCount = 512; | 
| 162     // Limit the bytes allocated toward textures in the bitmap->texture cache. | 162     // Limit the bytes allocated toward textures in the bitmap->texture cache. | 
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 296 | 296 | 
| 297     for (size_t i = 0; i < bufferSize; i += 4) | 297     for (size_t i = 0; i < bufferSize; i += 4) | 
| 298         std::swap(pixels[i], pixels[i + 2]); | 298         std::swap(pixels[i], pixels[i + 2]); | 
| 299 | 299 | 
| 300     return imageData.release(); | 300     return imageData.release(); | 
| 301 } | 301 } | 
| 302 | 302 | 
| 303 bool GraphicsContext3DInternal::paintsIntoCanvasBuffer() const | 303 bool GraphicsContext3DInternal::paintsIntoCanvasBuffer() const | 
| 304 { | 304 { | 
| 305     // If the gpu compositor is on then skip the readback and software rendering
       path. | 305     // If the gpu compositor is on then skip the readback and software rendering
       path. | 
|  | 306     ASSERT(m_webViewImpl); | 
| 306     return !m_webViewImpl->isAcceleratedCompositingActive(); | 307     return !m_webViewImpl->isAcceleratedCompositingActive(); | 
| 307 } | 308 } | 
| 308 | 309 | 
| 309 void GraphicsContext3DInternal::reshape(int width, int height) | 310 void GraphicsContext3DInternal::reshape(int width, int height) | 
| 310 { | 311 { | 
| 311     if (width == m_impl->width() && height == m_impl->height()) | 312     if (width == m_impl->width() && height == m_impl->height()) | 
| 312         return; | 313         return; | 
| 313 | 314 | 
| 314     m_impl->reshape(width, height); | 315     m_impl->reshape(width, height); | 
| 315 } | 316 } | 
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1247 | 1248 | 
| 1248 void GraphicsContext3DInternal::setSwapBuffersCompleteCallbackCHROMIUM(PassOwnPt
      r<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> cb) | 1249 void GraphicsContext3DInternal::setSwapBuffersCompleteCallbackCHROMIUM(PassOwnPt
      r<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> cb) | 
| 1249 { | 1250 { | 
| 1250     m_swapBuffersCompleteCallbackAdapter = SwapBuffersCompleteCallbackAdapter::c
      reate(cb); | 1251     m_swapBuffersCompleteCallbackAdapter = SwapBuffersCompleteCallbackAdapter::c
      reate(cb); | 
| 1251     m_impl->setSwapBuffersCompleteCallbackCHROMIUM(m_swapBuffersCompleteCallback
      Adapter.get()); | 1252     m_impl->setSwapBuffersCompleteCallbackCHROMIUM(m_swapBuffersCompleteCallback
      Adapter.get()); | 
| 1252 } | 1253 } | 
| 1253 | 1254 | 
| 1254 } // namespace WebCore | 1255 } // namespace WebCore | 
| 1255 | 1256 | 
| 1256 #endif // ENABLE(WEBGL) | 1257 #endif // ENABLE(WEBGL) | 
| OLD | NEW | 
|---|