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

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

Issue 791753002: SkCanvas::NewRaster is deprecated, create a surface instead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update x11 Created 6 years 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
« no previous file with comments | « content/browser/compositor/software_output_device_x11.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if (current_index_ != kInvalidIndex) 145 if (current_index_ != kInvalidIndex)
146 previous = buffers_[current_index_]; 146 previous = buffers_[current_index_];
147 current_index_ = FindFreeBuffer(current_index_ + 1); 147 current_index_ = FindFreeBuffer(current_index_ + 1);
148 Buffer* current = buffers_[current_index_]; 148 Buffer* current = buffers_[current_index_];
149 DCHECK(current->free()); 149 DCHECK(current->free());
150 current->SetFree(false); 150 current->SetFree(false);
151 151
152 // Set up a canvas for the current front buffer. 152 // Set up a canvas for the current front buffer.
153 SkImageInfo info = SkImageInfo::MakeN32Premul(viewport_pixel_size_.width(), 153 SkImageInfo info = SkImageInfo::MakeN32Premul(viewport_pixel_size_.width(),
154 viewport_pixel_size_.height()); 154 viewport_pixel_size_.height());
155 SkBitmap bitmap; 155 surface_ = skia::AdoptRef(SkSurface::NewRasterDirect(info, current->memory(),
156 bitmap.installPixels(info, current->memory(), info.minRowBytes()); 156 info.minRowBytes()));
157 canvas_ = skia::AdoptRef(new SkCanvas(bitmap));
158 157
159 if (!previous) { 158 if (!previous) {
160 DCHECK(damage_rect == gfx::Rect(viewport_pixel_size_)); 159 DCHECK(damage_rect == gfx::Rect(viewport_pixel_size_));
161 } else { 160 } else {
162 // Find the smallest damage region that needs 161 // Find the smallest damage region that needs
163 // to be copied from the |previous| buffer. 162 // to be copied from the |previous| buffer.
164 SkRegion region; 163 SkRegion region;
165 bool found = 164 bool found =
166 current->FindDamageDifferenceFrom(previous, &region) || 165 current->FindDamageDifferenceFrom(previous, &region) ||
167 previous->FindDamageDifferenceFrom(current, &region); 166 previous->FindDamageDifferenceFrom(current, &region);
168 if (!found) 167 if (!found)
169 region = SkRegion(RectToSkIRect(gfx::Rect(viewport_pixel_size_))); 168 region = SkRegion(RectToSkIRect(gfx::Rect(viewport_pixel_size_)));
170 region.op(RectToSkIRect(damage_rect), SkRegion::kDifference_Op); 169 region.op(RectToSkIRect(damage_rect), SkRegion::kDifference_Op);
171 170
172 // Copy over the damage region. 171 // Copy over the damage region.
173 if (!region.isEmpty()) { 172 if (!region.isEmpty()) {
174 SkImageInfo info = SkImageInfo::MakeN32Premul( 173 SkImageInfo info = SkImageInfo::MakeN32Premul(
175 viewport_pixel_size_.width(), viewport_pixel_size_.height()); 174 viewport_pixel_size_.width(), viewport_pixel_size_.height());
176 SkBitmap back_bitmap; 175 SkBitmap back_bitmap;
177 back_bitmap.installPixels(info, previous->memory(), info.minRowBytes()); 176 back_bitmap.installPixels(info, previous->memory(), info.minRowBytes());
178 177
179 for (SkRegion::Iterator it(region); !it.done(); it.next()) { 178 for (SkRegion::Iterator it(region); !it.done(); it.next()) {
180 const SkIRect& src_rect = it.rect(); 179 const SkIRect& src_rect = it.rect();
181 SkRect dst_rect = SkRect::Make(src_rect); 180 SkRect dst_rect = SkRect::Make(src_rect);
182 canvas_->drawBitmapRect(back_bitmap, &src_rect, dst_rect, NULL); 181 surface_->getCanvas()->drawBitmapRect(back_bitmap, &src_rect, dst_rect);
183 } 182 }
184 } 183 }
185 } 184 }
186 185
187 // Make |current| child of |previous| and orphan all of |current|'s children. 186 // Make |current| child of |previous| and orphan all of |current|'s children.
188 current->SetParent(previous, damage_rect); 187 current->SetParent(previous, damage_rect);
189 for (size_t i = 0; i < buffers_.size(); ++i) { 188 for (size_t i = 0; i < buffers_.size(); ++i) {
190 Buffer* buffer = buffers_[i]; 189 Buffer* buffer = buffers_[i];
191 if (buffer->parent() == current) 190 if (buffer->parent() == current)
192 buffer->SetParent(NULL, gfx::Rect(viewport_pixel_size_)); 191 buffer->SetParent(NULL, gfx::Rect(viewport_pixel_size_));
193 } 192 }
194 damage_rect_ = damage_rect; 193 damage_rect_ = damage_rect;
195 194
196 return canvas_.get(); 195 return surface_->getCanvas();
197 } 196 }
198 197
199 void CompositorSoftwareOutputDevice::EndPaint( 198 void CompositorSoftwareOutputDevice::EndPaint(
200 cc::SoftwareFrameData* frame_data) { 199 cc::SoftwareFrameData* frame_data) {
201 DCHECK(CalledOnValidThread()); 200 DCHECK(CalledOnValidThread());
202 DCHECK(frame_data); 201 DCHECK(frame_data);
203 202
204 Buffer* buffer = buffers_[current_index_]; 203 Buffer* buffer = buffers_[current_index_];
205 frame_data->id = buffer->id(); 204 frame_data->id = buffer->id();
206 frame_data->size = viewport_pixel_size_; 205 frame_data->size = viewport_pixel_size_;
(...skipping 17 matching lines...) Expand all
224 return; 223 return;
225 } else { 224 } else {
226 it = std::find_if(awaiting_ack_.begin(), awaiting_ack_.end(), 225 it = std::find_if(awaiting_ack_.begin(), awaiting_ack_.end(),
227 CompareById(id)); 226 CompareById(id));
228 DCHECK(it != awaiting_ack_.end()); 227 DCHECK(it != awaiting_ack_.end());
229 awaiting_ack_.erase(it); 228 awaiting_ack_.erase(it);
230 } 229 }
231 } 230 }
232 231
233 } // namespace content 232 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/software_output_device_x11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698