Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: content/renderer/gpu/compositor_software_output_device.h

Issue 1136553004: Remove CompositorSoftwareOutputDevice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_
6 #define CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/memory/shared_memory.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "cc/output/software_output_device.h"
13 #include "cc/resources/shared_bitmap.h"
14 #include "content/public/renderer/render_thread.h"
15 #include "third_party/skia/include/core/SkBitmap.h"
16
17 class SkRegion;
18
19 namespace cc {
20 class SharedBitmapManager;
21 }
22
23 namespace content {
24
25 // This class can be created only on the main thread, but then becomes pinned
26 // to a fixed thread when BindToClient is called.
27 class CompositorSoftwareOutputDevice
28 : NON_EXPORTED_BASE(public cc::SoftwareOutputDevice),
29 NON_EXPORTED_BASE(public base::NonThreadSafe) {
30 public:
31 CompositorSoftwareOutputDevice();
32 ~CompositorSoftwareOutputDevice() override;
33
34 void Resize(const gfx::Size& pixel_size, float scale_factor) override;
35
36 SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override;
37 void EndPaint(cc::SoftwareFrameData* frame_data) override;
38 void EnsureBackbuffer() override;
39 void DiscardBackbuffer() override;
40
41 void ReclaimSoftwareFrame(unsigned id) override;
42
43 private:
44 // Internal buffer class that manages shared memory lifetime and ownership.
45 // It also tracks buffers' history so we can calculate what's the minimum
46 // damage rect difference between any two given buffers (see SetParent and
47 // FindDamageDifferenceFrom).
48 class Buffer {
49 public:
50 explicit Buffer(unsigned id, scoped_ptr<cc::SharedBitmap> bitmap);
51 ~Buffer();
52
53 unsigned id() const { return id_; }
54
55 void* memory() const { return shared_bitmap_->pixels(); }
56 cc::SharedBitmapId shared_bitmap_id() const { return shared_bitmap_->id(); }
57
58 bool free() const { return free_; }
59 void SetFree(bool free) { free_ = free; }
60
61 Buffer* parent() const { return parent_; }
62 void SetParent(Buffer* parent, const gfx::Rect& damage);
63
64 bool FindDamageDifferenceFrom(Buffer* buffer, SkRegion* result) const;
65
66 private:
67 const unsigned id_;
68 scoped_ptr<cc::SharedBitmap> shared_bitmap_;
69 bool free_;
70 Buffer* parent_;
71 gfx::Rect damage_;
72
73 DISALLOW_COPY_AND_ASSIGN(Buffer);
74 };
75
76 class CompareById {
77 public:
78 CompareById(unsigned id) : id_(id) {}
79
80 bool operator()(const Buffer* buffer) const {
81 return buffer->id() == id_;
82 }
83
84 private:
85 const unsigned id_;
86 };
87
88 unsigned GetNextId();
89 Buffer* CreateBuffer();
90 size_t FindFreeBuffer(size_t hint);
91
92 size_t current_index_;
93 unsigned next_buffer_id_;
94 ScopedVector<Buffer> buffers_;
95 ScopedVector<Buffer> awaiting_ack_;
96 cc::SharedBitmapManager* shared_bitmap_manager_;
97 };
98
99 } // namespace content
100
101 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_
OLDNEW
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/gpu/compositor_software_output_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698