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

Side by Side Diff: content/browser/compositor/software_output_device_mus.cc

Issue 1438903002: p1 mus+ash chrome renders ui and content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased, fixed release build Created 5 years, 1 month 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
« no previous file with comments | « content/browser/compositor/software_output_device_mus.h ('k') | ui/views/mus/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/compositor/software_output_device_mus.h"
6
7 #include "components/bitmap_uploader/bitmap_uploader.h"
8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "third_party/skia/include/core/SkDevice.h"
10 #include "ui/base/view_prop.h"
11 #include "ui/compositor/compositor.h"
12 #include "ui/gfx/skia_util.h"
13
14 #if !defined(OFFICIAL_BUILD)
15 #include "base/threading/thread_restrictions.h"
16 #endif
17
18 namespace content {
19
20 SoftwareOutputDeviceMus::SoftwareOutputDeviceMus(ui::Compositor* compositor)
21 : compositor_(compositor) {}
22
23 void SoftwareOutputDeviceMus::EndPaint() {
24 SoftwareOutputDevice::EndPaint();
25 #if !defined(OFFICIAL_BUILD)
26 base::ThreadRestrictions::ScopedAllowWait wait;
27 #endif
28
29 if (!surface_)
30 return;
31
32 gfx::Rect rect = damage_rect_;
33 rect.Intersect(gfx::Rect(viewport_pixel_size_));
34 if (rect.IsEmpty())
35 return;
36
37 gfx::AcceleratedWidget widget = compositor_->widget();
38 bitmap_uploader::BitmapUploader* uploader =
39 reinterpret_cast<bitmap_uploader::BitmapUploader*>(ui::ViewProp::GetValue(
40 widget, bitmap_uploader::kBitmapUploaderForAcceleratedWidget));
41 DCHECK(uploader);
42
43 SkImageInfo info;
44 size_t rowBytes;
45 const void* addr = surface_->peekPixels(&info, &rowBytes);
46
47 if (!addr) {
48 LOG(WARNING) << "SoftwareOutputDeviceMus: skia surface did not provide us "
49 "with pixels";
50 return;
51 }
52
53 const unsigned char* pixels = static_cast<const unsigned char*>(addr);
54
55 // TODO(rjkroege): This makes an additional copy. Improve the
56 // bitmap_uploader API to remove.
57 scoped_ptr<std::vector<unsigned char>> data(new std::vector<unsigned char>(
58 pixels, pixels + rowBytes * viewport_pixel_size_.height()));
59 uploader->SetBitmap(viewport_pixel_size_.width(),
60 viewport_pixel_size_.height(), data.Pass(),
61 bitmap_uploader::BitmapUploader::BGRA);
62 }
63
64 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/software_output_device_mus.h ('k') | ui/views/mus/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698