OLD | NEW |
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.h" | 7 #include "content/browser/renderer_host/render_process_host.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 13 matching lines...) Expand all Loading... |
24 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); | 24 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); |
25 bitmap_.allocPixels(); | 25 bitmap_.allocPixels(); |
26 canvas_.reset(new SkCanvas(bitmap_)); | 26 canvas_.reset(new SkCanvas(bitmap_)); |
27 } | 27 } |
28 | 28 |
29 BackingStoreSkia::~BackingStoreSkia() { | 29 BackingStoreSkia::~BackingStoreSkia() { |
30 } | 30 } |
31 | 31 |
32 void BackingStoreSkia::SkiaShowRect(const gfx::Point& point, | 32 void BackingStoreSkia::SkiaShowRect(const gfx::Point& point, |
33 gfx::Canvas* canvas) { | 33 gfx::Canvas* canvas) { |
34 canvas->AsCanvasSkia()->drawBitmap(bitmap_, | 34 canvas->AsCanvasSkia()->skia_canvas()->drawBitmap(bitmap_, |
35 SkIntToScalar(point.x()), SkIntToScalar(point.y())); | 35 SkIntToScalar(point.x()), SkIntToScalar(point.y())); |
36 } | 36 } |
37 | 37 |
38 size_t BackingStoreSkia::MemorySize() { | 38 size_t BackingStoreSkia::MemorySize() { |
39 // NOTE: The computation may be different when the canvas is a subrectangle of | 39 // NOTE: The computation may be different when the canvas is a subrectangle of |
40 // a larger bitmap. | 40 // a larger bitmap. |
41 return size().GetArea() * 4; | 41 return size().GetArea() * 4; |
42 } | 42 } |
43 | 43 |
44 void BackingStoreSkia::PaintToBackingStore( | 44 void BackingStoreSkia::PaintToBackingStore( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return false; | 96 return false; |
97 | 97 |
98 SkBitmap bitmap = output->getTopPlatformDevice().accessBitmap(true); | 98 SkBitmap bitmap = output->getTopPlatformDevice().accessBitmap(true); |
99 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); | 99 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); |
100 SkBitmap b; | 100 SkBitmap b; |
101 if (!canvas_->readPixels(skrect, &b)) | 101 if (!canvas_->readPixels(skrect, &b)) |
102 return false; | 102 return false; |
103 output->writePixels(b, rect.x(), rect.y()); | 103 output->writePixels(b, rect.x(), rect.y()); |
104 return true; | 104 return true; |
105 } | 105 } |
OLD | NEW |