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

Side by Side Diff: content/browser/renderer_host/backing_store_aura.cc

Issue 11031055: Introduce PlatformBitmap, which is a minimal helper class that wraps an SkBitmap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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) 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 "content/browser/renderer_host/backing_store_aura.h" 5 #include "content/browser/renderer_host/backing_store_aura.h"
6 6
7 #include "content/browser/renderer_host/dip_util.h" 7 #include "content/browser/renderer_host/dip_util.h"
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 #include "content/public/browser/render_widget_host.h" 9 #include "content/public/browser/render_widget_host.h"
10 #include "skia/ext/platform_canvas.h" 10 #include "skia/ext/platform_canvas.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_dx); 142 int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_dx);
143 int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_dy); 143 int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_dy);
144 int w = pixel_rect.width() + abs(pixel_dx); 144 int w = pixel_rect.width() + abs(pixel_dx);
145 int h = pixel_rect.height() + abs(pixel_dy); 145 int h = pixel_rect.height() + abs(pixel_dy);
146 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); 146 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h);
147 bitmap_.scrollRect(&rect, pixel_dx, pixel_dy); 147 bitmap_.scrollRect(&rect, pixel_dx, pixel_dy);
148 } 148 }
149 149
150 bool BackingStoreAura::CopyFromBackingStore(const gfx::Rect& rect, 150 bool BackingStoreAura::CopyFromBackingStore(const gfx::Rect& rect,
151 skia::PlatformCanvas* output) { 151 skia::PlatformBitmap* output) {
152 const int width = 152 const int width =
153 std::min(size().width(), rect.width()) * device_scale_factor_; 153 std::min(size().width(), rect.width()) * device_scale_factor_;
154 const int height = 154 const int height =
155 std::min(size().height(), rect.height()) * device_scale_factor_; 155 std::min(size().height(), rect.height()) * device_scale_factor_;
156 if (!output->initialize(width, height, true)) 156 if (!output->Allocate(width, height, true))
157 return false; 157 return false;
158 158
159 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true);
160 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); 159 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height);
161 SkBitmap b; 160 SkBitmap b;
162 if (!canvas_->readPixels(skrect, &b)) 161 if (!canvas_->readPixels(skrect, &b))
163 return false; 162 return false;
164 output->writePixels(b, rect.x(), rect.y()); 163 SkCanvas(output->GetBitmap()).writePixels(b, rect.x(), rect.y());
165 return true; 164 return true;
166 } 165 }
167 166
168 } // namespace content 167 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/backing_store_aura.h ('k') | content/browser/renderer_host/backing_store_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698