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

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

Issue 2162693002: Move bitmap uploader to ui service client lib (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
« no previous file with comments | « content/browser/compositor/DEPS ('k') | services/ui/demo/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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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_mus.h" 5 #include "content/browser/compositor/software_output_device_mus.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "components/bitmap_uploader/bitmap_uploader.h" 10 #include "services/ui/public/cpp/bitmap_uploader.h"
11 #include "third_party/skia/include/core/SkImageInfo.h" 11 #include "third_party/skia/include/core/SkImageInfo.h"
12 #include "ui/base/view_prop.h" 12 #include "ui/base/view_prop.h"
13 #include "ui/compositor/compositor.h" 13 #include "ui/compositor/compositor.h"
14 #include "ui/gfx/skia_util.h" 14 #include "ui/gfx/skia_util.h"
15 15
16 #if !defined(OFFICIAL_BUILD) 16 #if !defined(OFFICIAL_BUILD)
17 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
18 #endif 18 #endif
19 19
20 namespace content { 20 namespace content {
21 21
22 SoftwareOutputDeviceMus::SoftwareOutputDeviceMus(ui::Compositor* compositor) 22 SoftwareOutputDeviceMus::SoftwareOutputDeviceMus(ui::Compositor* compositor)
23 : compositor_(compositor) {} 23 : compositor_(compositor) {}
24 24
25 void SoftwareOutputDeviceMus::EndPaint() { 25 void SoftwareOutputDeviceMus::EndPaint() {
26 SoftwareOutputDevice::EndPaint(); 26 SoftwareOutputDevice::EndPaint();
27 #if !defined(OFFICIAL_BUILD) 27 #if !defined(OFFICIAL_BUILD)
28 base::ThreadRestrictions::ScopedAllowWait wait; 28 base::ThreadRestrictions::ScopedAllowWait wait;
29 #endif 29 #endif
30 30
31 if (!surface_) 31 if (!surface_)
32 return; 32 return;
33 33
34 gfx::Rect rect = damage_rect_; 34 gfx::Rect rect = damage_rect_;
35 rect.Intersect(gfx::Rect(viewport_pixel_size_)); 35 rect.Intersect(gfx::Rect(viewport_pixel_size_));
36 if (rect.IsEmpty()) 36 if (rect.IsEmpty())
37 return; 37 return;
38 38
39 gfx::AcceleratedWidget widget = compositor_->widget(); 39 gfx::AcceleratedWidget widget = compositor_->widget();
40 bitmap_uploader::BitmapUploader* uploader = 40 ui::BitmapUploader* uploader =
41 reinterpret_cast<bitmap_uploader::BitmapUploader*>(ui::ViewProp::GetValue( 41 reinterpret_cast<ui::BitmapUploader*>(ui::ViewProp::GetValue(
42 widget, bitmap_uploader::kBitmapUploaderForAcceleratedWidget)); 42 widget, ui::kBitmapUploaderForAcceleratedWidget));
43 DCHECK(uploader); 43 DCHECK(uploader);
44 44
45 SkPixmap pixmap; 45 SkPixmap pixmap;
46 surface_->peekPixels(&pixmap); 46 surface_->peekPixels(&pixmap);
47 47
48 if (!pixmap.addr()) { 48 if (!pixmap.addr()) {
49 LOG(WARNING) << "SoftwareOutputDeviceMus: skia surface did not provide us " 49 LOG(WARNING) << "SoftwareOutputDeviceMus: skia surface did not provide us "
50 "with pixels"; 50 "with pixels";
51 return; 51 return;
52 } 52 }
53 53
54 const unsigned char* pixels = static_cast<const unsigned char*>( 54 const unsigned char* pixels = static_cast<const unsigned char*>(
55 pixmap.addr()); 55 pixmap.addr());
56 56
57 // TODO(rjkroege): This makes an additional copy. Improve the 57 // TODO(rjkroege): This makes an additional copy. Improve the
58 // bitmap_uploader API to remove. 58 // bitmap_uploader API to remove.
59 std::unique_ptr<std::vector<unsigned char>> data( 59 std::unique_ptr<std::vector<unsigned char>> data(
60 new std::vector<unsigned char>( 60 new std::vector<unsigned char>(
61 pixels, pixels + pixmap.rowBytes() * viewport_pixel_size_.height())); 61 pixels, pixels + pixmap.rowBytes() * viewport_pixel_size_.height()));
62 uploader->SetBitmap(viewport_pixel_size_.width(), 62 uploader->SetBitmap(viewport_pixel_size_.width(),
63 viewport_pixel_size_.height(), std::move(data), 63 viewport_pixel_size_.height(), std::move(data),
64 bitmap_uploader::BitmapUploader::BGRA); 64 ui::BitmapUploader::BGRA);
65 } 65 }
66 66
67 } // namespace content 67 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/DEPS ('k') | services/ui/demo/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698