Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
| 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
| 8 * met: | 8 * met: |
| 9 * | 9 * |
| 10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 #include "platform/graphics/GraphicsTypes3D.h" | 40 #include "platform/graphics/GraphicsTypes3D.h" |
| 41 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 41 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 42 #include "platform/graphics/gpu/DrawingBuffer.h" | 42 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 43 #include "platform/graphics/gpu/Extensions3DUtil.h" | 43 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 44 #include "platform/graphics/skia/NativeImageSkia.h" | 44 #include "platform/graphics/skia/NativeImageSkia.h" |
| 45 #include "platform/graphics/skia/SkiaUtils.h" | 45 #include "platform/graphics/skia/SkiaUtils.h" |
| 46 #include "platform/image-encoders/skia/JPEGImageEncoder.h" | 46 #include "platform/image-encoders/skia/JPEGImageEncoder.h" |
| 47 #include "platform/image-encoders/skia/PNGImageEncoder.h" | 47 #include "platform/image-encoders/skia/PNGImageEncoder.h" |
| 48 #include "platform/image-encoders/skia/WEBPImageEncoder.h" | 48 #include "platform/image-encoders/skia/WEBPImageEncoder.h" |
| 49 #include "public/platform/Platform.h" | 49 #include "public/platform/Platform.h" |
| 50 #include "public/platform/WebExternalTextureMailbox.h" | |
| 50 #include "public/platform/WebGraphicsContext3D.h" | 51 #include "public/platform/WebGraphicsContext3D.h" |
| 51 #include "public/platform/WebGraphicsContext3DProvider.h" | 52 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 52 #include "third_party/skia/include/effects/SkTableColorFilter.h" | 53 #include "third_party/skia/include/effects/SkTableColorFilter.h" |
| 53 #include "wtf/MathExtras.h" | 54 #include "wtf/MathExtras.h" |
| 54 #include "wtf/text/Base64.h" | 55 #include "wtf/text/Base64.h" |
| 55 #include "wtf/text/WTFString.h" | 56 #include "wtf/text/WTFString.h" |
| 56 | 57 |
| 57 using namespace std; | 58 using namespace std; |
| 58 | 59 |
| 59 namespace WebCore { | 60 namespace WebCore { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 blink::WebLayer* ImageBuffer::platformLayer() const | 132 blink::WebLayer* ImageBuffer::platformLayer() const |
| 132 { | 133 { |
| 133 return m_surface->layer(); | 134 return m_surface->layer(); |
| 134 } | 135 } |
| 135 | 136 |
| 136 bool ImageBuffer::copyToPlatformTexture(blink::WebGraphicsContext3D* context, Pl atform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, boo l premultiplyAlpha, bool flipY) | 137 bool ImageBuffer::copyToPlatformTexture(blink::WebGraphicsContext3D* context, Pl atform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, boo l premultiplyAlpha, bool flipY) |
| 137 { | 138 { |
| 138 if (!m_surface->isAccelerated() || !platformLayer() || !isValid()) | 139 if (!m_surface->isAccelerated() || !platformLayer() || !isValid()) |
| 139 return false; | 140 return false; |
| 140 | 141 |
| 142 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(internalFormat, destType, l evel)) | |
| 143 return false; | |
| 144 | |
| 145 OwnPtr<blink::WebGraphicsContext3DProvider> provider = adoptPtr(blink::Platf orm::current()->createSharedOffscreenGraphicsContext3DProvider()); | |
| 146 if (!provider) | |
| 147 return false; | |
| 148 blink::WebGraphicsContext3D* sharedContext = provider->context3d(); | |
| 149 if (!sharedContext || !sharedContext->makeContextCurrent()) | |
| 150 return false; | |
| 151 | |
| 152 GLint boundTexture = 0; | |
| 153 sharedContext->getIntegerv(GL_TEXTURE_BINDING_2D, &boundTexture); | |
|
Ken Russell (switch to Gerrit)
2014/03/12 21:23:38
Get calls are expensive in the command buffer. Is
| |
| 154 | |
| 155 OwnPtr<blink::WebExternalTextureMailbox> mailbox = adoptPtr(new blink::WebEx ternalTextureMailbox); | |
| 156 | |
| 157 // Contexts may be in a different share group. We must transfer the texture through a mailbox first | |
| 158 sharedContext->genMailboxCHROMIUM(mailbox->name); | |
| 159 sharedContext->bindTexture(GL_TEXTURE_2D, getBackingTexture()); | |
| 160 sharedContext->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name); | |
| 161 sharedContext->bindTexture(GL_TEXTURE_2D, boundTexture); | |
| 162 sharedContext->flush(); | |
| 163 | |
| 164 mailbox->syncPoint = sharedContext->insertSyncPoint(); | |
| 165 | |
| 141 if (!context->makeContextCurrent()) | 166 if (!context->makeContextCurrent()) |
| 142 return false; | 167 return false; |
| 143 | 168 |
| 144 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(internalFormat, destType, l evel)) | 169 Platform3DObject sourceTexture = context->createTexture(); |
| 145 return false; | 170 |
| 171 context->getIntegerv(GL_TEXTURE_BINDING_2D, &boundTexture); | |
|
Ken Russell (switch to Gerrit)
2014/03/12 21:23:38
The only caller of ImageBuffer::copyToPlatformText
| |
| 172 context->bindTexture(GL_TEXTURE_2D, sourceTexture); | |
| 173 | |
| 174 context->waitSyncPoint(mailbox->syncPoint); | |
| 175 context->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name); | |
| 146 | 176 |
| 147 // The canvas is stored in a premultiplied format, so unpremultiply if neces sary. | 177 // The canvas is stored in a premultiplied format, so unpremultiply if neces sary. |
| 148 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !premultiplyA lpha); | 178 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !premultiplyA lpha); |
| 149 | 179 |
| 150 // The canvas is stored in an inverted position, so the flip semantics are r eversed. | 180 // The canvas is stored in an inverted position, so the flip semantics are r eversed. |
| 151 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, !flipY); | 181 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, !flipY); |
| 152 context->copyTextureCHROMIUM(GL_TEXTURE_2D, getBackingTexture(), texture, le vel, internalFormat, destType); | 182 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, level, i nternalFormat, destType); |
| 153 | 183 |
| 154 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, false); | 184 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, false); |
| 155 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false); | 185 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false); |
| 186 | |
| 187 context->bindTexture(GL_TEXTURE_2D, boundTexture); | |
|
Ken Russell (switch to Gerrit)
2014/03/12 21:23:38
In order to effectively delete sourceTexture below
| |
| 188 context->deleteTexture(sourceTexture); | |
| 189 | |
| 156 context->flush(); | 190 context->flush(); |
| 191 sharedContext->waitSyncPoint(context->insertSyncPoint()); | |
| 192 | |
| 157 return true; | 193 return true; |
| 158 } | 194 } |
| 159 | 195 |
| 160 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) | 196 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) |
| 161 { | 197 { |
| 162 ASSERT(dst); | 198 ASSERT(dst); |
| 163 return (src == dst); | 199 return (src == dst); |
| 164 } | 200 } |
| 165 | 201 |
| 166 Platform3DObject ImageBuffer::getBackingTexture() | 202 Platform3DObject ImageBuffer::getBackingTexture() |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 433 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
| 398 return "data:,"; | 434 return "data:,"; |
| 399 | 435 |
| 400 Vector<char> base64Data; | 436 Vector<char> base64Data; |
| 401 base64Encode(encodedImage, base64Data); | 437 base64Encode(encodedImage, base64Data); |
| 402 | 438 |
| 403 return "data:" + mimeType + ";base64," + base64Data; | 439 return "data:" + mimeType + ";base64," + base64Data; |
| 404 } | 440 } |
| 405 | 441 |
| 406 } // namespace WebCore | 442 } // namespace WebCore |
| OLD | NEW |