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

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

Issue 372093002: Fixes for re-enabling more MSVC level 4 warnings: content/renderer/ edition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comment Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 "content/renderer/gpu/compositor_software_output_device.h" 5 #include "content/renderer/gpu/compositor_software_output_device.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "cc/output/software_frame_data.h" 8 #include "cc/output/software_frame_data.h"
9 #include "content/child/child_shared_bitmap_manager.h" 9 #include "content/child/child_shared_bitmap_manager.h"
10 #include "content/renderer/render_process.h" 10 #include "content/renderer/render_process.h"
11 #include "content/renderer/render_thread_impl.h" 11 #include "content/renderer/render_thread_impl.h"
12 #include "third_party/skia/include/core/SkBitmapDevice.h" 12 #include "third_party/skia/include/core/SkBitmapDevice.h"
13 #include "third_party/skia/include/core/SkCanvas.h" 13 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkPixelRef.h" 14 #include "third_party/skia/include/core/SkPixelRef.h"
15 #include "third_party/skia/include/core/SkRegion.h" 15 #include "third_party/skia/include/core/SkRegion.h"
16 #include "ui/gfx/skia_util.h" 16 #include "ui/gfx/skia_util.h"
17 17
18 namespace {
19
20 const size_t kInvalidIndex = static_cast<size_t>(-1);
21
22 } // namespace
23
18 namespace content { 24 namespace content {
19 25
20 CompositorSoftwareOutputDevice::Buffer::Buffer( 26 CompositorSoftwareOutputDevice::Buffer::Buffer(
21 unsigned id, 27 unsigned id,
22 scoped_ptr<cc::SharedBitmap> bitmap) 28 scoped_ptr<cc::SharedBitmap> bitmap)
23 : id_(id), shared_bitmap_(bitmap.Pass()), free_(true), parent_(NULL) {} 29 : id_(id), shared_bitmap_(bitmap.Pass()), free_(true), parent_(NULL) {}
24 30
25 CompositorSoftwareOutputDevice::Buffer::~Buffer() { 31 CompositorSoftwareOutputDevice::Buffer::~Buffer() {
26 } 32 }
27 33
(...skipping 21 matching lines...) Expand all
49 *result = damage; 55 *result = damage;
50 return true; 56 return true;
51 } 57 }
52 current = current->parent_; 58 current = current->parent_;
53 } 59 }
54 60
55 return false; 61 return false;
56 } 62 }
57 63
58 CompositorSoftwareOutputDevice::CompositorSoftwareOutputDevice() 64 CompositorSoftwareOutputDevice::CompositorSoftwareOutputDevice()
59 : current_index_(-1), 65 : current_index_(kInvalidIndex),
60 next_buffer_id_(1), 66 next_buffer_id_(1),
61 shared_bitmap_manager_( 67 shared_bitmap_manager_(
62 RenderThreadImpl::current()->shared_bitmap_manager()) { 68 RenderThreadImpl::current()->shared_bitmap_manager()) {
63 DetachFromThread(); 69 DetachFromThread();
64 } 70 }
65 71
66 CompositorSoftwareOutputDevice::~CompositorSoftwareOutputDevice() { 72 CompositorSoftwareOutputDevice::~CompositorSoftwareOutputDevice() {
67 DCHECK(CalledOnValidThread()); 73 DCHECK(CalledOnValidThread());
68 } 74 }
69 75
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 112
107 // Keep non-ACKed buffers in awaiting_ack_ until they get acknowledged. 113 // Keep non-ACKed buffers in awaiting_ack_ until they get acknowledged.
108 for (size_t i = 0; i < buffers_.size(); ++i) { 114 for (size_t i = 0; i < buffers_.size(); ++i) {
109 if (!buffers_[i]->free()) { 115 if (!buffers_[i]->free()) {
110 awaiting_ack_.push_back(buffers_[i]); 116 awaiting_ack_.push_back(buffers_[i]);
111 buffers_[i] = NULL; 117 buffers_[i] = NULL;
112 } 118 }
113 } 119 }
114 120
115 buffers_.clear(); 121 buffers_.clear();
116 current_index_ = -1; 122 current_index_ = kInvalidIndex;
117 viewport_pixel_size_ = viewport_pixel_size; 123 viewport_pixel_size_ = viewport_pixel_size;
118 } 124 }
119 125
120 void CompositorSoftwareOutputDevice::DiscardBackbuffer() { 126 void CompositorSoftwareOutputDevice::DiscardBackbuffer() {
121 // Keep non-ACKed buffers in awaiting_ack_ until they get acknowledged. 127 // Keep non-ACKed buffers in awaiting_ack_ until they get acknowledged.
122 for (size_t i = 0; i < buffers_.size(); ++i) { 128 for (size_t i = 0; i < buffers_.size(); ++i) {
123 if (!buffers_[i]->free()) { 129 if (!buffers_[i]->free()) {
124 awaiting_ack_.push_back(buffers_[i]); 130 awaiting_ack_.push_back(buffers_[i]);
125 buffers_[i] = NULL; 131 buffers_[i] = NULL;
126 } 132 }
127 } 133 }
128 buffers_.clear(); 134 buffers_.clear();
129 current_index_ = -1; 135 current_index_ = kInvalidIndex;
130 } 136 }
131 137
132 void CompositorSoftwareOutputDevice::EnsureBackbuffer() { 138 void CompositorSoftwareOutputDevice::EnsureBackbuffer() {
133 } 139 }
134 140
135 SkCanvas* CompositorSoftwareOutputDevice::BeginPaint( 141 SkCanvas* CompositorSoftwareOutputDevice::BeginPaint(
136 const gfx::Rect& damage_rect) { 142 const gfx::Rect& damage_rect) {
137 DCHECK(CalledOnValidThread()); 143 DCHECK(CalledOnValidThread());
138 144
139 Buffer* previous = NULL; 145 Buffer* previous = NULL;
140 if (current_index_ != size_t(-1)) 146 if (current_index_ != kInvalidIndex)
141 previous = buffers_[current_index_]; 147 previous = buffers_[current_index_];
142 current_index_ = FindFreeBuffer(current_index_ + 1); 148 current_index_ = FindFreeBuffer(current_index_ + 1);
143 Buffer* current = buffers_[current_index_]; 149 Buffer* current = buffers_[current_index_];
144 DCHECK(current->free()); 150 DCHECK(current->free());
145 current->SetFree(false); 151 current->SetFree(false);
146 152
147 // Set up a canvas for the current front buffer. 153 // Set up a canvas for the current front buffer.
148 SkImageInfo info = SkImageInfo::MakeN32Premul(viewport_pixel_size_.width(), 154 SkImageInfo info = SkImageInfo::MakeN32Premul(viewport_pixel_size_.width(),
149 viewport_pixel_size_.height()); 155 viewport_pixel_size_.height());
150 SkBitmap bitmap; 156 SkBitmap bitmap;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return; 225 return;
220 } else { 226 } else {
221 it = std::find_if(awaiting_ack_.begin(), awaiting_ack_.end(), 227 it = std::find_if(awaiting_ack_.begin(), awaiting_ack_.end(),
222 CompareById(id)); 228 CompareById(id));
223 DCHECK(it != awaiting_ack_.end()); 229 DCHECK(it != awaiting_ack_.end());
224 awaiting_ack_.erase(it); 230 awaiting_ack_.erase(it);
225 } 231 }
226 } 232 }
227 233
228 } // namespace content 234 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/compositor_software_output_device.h ('k') | content/renderer/history_serialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698