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

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

Issue 9416017: Optionally clear PlatformCanvas instances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Address style issues. Created 8 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_skia.h" 5 #include "content/browser/renderer_host/backing_store_skia.h"
6 6
7 #include "content/browser/renderer_host/render_process_host_impl.h" 7 #include "content/browser/renderer_host/render_process_host_impl.h"
8 #include "skia/ext/platform_canvas.h" 8 #include "skia/ext/platform_canvas.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 int w = clip_rect.width() + abs(dx); 91 int w = clip_rect.width() + abs(dx);
92 int h = clip_rect.height() + abs(dy); 92 int h = clip_rect.height() + abs(dy);
93 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); 93 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h);
94 bitmap_.scrollRect(&rect, dx, dy); 94 bitmap_.scrollRect(&rect, dx, dy);
95 } 95 }
96 96
97 bool BackingStoreSkia::CopyFromBackingStore(const gfx::Rect& rect, 97 bool BackingStoreSkia::CopyFromBackingStore(const gfx::Rect& rect,
98 skia::PlatformCanvas* output) { 98 skia::PlatformCanvas* output) {
99 const int width = std::min(size().width(), rect.width()); 99 const int width = std::min(size().width(), rect.width());
100 const int height = std::min(size().height(), rect.height()); 100 const int height = std::min(size().height(), rect.height());
101 if (!output->initialize(width, height, true)) 101 if (!output->initialize(width, height, skia::PlatformDevice::FLAGS_OPAQUE))
102 return false; 102 return false;
103 103
104 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true); 104 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true);
105 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); 105 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height);
106 SkBitmap b; 106 SkBitmap b;
107 if (!canvas_->readPixels(skrect, &b)) 107 if (!canvas_->readPixels(skrect, &b))
108 return false; 108 return false;
109 output->writePixels(b, rect.x(), rect.y()); 109 output->writePixels(b, rect.x(), rect.y());
110 return true; 110 return true;
111 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698