OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compositor/software_output_device_win.h" | 5 #include "content/browser/compositor/software_output_device_win.h" |
6 | 6 |
7 #include "base/debug/alias.h" | 7 #include "base/debug/alias.h" |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "cc/resources/shared_bitmap.h" | 9 #include "cc/resources/shared_bitmap.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 DCHECK(!in_paint_); | 115 DCHECK(!in_paint_); |
116 | 116 |
117 scale_factor_ = scale_factor; | 117 scale_factor_ = scale_factor; |
118 | 118 |
119 if (viewport_pixel_size_ == viewport_pixel_size) | 119 if (viewport_pixel_size_ == viewport_pixel_size) |
120 return; | 120 return; |
121 | 121 |
122 viewport_pixel_size_ = viewport_pixel_size; | 122 viewport_pixel_size_ = viewport_pixel_size; |
123 if (backing_) | 123 if (backing_) |
124 backing_->Resized(); | 124 backing_->Resized(); |
125 contents_.clear(); | 125 contents_.reset(); |
126 } | 126 } |
127 | 127 |
128 SkCanvas* SoftwareOutputDeviceWin::BeginPaint(const gfx::Rect& damage_rect) { | 128 SkCanvas* SoftwareOutputDeviceWin::BeginPaint(const gfx::Rect& damage_rect) { |
129 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 129 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
130 DCHECK(!in_paint_); | 130 DCHECK(!in_paint_); |
131 if (!contents_) { | 131 if (!contents_) { |
132 HANDLE shared_section = NULL; | 132 HANDLE shared_section = NULL; |
133 bool can_create_contents = true; | 133 bool can_create_contents = true; |
134 if (backing_) { | 134 if (backing_) { |
135 base::SharedMemory* memory = | 135 base::SharedMemory* memory = |
136 backing_->GetSharedMemory(viewport_pixel_size_); | 136 backing_->GetSharedMemory(viewport_pixel_size_); |
137 if (memory) { | 137 if (memory) { |
138 shared_section = memory->handle().GetHandle(); | 138 shared_section = memory->handle().GetHandle(); |
139 } else { | 139 } else { |
140 can_create_contents = false; | 140 can_create_contents = false; |
141 } | 141 } |
142 } | 142 } |
143 if (can_create_contents) { | 143 if (can_create_contents) { |
144 contents_ = skia::AdoptRef(skia::CreatePlatformCanvas( | 144 contents_ = sk_sp<SkCanvas>(skia::CreatePlatformCanvas( |
145 viewport_pixel_size_.width(), viewport_pixel_size_.height(), true, | 145 viewport_pixel_size_.width(), viewport_pixel_size_.height(), true, |
146 shared_section, skia::CRASH_ON_FAILURE)); | 146 shared_section, skia::CRASH_ON_FAILURE)); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 damage_rect_ = damage_rect; | 150 damage_rect_ = damage_rect; |
151 in_paint_ = true; | 151 in_paint_ = true; |
152 return contents_.get(); | 152 return contents_.get(); |
153 } | 153 } |
154 | 154 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 RECT src_rect = rect.ToRECT(); | 189 RECT src_rect = rect.ToRECT(); |
190 skia::DrawToNativeContext(contents_.get(), hdc, rect.x(), rect.y(), | 190 skia::DrawToNativeContext(contents_.get(), hdc, rect.x(), rect.y(), |
191 &src_rect); | 191 &src_rect); |
192 ::ReleaseDC(hwnd_, hdc); | 192 ::ReleaseDC(hwnd_, hdc); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 void SoftwareOutputDeviceWin::ReleaseContents() { | 196 void SoftwareOutputDeviceWin::ReleaseContents() { |
197 DCHECK(!contents_ || contents_->unique()); | 197 DCHECK(!contents_ || contents_->unique()); |
198 DCHECK(!in_paint_); | 198 DCHECK(!in_paint_); |
199 contents_.clear(); | 199 contents_.reset(); |
200 } | 200 } |
201 | 201 |
202 } // namespace content | 202 } // namespace content |
OLD | NEW |