| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 snapshot_state_ = kDrawnToAfterSnapshot; | 212 snapshot_state_ = kDrawnToAfterSnapshot; |
| 213 surface_->DidDraw(rect); | 213 surface_->DidDraw(rect); |
| 214 } | 214 } |
| 215 | 215 |
| 216 WebLayer* ImageBuffer::PlatformLayer() const { | 216 WebLayer* ImageBuffer::PlatformLayer() const { |
| 217 return surface_->Layer(); | 217 return surface_->Layer(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool ImageBuffer::CopyToPlatformTexture(SnapshotReason reason, | 220 bool ImageBuffer::CopyToPlatformTexture(SnapshotReason reason, |
| 221 gpu::gles2::GLES2Interface* gl, | 221 gpu::gles2::GLES2Interface* gl, |
| 222 GLenum target, |
| 222 GLuint texture, | 223 GLuint texture, |
| 223 GLenum internal_format, | |
| 224 GLenum dest_type, | |
| 225 GLint level, | |
| 226 bool premultiply_alpha, | 224 bool premultiply_alpha, |
| 227 bool flip_y, | 225 bool flip_y, |
| 228 const IntPoint& dest_point, | 226 const IntPoint& dest_point, |
| 229 const IntRect& source_sub_rectangle) { | 227 const IntRect& source_sub_rectangle) { |
| 230 if (!Extensions3DUtil::CanUseCopyTextureCHROMIUM( | 228 if (!Extensions3DUtil::CanUseCopyTextureCHROMIUM(target)) |
| 231 GL_TEXTURE_2D, internal_format, dest_type, level)) | |
| 232 return false; | 229 return false; |
| 233 | 230 |
| 234 if (!IsSurfaceValid()) | 231 if (!IsSurfaceValid()) |
| 235 return false; | 232 return false; |
| 236 | 233 |
| 237 sk_sp<const SkImage> texture_image = | 234 sk_sp<const SkImage> texture_image = |
| 238 surface_->NewImageSnapshot(kPreferAcceleration, reason); | 235 surface_->NewImageSnapshot(kPreferAcceleration, reason); |
| 239 if (!texture_image) | 236 if (!texture_image) |
| 240 return false; | 237 return false; |
| 241 | 238 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 270 |
| 274 GLuint source_texture = | 271 GLuint source_texture = |
| 275 gl->CreateAndConsumeTextureCHROMIUM(texture_info->fTarget, mailbox.name); | 272 gl->CreateAndConsumeTextureCHROMIUM(texture_info->fTarget, mailbox.name); |
| 276 | 273 |
| 277 // The canvas is stored in a premultiplied format, so unpremultiply if | 274 // The canvas is stored in a premultiplied format, so unpremultiply if |
| 278 // necessary. The canvas is also stored in an inverted position, so the flip | 275 // necessary. The canvas is also stored in an inverted position, so the flip |
| 279 // semantics are reversed. | 276 // semantics are reversed. |
| 280 // It is expected that callers of this method have already allocated | 277 // It is expected that callers of this method have already allocated |
| 281 // the platform texture with the appropriate size. | 278 // the platform texture with the appropriate size. |
| 282 gl->CopySubTextureCHROMIUM( | 279 gl->CopySubTextureCHROMIUM( |
| 283 source_texture, 0, GL_TEXTURE_2D, texture, 0, dest_point.X(), | 280 source_texture, 0, target, texture, 0, dest_point.X(), dest_point.Y(), |
| 284 dest_point.Y(), source_sub_rectangle.X(), source_sub_rectangle.Y(), | 281 source_sub_rectangle.X(), source_sub_rectangle.Y(), |
| 285 source_sub_rectangle.Width(), source_sub_rectangle.Height(), | 282 source_sub_rectangle.Width(), source_sub_rectangle.Height(), |
| 286 flip_y ? GL_FALSE : GL_TRUE, GL_FALSE, | 283 flip_y ? GL_FALSE : GL_TRUE, GL_FALSE, |
| 287 premultiply_alpha ? GL_FALSE : GL_TRUE); | 284 premultiply_alpha ? GL_FALSE : GL_TRUE); |
| 288 | 285 |
| 289 gl->DeleteTextures(1, &source_texture); | 286 gl->DeleteTextures(1, &source_texture); |
| 290 | 287 |
| 291 const GLuint64 context_fence_sync = gl->InsertFenceSyncCHROMIUM(); | 288 const GLuint64 context_fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 292 | 289 |
| 293 gl->Flush(); | 290 gl->Flush(); |
| 294 | 291 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 318 if (!provider) | 315 if (!provider) |
| 319 return false; | 316 return false; |
| 320 gpu::gles2::GLES2Interface* gl = provider->ContextGL(); | 317 gpu::gles2::GLES2Interface* gl = provider->ContextGL(); |
| 321 GLuint texture_id = surface_->GetBackingTextureHandleForOverwrite(); | 318 GLuint texture_id = surface_->GetBackingTextureHandleForOverwrite(); |
| 322 if (!texture_id) | 319 if (!texture_id) |
| 323 return false; | 320 return false; |
| 324 | 321 |
| 325 gl->Flush(); | 322 gl->Flush(); |
| 326 | 323 |
| 327 return drawing_buffer->CopyToPlatformTexture( | 324 return drawing_buffer->CopyToPlatformTexture( |
| 328 gl, texture_id, GL_RGBA, GL_UNSIGNED_BYTE, 0, true, false, IntPoint(0, 0), | 325 gl, GL_TEXTURE_2D, texture_id, true, false, IntPoint(0, 0), |
| 329 IntRect(IntPoint(0, 0), drawing_buffer->size()), source_buffer); | 326 IntRect(IntPoint(0, 0), drawing_buffer->size()), source_buffer); |
| 330 } | 327 } |
| 331 | 328 |
| 332 void ImageBuffer::Draw(GraphicsContext& context, | 329 void ImageBuffer::Draw(GraphicsContext& context, |
| 333 const FloatRect& dest_rect, | 330 const FloatRect& dest_rect, |
| 334 const FloatRect* src_ptr, | 331 const FloatRect* src_ptr, |
| 335 SkBlendMode op) { | 332 SkBlendMode op) { |
| 336 if (!IsSurfaceValid()) | 333 if (!IsSurfaceValid()) |
| 337 return; | 334 return; |
| 338 | 335 |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type)); | 620 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type)); |
| 624 | 621 |
| 625 Vector<unsigned char> result; | 622 Vector<unsigned char> result; |
| 626 if (!EncodeImage(mime_type, quality, &result)) | 623 if (!EncodeImage(mime_type, quality, &result)) |
| 627 return "data:,"; | 624 return "data:,"; |
| 628 | 625 |
| 629 return "data:" + mime_type + ";base64," + Base64Encode(result); | 626 return "data:" + mime_type + ";base64," + Base64Encode(result); |
| 630 } | 627 } |
| 631 | 628 |
| 632 } // namespace blink | 629 } // namespace blink |
| OLD | NEW |