| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 return FinishPrepareTextureMailboxSoftware(out_mailbox, | 289 return FinishPrepareTextureMailboxSoftware(out_mailbox, |
| 290 out_release_callback); | 290 out_release_callback); |
| 291 } else { | 291 } else { |
| 292 return FinishPrepareTextureMailboxGpu(out_mailbox, out_release_callback); | 292 return FinishPrepareTextureMailboxGpu(out_mailbox, out_release_callback); |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 bool DrawingBuffer::FinishPrepareTextureMailboxSoftware( | 296 bool DrawingBuffer::FinishPrepareTextureMailboxSoftware( |
| 297 cc::TextureMailbox* out_mailbox, | 297 cc::TextureMailbox* out_mailbox, |
| 298 std::unique_ptr<cc::SingleReleaseCallback>* out_release_callback) { | 298 std::unique_ptr<cc::SingleReleaseCallback>* out_release_callback) { |
| 299 DCHECK(state_restorer_); |
| 299 std::unique_ptr<cc::SharedBitmap> bitmap = CreateOrRecycleBitmap(); | 300 std::unique_ptr<cc::SharedBitmap> bitmap = CreateOrRecycleBitmap(); |
| 300 if (!bitmap) | 301 if (!bitmap) |
| 301 return false; | 302 return false; |
| 302 | 303 |
| 303 // Read the framebuffer into |bitmap|. | 304 // Read the framebuffer into |bitmap|. |
| 304 { | 305 { |
| 305 unsigned char* pixels = bitmap->pixels(); | 306 unsigned char* pixels = bitmap->pixels(); |
| 306 DCHECK(pixels); | 307 DCHECK(pixels); |
| 307 bool need_premultiply = want_alpha_channel_ && !premultiplied_alpha_; | 308 bool need_premultiply = want_alpha_channel_ && !premultiplied_alpha_; |
| 308 WebGLImageConversion::AlphaOp op = | 309 WebGLImageConversion::AlphaOp op = |
| 309 need_premultiply ? WebGLImageConversion::kAlphaDoPremultiply | 310 need_premultiply ? WebGLImageConversion::kAlphaDoPremultiply |
| 310 : WebGLImageConversion::kAlphaDoNothing; | 311 : WebGLImageConversion::kAlphaDoNothing; |
| 312 state_restorer_->SetFramebufferBindingDirty(); |
| 313 gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_); |
| 311 ReadBackFramebuffer(pixels, Size().Width(), Size().Height(), kReadbackSkia, | 314 ReadBackFramebuffer(pixels, Size().Width(), Size().Height(), kReadbackSkia, |
| 312 op); | 315 op); |
| 313 } | 316 } |
| 314 | 317 |
| 315 *out_mailbox = cc::TextureMailbox(bitmap.get(), size_); | 318 *out_mailbox = cc::TextureMailbox(bitmap.get(), size_); |
| 316 out_mailbox->set_color_space(color_space_); | 319 out_mailbox->set_color_space(color_space_); |
| 317 | 320 |
| 318 // This holds a ref on the DrawingBuffer that will keep it alive until the | 321 // This holds a ref on the DrawingBuffer that will keep it alive until the |
| 319 // mailbox is released (and while the release callback is running). It also | 322 // mailbox is released (and while the release callback is running). It also |
| 320 // owns the SharedBitmap. | 323 // owns the SharedBitmap. |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 if (pixel_unpack_buffer_binding_dirty_) | 1380 if (pixel_unpack_buffer_binding_dirty_) |
| 1378 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); | 1381 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); |
| 1379 } | 1382 } |
| 1380 | 1383 |
| 1381 bool DrawingBuffer::ShouldUseChromiumImage() { | 1384 bool DrawingBuffer::ShouldUseChromiumImage() { |
| 1382 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && | 1385 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && |
| 1383 chromium_image_usage_ == kAllowChromiumImage; | 1386 chromium_image_usage_ == kAllowChromiumImage; |
| 1384 } | 1387 } |
| 1385 | 1388 |
| 1386 } // namespace blink | 1389 } // namespace blink |
| OLD | NEW |