| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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" | 51 #include "public/platform/WebGraphicsContext3D.h" |
| 52 #include "public/platform/WebGraphicsContext3DProvider.h" | 52 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 53 #include "third_party/skia/include/core/SkColorFilter.h" |
| 53 #include "third_party/skia/include/core/SkPicture.h" | 54 #include "third_party/skia/include/core/SkPicture.h" |
| 54 #include "wtf/ArrayBufferContents.h" | 55 #include "wtf/ArrayBufferContents.h" |
| 55 #include "wtf/MathExtras.h" | 56 #include "wtf/MathExtras.h" |
| 56 #include "wtf/Vector.h" | 57 #include "wtf/Vector.h" |
| 57 #include "wtf/text/Base64.h" | 58 #include "wtf/text/Base64.h" |
| 58 #include "wtf/text/WTFString.h" | 59 #include "wtf/text/WTFString.h" |
| 59 | 60 |
| 60 namespace blink { | 61 namespace blink { |
| 61 | 62 |
| 62 PassOwnPtr<ImageBuffer> ImageBuffer::create(PassOwnPtr<ImageBufferSurface> surfa
ce) | 63 PassOwnPtr<ImageBuffer> ImageBuffer::create(PassOwnPtr<ImageBufferSurface> surfa
ce) |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 Platform3DObject textureId = m_surface->getBackingTextureHandleForOverwrite(
); | 252 Platform3DObject textureId = m_surface->getBackingTextureHandleForOverwrite(
); |
| 252 if (!textureId) | 253 if (!textureId) |
| 253 return false; | 254 return false; |
| 254 | 255 |
| 255 context3D->flush(); | 256 context3D->flush(); |
| 256 | 257 |
| 257 return drawingBuffer->copyToPlatformTexture(context3D, textureId, GL_RGBA, | 258 return drawingBuffer->copyToPlatformTexture(context3D, textureId, GL_RGBA, |
| 258 GL_UNSIGNED_BYTE, 0, true, false, sourceBuffer); | 259 GL_UNSIGNED_BYTE, 0, true, false, sourceBuffer); |
| 259 } | 260 } |
| 260 | 261 |
| 261 void ImageBuffer::draw(GraphicsContext& context, const FloatRect& destRect, cons
t FloatRect* srcPtr, SkXfermode::Mode op) | 262 void ImageBuffer::draw(GraphicsContext& context, const FloatRect& destRect, cons
t FloatRect* srcPtr, SkXfermode::Mode op, SkColorFilter* transform) |
| 262 { | 263 { |
| 263 if (!isSurfaceValid()) | 264 if (!isSurfaceValid()) |
| 264 return; | 265 return; |
| 265 | 266 |
| 266 FloatRect srcRect = srcPtr ? *srcPtr : FloatRect(FloatPoint(), FloatSize(siz
e())); | 267 FloatRect srcRect = srcPtr ? *srcPtr : FloatRect(FloatPoint(), FloatSize(siz
e())); |
| 267 m_surface->draw(context, destRect, srcRect, op); | 268 m_surface->draw(context, destRect, srcRect, op, transform); |
| 268 } | 269 } |
| 269 | 270 |
| 270 void ImageBuffer::flush() | 271 void ImageBuffer::flush() |
| 271 { | 272 { |
| 272 if (m_surface->canvas()) { | 273 if (m_surface->canvas()) { |
| 273 m_surface->flush(); | 274 m_surface->flush(); |
| 274 } | 275 } |
| 275 } | 276 } |
| 276 | 277 |
| 277 void ImageBuffer::flushGpu() | 278 void ImageBuffer::flushGpu() |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 401 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 401 | 402 |
| 402 Vector<unsigned char> result; | 403 Vector<unsigned char> result; |
| 403 if (!encodeImage(mimeType, quality, &result)) | 404 if (!encodeImage(mimeType, quality, &result)) |
| 404 return "data:,"; | 405 return "data:,"; |
| 405 | 406 |
| 406 return "data:" + mimeType + ";base64," + base64Encode(result); | 407 return "data:" + mimeType + ";base64," + base64Encode(result); |
| 407 } | 408 } |
| 408 | 409 |
| 409 } // namespace blink | 410 } // namespace blink |
| OLD | NEW |