Chromium Code Reviews| 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_animationState == InitialAnimationState) | |
| 153 m_animationState = DidAcquireSnapshot; | |
|
Stephen White
2015/08/17 15:15:07
Naming nit: m_drawnToAfterSnapshot or something li
| |
| 154 | |
| 152 if (!isSurfaceValid()) | 155 if (!isSurfaceValid()) |
| 153 return nullptr; | 156 return nullptr; |
| 154 return m_surface->newImageSnapshot(); | 157 return m_surface->newImageSnapshot(); |
| 155 } | 158 } |
| 156 | 159 |
| 157 PassRefPtr<Image> ImageBuffer::newImageSnapshot() const | 160 PassRefPtr<Image> ImageBuffer::newImageSnapshot() const |
| 158 { | 161 { |
| 159 if (!isSurfaceValid()) | 162 RefPtr<SkImage> snapshot = newSkImageSnapshot(); |
| 160 return nullptr; | |
| 161 RefPtr<SkImage> snapshot = m_surface->newImageSnapshot(); | |
| 162 if (!snapshot) | 163 if (!snapshot) |
| 163 return nullptr; | 164 return nullptr; |
| 164 return StaticBitmapImage::create(snapshot); | 165 return StaticBitmapImage::create(snapshot); |
| 165 } | 166 } |
| 166 | 167 |
| 168 void ImageBuffer::didDraw(const FloatRect& rect) const | |
| 169 { | |
| 170 if (m_animationState == DidAcquireSnapshot) | |
| 171 m_animationState = DidDrawAfterSnapshot; | |
| 172 m_surface->didDraw(rect); | |
| 173 } | |
| 174 | |
| 167 WebLayer* ImageBuffer::platformLayer() const | 175 WebLayer* ImageBuffer::platformLayer() const |
| 168 { | 176 { |
| 169 return m_surface->layer(); | 177 return m_surface->layer(); |
| 170 } | 178 } |
| 171 | 179 |
| 172 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3 DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu ltiplyAlpha, bool flipY) | 180 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3 DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu ltiplyAlpha, bool flipY) |
| 173 { | 181 { |
| 174 if (!m_surface->isAccelerated() || !isSurfaceValid()) | 182 if (!m_surface->isAccelerated() || !isSurfaceValid()) |
| 175 return false; | 183 return false; |
| 176 | 184 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 370 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 363 | 371 |
| 364 Vector<char> encodedImage; | 372 Vector<char> encodedImage; |
| 365 if (!encodeImage(*this, mimeType, quality, &encodedImage)) | 373 if (!encodeImage(*this, mimeType, quality, &encodedImage)) |
| 366 return "data:,"; | 374 return "data:,"; |
| 367 | 375 |
| 368 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); | 376 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); |
| 369 } | 377 } |
| 370 | 378 |
| 371 } // namespace blink | 379 } // namespace blink |
| OLD | NEW |