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 30 matching lines...) Expand all Loading... |
41 #include "platform/graphics/StaticBitmapImage.h" | 41 #include "platform/graphics/StaticBitmapImage.h" |
42 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 42 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
43 #include "platform/graphics/gpu/DrawingBuffer.h" | 43 #include "platform/graphics/gpu/DrawingBuffer.h" |
44 #include "platform/graphics/gpu/Extensions3DUtil.h" | 44 #include "platform/graphics/gpu/Extensions3DUtil.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/WebExternalTextureMailbox.h" |
51 #include "public/platform/WebGraphicsContext3D.h" | |
52 #include "public/platform/WebGraphicsContext3DProvider.h" | 51 #include "public/platform/WebGraphicsContext3DProvider.h" |
53 #include "skia/ext/texture_handle.h" | 52 #include "skia/ext/texture_handle.h" |
54 #include "third_party/skia/include/core/SkPicture.h" | 53 #include "third_party/skia/include/core/SkPicture.h" |
55 #include "third_party/skia/include/gpu/GrContext.h" | 54 #include "third_party/skia/include/gpu/GrContext.h" |
56 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" | 55 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
57 #include "wtf/CheckedNumeric.h" | 56 #include "wtf/CheckedNumeric.h" |
58 #include "wtf/MathExtras.h" | 57 #include "wtf/MathExtras.h" |
59 #include "wtf/Vector.h" | 58 #include "wtf/Vector.h" |
60 #include "wtf/text/Base64.h" | 59 #include "wtf/text/Base64.h" |
61 #include "wtf/text/WTFString.h" | 60 #include "wtf/text/WTFString.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 if (m_snapshotState == DidAcquireSnapshot) | 171 if (m_snapshotState == DidAcquireSnapshot) |
173 m_snapshotState = DrawnToAfterSnapshot; | 172 m_snapshotState = DrawnToAfterSnapshot; |
174 m_surface->didDraw(rect); | 173 m_surface->didDraw(rect); |
175 } | 174 } |
176 | 175 |
177 WebLayer* ImageBuffer::platformLayer() const | 176 WebLayer* ImageBuffer::platformLayer() const |
178 { | 177 { |
179 return m_surface->layer(); | 178 return m_surface->layer(); |
180 } | 179 } |
181 | 180 |
182 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, gpu::gles
2::GLES2Interface* gl, Platform3DObject texture, GLenum internalFormat, GLenum d
estType, GLint level, bool premultiplyAlpha, bool flipY) | 181 bool ImageBuffer::copyToPlatformTexture(gpu::gles2::GLES2Interface* gl, Platform
3DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool prem
ultiplyAlpha, bool flipY) |
183 { | 182 { |
184 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalForm
at, destType, level)) | 183 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalForm
at, destType, level)) |
185 return false; | 184 return false; |
186 | 185 |
187 if (!isSurfaceValid()) | 186 if (!isSurfaceValid()) |
188 return false; | 187 return false; |
189 | 188 |
190 RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot(PreferAccel
eration, SnapshotReasonCopyToWebGLTexture); | 189 RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot(PreferAccel
eration, SnapshotReasonCopyToWebGLTexture); |
191 if (!textureImage) | 190 if (!textureImage) |
192 return false; | 191 return false; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 return true; | 240 return true; |
242 } | 241 } |
243 | 242 |
244 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer, SourceDrawingBuffer sourceBuffer) | 243 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer, SourceDrawingBuffer sourceBuffer) |
245 { | 244 { |
246 if (!drawingBuffer || !m_surface->isAccelerated()) | 245 if (!drawingBuffer || !m_surface->isAccelerated()) |
247 return false; | 246 return false; |
248 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); | 247 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); |
249 if (!provider) | 248 if (!provider) |
250 return false; | 249 return false; |
251 WebGraphicsContext3D* context3D = provider->context3d(); | |
252 gpu::gles2::GLES2Interface* gl = provider->contextGL(); | 250 gpu::gles2::GLES2Interface* gl = provider->contextGL(); |
253 Platform3DObject textureId = m_surface->getBackingTextureHandleForOverwrite(
); | 251 Platform3DObject textureId = m_surface->getBackingTextureHandleForOverwrite(
); |
254 if (!textureId) | 252 if (!textureId) |
255 return false; | 253 return false; |
256 | 254 |
257 gl->Flush(); | 255 gl->Flush(); |
258 | 256 |
259 return drawingBuffer->copyToPlatformTexture(context3D, gl, textureId, GL_RGB
A, | 257 return drawingBuffer->copyToPlatformTexture(gl, textureId, GL_RGBA, |
260 GL_UNSIGNED_BYTE, 0, true, false, sourceBuffer); | 258 GL_UNSIGNED_BYTE, 0, true, false, sourceBuffer); |
261 } | 259 } |
262 | 260 |
263 void ImageBuffer::draw(GraphicsContext& context, const FloatRect& destRect, cons
t FloatRect* srcPtr, SkXfermode::Mode op) | 261 void ImageBuffer::draw(GraphicsContext& context, const FloatRect& destRect, cons
t FloatRect* srcPtr, SkXfermode::Mode op) |
264 { | 262 { |
265 if (!isSurfaceValid()) | 263 if (!isSurfaceValid()) |
266 return; | 264 return; |
267 | 265 |
268 FloatRect srcRect = srcPtr ? *srcPtr : FloatRect(FloatPoint(), FloatSize(siz
e())); | 266 FloatRect srcRect = srcPtr ? *srcPtr : FloatRect(FloatPoint(), FloatSize(siz
e())); |
269 m_surface->draw(context, destRect, srcRect, op); | 267 m_surface->draw(context, destRect, srcRect, op); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 401 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
404 | 402 |
405 Vector<unsigned char> result; | 403 Vector<unsigned char> result; |
406 if (!encodeImage(mimeType, quality, &result)) | 404 if (!encodeImage(mimeType, quality, &result)) |
407 return "data:,"; | 405 return "data:,"; |
408 | 406 |
409 return "data:" + mimeType + ";base64," + base64Encode(result); | 407 return "data:" + mimeType + ";base64," + base64Encode(result); |
410 } | 408 } |
411 | 409 |
412 } // namespace blink | 410 } // namespace blink |
OLD | NEW |