OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_SOFTWARE_FRAME_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_SOFTWARE_FRAME_MANAGER_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "cc/output/software_frame_data.h" |
| 13 #include "cc/resources/single_release_callback.h" |
| 14 #include "cc/resources/texture_mailbox.h" |
| 15 #include "content/common/content_export.h" |
| 16 #include "ui/gfx/size.h" |
| 17 |
| 18 namespace content { |
| 19 class SoftwareFrame; |
| 20 class SoftwareFrameMemoryManager; |
| 21 |
| 22 class CONTENT_EXPORT SoftwareFrameManagerClient { |
| 23 public: |
| 24 // Called when the memory for the current software frame was freed. |
| 25 virtual void SoftwareFrameWasFreed( |
| 26 uint32 output_surface_id, unsigned frame_id) = 0; |
| 27 |
| 28 // Called when the SoftwareFrameMemoryManager has requested that the frame |
| 29 // be evicted. Upon receiving this callback, the client should release any |
| 30 // references that it may hold to the current frame, to ensure that its memory |
| 31 // is freed expediently. |
| 32 virtual void ReleaseReferencesToSoftwareFrame() = 0; |
| 33 }; |
| 34 |
| 35 class CONTENT_EXPORT SoftwareFrameManager { |
| 36 public: |
| 37 explicit SoftwareFrameManager( |
| 38 base::WeakPtr<SoftwareFrameManagerClient> client); |
| 39 ~SoftwareFrameManager(); |
| 40 |
| 41 // Swaps to a new frame from shared memory. This frame is guaranteed to |
| 42 // not be evicted until SwapToNewFrameComplete is called. |
| 43 bool SwapToNewFrame( |
| 44 uint32 output_surface_id, |
| 45 const cc::SoftwareFrameData* frame_data, |
| 46 float frame_device_scale_factor, |
| 47 base::ProcessHandle process_handle); |
| 48 void SwapToNewFrameComplete(bool visible); |
| 49 void SetVisibility(bool visible); |
| 50 bool HasCurrentFrame() const; |
| 51 void DiscardCurrentFrame(); |
| 52 void GetCurrentFrameMailbox( |
| 53 cc::TextureMailbox* mailbox, |
| 54 scoped_ptr<cc::SingleReleaseCallback>* callback); |
| 55 const void* GetCurrentFramePixels() const; |
| 56 gfx::Size GetCurrentFrameSizeInPixels() const; |
| 57 gfx::Size GetCurrentFrameSizeInDIP() const; |
| 58 |
| 59 private: |
| 60 friend class SoftwareFrameMemoryManager; |
| 61 |
| 62 // Called by SoftwareFrameMemoryManager to demand that the current frame |
| 63 // be evicted. |
| 64 void EvictCurrentFrame(); |
| 65 |
| 66 base::WeakPtr<SoftwareFrameManagerClient> client_; |
| 67 |
| 68 // This holds the current software framebuffer. |
| 69 scoped_refptr<SoftwareFrame> current_frame_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(SoftwareFrameManager); |
| 72 }; |
| 73 |
| 74 } // namespace content |
| 75 |
| 76 #endif // CONTENT_BROWSER_RENDERER_HOST_SOFTWARE_FRAME_MANAGER_H_ |
OLD | NEW |