OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/blink/skcanvas_video_renderer.h" | 5 #include "media/blink/skcanvas_video_renderer.h" |
6 | 6 |
7 #include "gpu/GLES2/gl2extchromium.h" | 7 #include "gpu/GLES2/gl2extchromium.h" |
8 #include "gpu/command_buffer/client/gles2_interface.h" | 8 #include "gpu/command_buffer/client/gles2_interface.h" |
9 #include "gpu/command_buffer/common/mailbox_holder.h" | 9 #include "gpu/command_buffer/common/mailbox_holder.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 desc.fSampleCnt = 0; | 72 desc.fSampleCnt = 0; |
73 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 73 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
74 desc.fWidth = size.width(); | 74 desc.fWidth = size.width(); |
75 desc.fHeight = size.height(); | 75 desc.fHeight = size.height(); |
76 skia::RefPtr<GrTexture> texture = skia::AdoptRef( | 76 skia::RefPtr<GrTexture> texture = skia::AdoptRef( |
77 gr->textureProvider()->refScratchTexture( | 77 gr->textureProvider()->refScratchTexture( |
78 desc, GrTextureProvider::kExact_ScratchTexMatch)); | 78 desc, GrTextureProvider::kExact_ScratchTexMatch)); |
79 if (!texture.get()) | 79 if (!texture.get()) |
80 return false; | 80 return false; |
81 | 81 |
| 82 // A recycled texture may have pending writes. Make sure they are flushed |
| 83 // before the texture is handed over for subsequent operations done outside |
| 84 // of Skia. |
| 85 texture->flushWrites(); |
| 86 |
82 SkImageInfo info = SkImageInfo::MakeN32Premul(desc.fWidth, desc.fHeight); | 87 SkImageInfo info = SkImageInfo::MakeN32Premul(desc.fWidth, desc.fHeight); |
83 SkGrPixelRef* pixel_ref = SkNEW_ARGS(SkGrPixelRef, (info, texture.get())); | 88 SkGrPixelRef* pixel_ref = SkNEW_ARGS(SkGrPixelRef, (info, texture.get())); |
84 if (!pixel_ref) | 89 if (!pixel_ref) |
85 return false; | 90 return false; |
86 bitmap->setInfo(info); | 91 bitmap->setInfo(info); |
87 bitmap->setPixelRef(pixel_ref)->unref(); | 92 bitmap->setPixelRef(pixel_ref)->unref(); |
88 return true; | 93 return true; |
89 } | 94 } |
90 | 95 |
91 class SyncPointClientImpl : public VideoFrame::SyncPointClient { | 96 class SyncPointClientImpl : public VideoFrame::SyncPointClient { |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 } | 678 } |
674 | 679 |
675 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() { | 680 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() { |
676 accelerated_last_image_.reset(); | 681 accelerated_last_image_.reset(); |
677 accelerated_last_frame_.reset(); | 682 accelerated_last_frame_.reset(); |
678 accelerated_generator_ = nullptr; | 683 accelerated_generator_ = nullptr; |
679 accelerated_last_frame_timestamp_ = media::kNoTimestamp(); | 684 accelerated_last_frame_timestamp_ = media::kNoTimestamp(); |
680 } | 685 } |
681 | 686 |
682 } // namespace media | 687 } // namespace media |
OLD | NEW |