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

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

Issue 8369006: [Aura] Support transparent webkit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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) 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"
11 #include "ui/gfx/canvas_skia.h" 11 #include "ui/gfx/canvas_skia.h"
12 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
13 13
14 // Assume that somewhere along the line, someone will do width * height * 4 14 // Assume that somewhere along the line, someone will do width * height * 4
15 // with signed numbers. If the maximum value is 2**31, then 2**31 / 4 = 15 // with signed numbers. If the maximum value is 2**31, then 2**31 / 4 =
16 // 2**29 and floor(sqrt(2**29)) = 23170. 16 // 2**29 and floor(sqrt(2**29)) = 23170.
17 17
18 // Max height and width for layers 18 // Max height and width for layers
19 static const int kMaxVideoLayerSize = 23170; 19 static const int kMaxVideoLayerSize = 23170;
20 20
21 BackingStoreSkia::BackingStoreSkia(RenderWidgetHost* widget, 21 BackingStoreSkia::BackingStoreSkia(RenderWidgetHost* widget,
22 const gfx::Size& size) 22 const gfx::Size& size)
23 : BackingStore(widget, size) { 23 : BackingStore(widget, size) {
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 copy_paint_.setXfermodeMode(SkXfermode::kSrc_Mode);
27 } 28 }
28 29
29 BackingStoreSkia::~BackingStoreSkia() { 30 BackingStoreSkia::~BackingStoreSkia() {
30 } 31 }
31 32
32 void BackingStoreSkia::SkiaShowRect(const gfx::Point& point, 33 void BackingStoreSkia::SkiaShowRect(const gfx::Point& point,
33 gfx::Canvas* canvas) { 34 gfx::Canvas* canvas) {
34 canvas->GetSkCanvas()->drawBitmap(bitmap_, 35 canvas->GetSkCanvas()->drawBitmap(bitmap_,
35 SkIntToScalar(point.x()), SkIntToScalar(point.y())); 36 SkIntToScalar(point.x()), SkIntToScalar(point.y()));
36 } 37 }
(...skipping 29 matching lines...) Expand all
66 for (size_t i = 0; i < copy_rects.size(); i++) { 67 for (size_t i = 0; i < copy_rects.size(); i++) {
67 const gfx::Rect& copy_rect = copy_rects[i]; 68 const gfx::Rect& copy_rect = copy_rects[i];
68 int x = copy_rect.x() - bitmap_rect.x(); 69 int x = copy_rect.x() - bitmap_rect.x();
69 int y = copy_rect.y() - bitmap_rect.y(); 70 int y = copy_rect.y() - bitmap_rect.y();
70 int w = copy_rect.width(); 71 int w = copy_rect.width();
71 int h = copy_rect.height(); 72 int h = copy_rect.height();
72 SkIRect srcrect = SkIRect::MakeXYWH(x, y, w, h); 73 SkIRect srcrect = SkIRect::MakeXYWH(x, y, w, h);
73 SkRect dstrect = SkRect::MakeXYWH( 74 SkRect dstrect = SkRect::MakeXYWH(
74 SkIntToScalar(copy_rect.x()), SkIntToScalar(copy_rect.y()), 75 SkIntToScalar(copy_rect.x()), SkIntToScalar(copy_rect.y()),
75 SkIntToScalar(w), SkIntToScalar(h)); 76 SkIntToScalar(w), SkIntToScalar(h));
76 canvas_.get()->drawBitmapRect(sk_bitmap, &srcrect, dstrect); 77 canvas_.get()->drawBitmapRect(sk_bitmap, &srcrect, dstrect, &copy_paint_);
brettw 2011/10/21 20:14:44 In other places we haven't bothered saving the SkP
xiyuan 2011/10/21 20:24:05 Done.
77 } 78 }
78 } 79 }
79 80
80 void BackingStoreSkia::ScrollBackingStore(int dx, int dy, 81 void BackingStoreSkia::ScrollBackingStore(int dx, int dy,
81 const gfx::Rect& clip_rect, 82 const gfx::Rect& clip_rect,
82 const gfx::Size& view_size) { 83 const gfx::Size& view_size) {
83 int x = std::min(clip_rect.x(), clip_rect.x() - dx); 84 int x = std::min(clip_rect.x(), clip_rect.x() - dx);
84 int y = std::min(clip_rect.y(), clip_rect.y() - dy); 85 int y = std::min(clip_rect.y(), clip_rect.y() - dy);
85 int w = clip_rect.width() + abs(dx); 86 int w = clip_rect.width() + abs(dx);
86 int h = clip_rect.height() + abs(dy); 87 int h = clip_rect.height() + abs(dy);
87 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); 88 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h);
88 bitmap_.scrollRect(&rect, dx, dy); 89 bitmap_.scrollRect(&rect, dx, dy);
89 } 90 }
90 91
91 bool BackingStoreSkia::CopyFromBackingStore(const gfx::Rect& rect, 92 bool BackingStoreSkia::CopyFromBackingStore(const gfx::Rect& rect,
92 skia::PlatformCanvas* output) { 93 skia::PlatformCanvas* output) {
93 const int width = std::min(size().width(), rect.width()); 94 const int width = std::min(size().width(), rect.width());
94 const int height = std::min(size().height(), rect.height()); 95 const int height = std::min(size().height(), rect.height());
95 if (!output->initialize(width, height, true)) 96 if (!output->initialize(width, height, true))
96 return false; 97 return false;
97 98
98 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true); 99 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true);
99 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); 100 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height);
100 SkBitmap b; 101 SkBitmap b;
101 if (!canvas_->readPixels(skrect, &b)) 102 if (!canvas_->readPixels(skrect, &b))
102 return false; 103 return false;
103 output->writePixels(b, rect.x(), rect.y()); 104 output->writePixels(b, rect.x(), rect.y());
104 return true; 105 return true;
105 } 106 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/backing_store_skia.h ('k') | content/browser/renderer_host/render_widget_host_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698