| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/AcceleratedStaticBitmapImage.h" | 5 #include "platform/graphics/AcceleratedStaticBitmapImage.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" | 7 #include "gpu/command_buffer/client/gles2_interface.h" |
| 8 #include "gpu/command_buffer/common/sync_token.h" | 8 #include "gpu/command_buffer/common/sync_token.h" |
| 9 #include "platform/graphics/MailboxTextureHolder.h" | 9 #include "platform/graphics/MailboxTextureHolder.h" |
| 10 #include "platform/graphics/SkiaTextureHolder.h" | 10 #include "platform/graphics/SkiaTextureHolder.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 IntSize AcceleratedStaticBitmapImage::size() const { | 59 IntSize AcceleratedStaticBitmapImage::size() const { |
| 60 return texture_holder_->size(); | 60 return texture_holder_->size(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void AcceleratedStaticBitmapImage::UpdateSyncToken(gpu::SyncToken sync_token) { | 63 void AcceleratedStaticBitmapImage::UpdateSyncToken(gpu::SyncToken sync_token) { |
| 64 texture_holder_->UpdateSyncToken(sync_token); | 64 texture_holder_->UpdateSyncToken(sync_token); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void AcceleratedStaticBitmapImage::CopyToTexture( | 67 void AcceleratedStaticBitmapImage::CopyToTexture( |
| 68 WebGraphicsContext3DProvider* dest_provider, | 68 WebGraphicsContext3DProvider* dest_provider, |
| 69 GLenum dest_target, |
| 69 GLuint dest_texture_id, | 70 GLuint dest_texture_id, |
| 70 GLenum internal_format, | 71 bool flip_y, |
| 71 GLenum dest_type, | 72 const IntPoint& dest_point, |
| 72 bool flip_y) { | 73 const IntRect& source_sub_rectangle) { |
| 73 CheckThread(); | 74 CheckThread(); |
| 74 if (!IsValid()) | 75 if (!IsValid()) |
| 75 return; | 76 return; |
| 76 // |destProvider| may not be the same context as the one used for |m_image|, | 77 // |destProvider| may not be the same context as the one used for |m_image|, |
| 77 // so we use a mailbox to generate a texture id for |destProvider| to access. | 78 // so we use a mailbox to generate a texture id for |destProvider| to access. |
| 78 EnsureMailbox(); | 79 EnsureMailbox(); |
| 79 | 80 |
| 80 // Get a texture id that |destProvider| knows about and copy from it. | 81 // Get a texture id that |destProvider| knows about and copy from it. |
| 81 gpu::gles2::GLES2Interface* dest_gl = dest_provider->ContextGL(); | 82 gpu::gles2::GLES2Interface* dest_gl = dest_provider->ContextGL(); |
| 82 dest_gl->WaitSyncTokenCHROMIUM(texture_holder_->GetSyncToken().GetData()); | 83 dest_gl->WaitSyncTokenCHROMIUM(texture_holder_->GetSyncToken().GetData()); |
| 83 GLuint source_texture_id = dest_gl->CreateAndConsumeTextureCHROMIUM( | 84 GLuint source_texture_id = dest_gl->CreateAndConsumeTextureCHROMIUM( |
| 84 GL_TEXTURE_2D, texture_holder_->GetMailbox().name); | 85 GL_TEXTURE_2D, texture_holder_->GetMailbox().name); |
| 85 dest_gl->CopyTextureCHROMIUM(source_texture_id, 0, GL_TEXTURE_2D, | 86 dest_gl->CopySubTextureCHROMIUM( |
| 86 dest_texture_id, 0, internal_format, dest_type, | 87 source_texture_id, 0, dest_target, dest_texture_id, 0, dest_point.X(), |
| 87 flip_y, false, false); | 88 dest_point.Y(), source_sub_rectangle.X(), source_sub_rectangle.Y(), |
| 89 source_sub_rectangle.Width(), source_sub_rectangle.Height(), flip_y, |
| 90 false, false); |
| 88 // This drops the |destGL| context's reference on our |m_mailbox|, but it's | 91 // This drops the |destGL| context's reference on our |m_mailbox|, but it's |
| 89 // still held alive by our SkImage. | 92 // still held alive by our SkImage. |
| 90 dest_gl->DeleteTextures(1, &source_texture_id); | 93 dest_gl->DeleteTextures(1, &source_texture_id); |
| 91 } | 94 } |
| 92 | 95 |
| 93 sk_sp<SkImage> AcceleratedStaticBitmapImage::ImageForCurrentFrame() { | 96 sk_sp<SkImage> AcceleratedStaticBitmapImage::ImageForCurrentFrame() { |
| 94 CheckThread(); | 97 CheckThread(); |
| 95 if (!IsValid()) | 98 if (!IsValid()) |
| 96 return nullptr; | 99 return nullptr; |
| 97 CreateImageFromMailboxIfNeeded(); | 100 CreateImageFromMailboxIfNeeded(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 173 |
| 171 void AcceleratedStaticBitmapImage::CheckThread() { | 174 void AcceleratedStaticBitmapImage::CheckThread() { |
| 172 if (detach_thread_at_next_check_) { | 175 if (detach_thread_at_next_check_) { |
| 173 thread_checker_.DetachFromThread(); | 176 thread_checker_.DetachFromThread(); |
| 174 detach_thread_at_next_check_ = false; | 177 detach_thread_at_next_check_ = false; |
| 175 } | 178 } |
| 176 CHECK(thread_checker_.CalledOnValidThread()); | 179 CHECK(thread_checker_.CalledOnValidThread()); |
| 177 } | 180 } |
| 178 | 181 |
| 179 } // namespace blink | 182 } // namespace blink |
| OLD | NEW |