| 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 23 matching lines...) Expand all Loading... |
| 34 #include "platform/graphics/ImageBuffer.h" | 34 #include "platform/graphics/ImageBuffer.h" |
| 35 | 35 |
| 36 #include "GrContext.h" | 36 #include "GrContext.h" |
| 37 #include "platform/MIMETypeRegistry.h" | 37 #include "platform/MIMETypeRegistry.h" |
| 38 #include "platform/geometry/IntRect.h" | 38 #include "platform/geometry/IntRect.h" |
| 39 #include "platform/graphics/GraphicsContext.h" | 39 #include "platform/graphics/GraphicsContext.h" |
| 40 #include "platform/graphics/GraphicsTypes3D.h" | 40 #include "platform/graphics/GraphicsTypes3D.h" |
| 41 #include "platform/graphics/ImageBufferClient.h" | 41 #include "platform/graphics/ImageBufferClient.h" |
| 42 #include "platform/graphics/StaticBitmapImage.h" | 42 #include "platform/graphics/StaticBitmapImage.h" |
| 43 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 43 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 44 #include "platform/graphics/UnacceleratedSimpleImageBufferSurface.h" |
| 44 #include "platform/graphics/gpu/DrawingBuffer.h" | 45 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 45 #include "platform/graphics/gpu/Extensions3DUtil.h" | 46 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 46 #include "platform/graphics/skia/SkiaUtils.h" | 47 #include "platform/graphics/skia/SkiaUtils.h" |
| 47 #include "platform/image-encoders/skia/JPEGImageEncoder.h" | 48 #include "platform/image-encoders/skia/JPEGImageEncoder.h" |
| 48 #include "platform/image-encoders/skia/PNGImageEncoder.h" | 49 #include "platform/image-encoders/skia/PNGImageEncoder.h" |
| 49 #include "platform/image-encoders/skia/WEBPImageEncoder.h" | 50 #include "platform/image-encoders/skia/WEBPImageEncoder.h" |
| 50 #include "public/platform/Platform.h" | 51 #include "public/platform/Platform.h" |
| 51 #include "public/platform/WebExternalTextureMailbox.h" | 52 #include "public/platform/WebExternalTextureMailbox.h" |
| 52 #include "public/platform/WebGraphicsContext3D.h" | 53 #include "public/platform/WebGraphicsContext3D.h" |
| 53 #include "public/platform/WebGraphicsContext3DProvider.h" | 54 #include "public/platform/WebGraphicsContext3DProvider.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 68 } | 69 } |
| 69 | 70 |
| 70 PassOwnPtr<ImageBuffer> ImageBuffer::create(const IntSize& size, OpacityMode opa
cityMode) | 71 PassOwnPtr<ImageBuffer> ImageBuffer::create(const IntSize& size, OpacityMode opa
cityMode) |
| 71 { | 72 { |
| 72 OwnPtr<ImageBufferSurface> surface(adoptPtr(new UnacceleratedImageBufferSurf
ace(size, opacityMode))); | 73 OwnPtr<ImageBufferSurface> surface(adoptPtr(new UnacceleratedImageBufferSurf
ace(size, opacityMode))); |
| 73 if (!surface->isValid()) | 74 if (!surface->isValid()) |
| 74 return nullptr; | 75 return nullptr; |
| 75 return adoptPtr(new ImageBuffer(surface.release())); | 76 return adoptPtr(new ImageBuffer(surface.release())); |
| 76 } | 77 } |
| 77 | 78 |
| 79 PassOwnPtr<ImageBuffer> ImageBuffer::createSimple(const IntSize& size, OpacityMo
de opacityMode) |
| 80 { |
| 81 OwnPtr<ImageBufferSurface> surface(adoptPtr(new UnacceleratedSimpleImageBuff
erSurface(size, opacityMode))); |
| 82 if (!surface->isValid()) |
| 83 return nullptr; |
| 84 return adoptPtr(new ImageBuffer(surface.release())); |
| 85 } |
| 86 |
| 78 ImageBuffer::ImageBuffer(PassOwnPtr<ImageBufferSurface> surface) | 87 ImageBuffer::ImageBuffer(PassOwnPtr<ImageBufferSurface> surface) |
| 79 : m_snapshotState(InitialSnapshotState) | 88 : m_snapshotState(InitialSnapshotState) |
| 80 , m_surface(surface) | 89 , m_surface(surface) |
| 81 , m_client(0) | 90 , m_client(0) |
| 82 { | 91 { |
| 83 m_surface->setImageBuffer(this); | 92 m_surface->setImageBuffer(this); |
| 84 } | 93 } |
| 85 | 94 |
| 86 ImageBuffer::~ImageBuffer() | 95 ImageBuffer::~ImageBuffer() |
| 87 { | 96 { |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 385 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 377 | 386 |
| 378 Vector<char> encodedImage; | 387 Vector<char> encodedImage; |
| 379 if (!encodeImage(mimeType, quality, &encodedImage)) | 388 if (!encodeImage(mimeType, quality, &encodedImage)) |
| 380 return "data:,"; | 389 return "data:,"; |
| 381 | 390 |
| 382 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); | 391 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); |
| 383 } | 392 } |
| 384 | 393 |
| 385 } // namespace blink | 394 } // namespace blink |
| OLD | NEW |