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); | |
154 | |
155 OwnPtr<blink::WebExternalTextureMailbox> mailbox = adoptPtr(new blink::WebEx ternalTextureMailbox); | |
156 | |
157 // Context may be in a different share group. We must transfer the texture t hrough 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->flush(); | |
162 | |
163 mailbox->syncPoint = sharedContext->insertSyncPoint(); | |
164 sharedContext->waitSyncPoint(mailbox->syncPoint); | |
piman
2014/03/11 00:02:24
Same comments as in DrawingBuffer, you want to do
| |
165 | |
166 sharedContext->bindTexture(GL_TEXTURE_2D, boundTexture); | |
167 | |
141 if (!context->makeContextCurrent()) | 168 if (!context->makeContextCurrent()) |
142 return false; | 169 return false; |
143 | 170 |
144 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(internalFormat, destType, l evel)) | 171 Platform3DObject sourceTexture = context->createTexture(); |
145 return false; | 172 |
173 context->getIntegerv(GL_TEXTURE_BINDING_2D, &boundTexture); | |
174 context->bindTexture(GL_TEXTURE_2D, sourceTexture); | |
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); | |
188 context->deleteTexture(sourceTexture); | |
189 | |
156 context->flush(); | 190 context->flush(); |
piman
2014/03/11 00:02:24
same comments as in DrawingBuffer, you can add sha
| |
157 return true; | 191 return true; |
158 } | 192 } |
159 | 193 |
160 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) | 194 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) |
161 { | 195 { |
162 ASSERT(dst); | 196 ASSERT(dst); |
163 return (src == dst); | 197 return (src == dst); |
164 } | 198 } |
165 | 199 |
166 Platform3DObject ImageBuffer::getBackingTexture() | 200 Platform3DObject ImageBuffer::getBackingTexture() |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 433 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
400 return "data:,"; | 434 return "data:,"; |
401 | 435 |
402 Vector<char> base64Data; | 436 Vector<char> base64Data; |
403 base64Encode(encodedImage, base64Data); | 437 base64Encode(encodedImage, base64Data); |
404 | 438 |
405 return "data:" + mimeType + ";base64," + base64Data; | 439 return "data:" + mimeType + ";base64," + base64Data; |
406 } | 440 } |
407 | 441 |
408 } // namespace WebCore | 442 } // namespace WebCore |
OLD | NEW |