| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 142 } |
| 143 | 143 |
| 144 void ImageBuffer::resetCanvas(SkCanvas* canvas) const | 144 void ImageBuffer::resetCanvas(SkCanvas* canvas) const |
| 145 { | 145 { |
| 146 if (m_client) | 146 if (m_client) |
| 147 m_client->restoreCanvasMatrixClipStack(canvas); | 147 m_client->restoreCanvasMatrixClipStack(canvas); |
| 148 } | 148 } |
| 149 | 149 |
| 150 PassRefPtr<SkImage> ImageBuffer::newSkImageSnapshot() const | 150 PassRefPtr<SkImage> ImageBuffer::newSkImageSnapshot() const |
| 151 { | 151 { |
| 152 if (m_snapshotState == InitialSnapshotState) | |
| 153 m_snapshotState = DidAcquireSnapshot; | |
| 154 | |
| 155 if (!isSurfaceValid()) | 152 if (!isSurfaceValid()) |
| 156 return nullptr; | 153 return nullptr; |
| 157 return m_surface->newImageSnapshot(); | 154 return m_surface->newImageSnapshot(); |
| 158 } | 155 } |
| 159 | 156 |
| 160 PassRefPtr<Image> ImageBuffer::newImageSnapshot() const | 157 PassRefPtr<Image> ImageBuffer::newImageSnapshot() const |
| 161 { | 158 { |
| 162 RefPtr<SkImage> snapshot = newSkImageSnapshot(); | 159 if (!isSurfaceValid()) |
| 160 return nullptr; |
| 161 RefPtr<SkImage> snapshot = m_surface->newImageSnapshot(); |
| 163 if (!snapshot) | 162 if (!snapshot) |
| 164 return nullptr; | 163 return nullptr; |
| 165 return StaticBitmapImage::create(snapshot); | 164 return StaticBitmapImage::create(snapshot); |
| 166 } | 165 } |
| 167 | 166 |
| 168 void ImageBuffer::didDraw(const FloatRect& rect) const | |
| 169 { | |
| 170 if (m_snapshotState == DidAcquireSnapshot) | |
| 171 m_snapshotState = DrawnToAfterSnapshot; | |
| 172 m_surface->didDraw(rect); | |
| 173 } | |
| 174 | |
| 175 WebLayer* ImageBuffer::platformLayer() const | 167 WebLayer* ImageBuffer::platformLayer() const |
| 176 { | 168 { |
| 177 return m_surface->layer(); | 169 return m_surface->layer(); |
| 178 } | 170 } |
| 179 | 171 |
| 180 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3
DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu
ltiplyAlpha, bool flipY) | 172 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3
DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu
ltiplyAlpha, bool flipY) |
| 181 { | 173 { |
| 182 if (!m_surface->isAccelerated() || !isSurfaceValid()) | 174 if (!m_surface->isAccelerated() || !isSurfaceValid()) |
| 183 return false; | 175 return false; |
| 184 | 176 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 362 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 371 | 363 |
| 372 Vector<char> encodedImage; | 364 Vector<char> encodedImage; |
| 373 if (!encodeImage(*this, mimeType, quality, &encodedImage)) | 365 if (!encodeImage(*this, mimeType, quality, &encodedImage)) |
| 374 return "data:,"; | 366 return "data:,"; |
| 375 | 367 |
| 376 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); | 368 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); |
| 377 } | 369 } |
| 378 | 370 |
| 379 } // namespace blink | 371 } // namespace blink |
| OLD | NEW |