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

Side by Side Diff: cc/playback/image_hijack_canvas.cc

Issue 2541183002: cc: Rename ImageDecodeController to ImageDecodeCache. (Closed)
Patch Set: rename: update Created 4 years 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 | « cc/playback/image_hijack_canvas.h ('k') | cc/playback/raster_source.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "cc/playback/image_hijack_canvas.h" 5 #include "cc/playback/image_hijack_canvas.h"
6 6
7 #include "base/optional.h" 7 #include "base/optional.h"
8 #include "cc/playback/discardable_image_map.h" 8 #include "cc/playback/discardable_image_map.h"
9 #include "cc/tiles/image_decode_controller.h" 9 #include "cc/tiles/image_decode_cache.h"
10 10
11 namespace cc { 11 namespace cc {
12 namespace { 12 namespace {
13 13
14 SkIRect RoundOutRect(const SkRect& rect) { 14 SkIRect RoundOutRect(const SkRect& rect) {
15 SkIRect result; 15 SkIRect result;
16 rect.roundOut(&result); 16 rect.roundOut(&result);
17 return result; 17 return result;
18 } 18 }
19 19
20 class ScopedDecodedImageLock { 20 class ScopedDecodedImageLock {
21 public: 21 public:
22 ScopedDecodedImageLock(ImageDecodeController* image_decode_controller, 22 ScopedDecodedImageLock(ImageDecodeCache* image_decode_cache,
23 sk_sp<const SkImage> image, 23 sk_sp<const SkImage> image,
24 const SkRect& src_rect, 24 const SkRect& src_rect,
25 const SkMatrix& matrix, 25 const SkMatrix& matrix,
26 const SkPaint* paint) 26 const SkPaint* paint)
27 : image_decode_controller_(image_decode_controller), 27 : image_decode_cache_(image_decode_cache),
28 draw_image_(std::move(image), 28 draw_image_(std::move(image),
29 RoundOutRect(src_rect), 29 RoundOutRect(src_rect),
30 paint ? paint->getFilterQuality() : kNone_SkFilterQuality, 30 paint ? paint->getFilterQuality() : kNone_SkFilterQuality,
31 matrix), 31 matrix),
32 decoded_draw_image_( 32 decoded_draw_image_(
33 image_decode_controller_->GetDecodedImageForDraw(draw_image_)) { 33 image_decode_cache_->GetDecodedImageForDraw(draw_image_)) {
34 DCHECK(draw_image_.image()->isLazyGenerated()); 34 DCHECK(draw_image_.image()->isLazyGenerated());
35 if (paint) { 35 if (paint) {
36 decoded_paint_ = *paint; 36 decoded_paint_ = *paint;
37 decoded_paint_->setFilterQuality(decoded_draw_image_.filter_quality()); 37 decoded_paint_->setFilterQuality(decoded_draw_image_.filter_quality());
38 } 38 }
39 } 39 }
40 40
41 ~ScopedDecodedImageLock() { 41 ~ScopedDecodedImageLock() {
42 image_decode_controller_->DrawWithImageFinished(draw_image_, 42 image_decode_cache_->DrawWithImageFinished(draw_image_,
43 decoded_draw_image_); 43 decoded_draw_image_);
44 } 44 }
45 45
46 const DecodedDrawImage& decoded_image() const { return decoded_draw_image_; } 46 const DecodedDrawImage& decoded_image() const { return decoded_draw_image_; }
47 const SkPaint* decoded_paint() const { 47 const SkPaint* decoded_paint() const {
48 return decoded_paint_ ? &decoded_paint_.value() : nullptr; 48 return decoded_paint_ ? &decoded_paint_.value() : nullptr;
49 } 49 }
50 50
51 private: 51 private:
52 ImageDecodeController* image_decode_controller_; 52 ImageDecodeCache* image_decode_cache_;
53 DrawImage draw_image_; 53 DrawImage draw_image_;
54 DecodedDrawImage decoded_draw_image_; 54 DecodedDrawImage decoded_draw_image_;
55 base::Optional<SkPaint> decoded_paint_; 55 base::Optional<SkPaint> decoded_paint_;
56 }; 56 };
57 57
58 } // namespace 58 } // namespace
59 59
60 ImageHijackCanvas::ImageHijackCanvas( 60 ImageHijackCanvas::ImageHijackCanvas(int width,
61 int width, 61 int height,
62 int height, 62 ImageDecodeCache* image_decode_cache)
63 ImageDecodeController* image_decode_controller) 63 : SkNWayCanvas(width, height), image_decode_cache_(image_decode_cache) {}
64 : SkNWayCanvas(width, height),
65 image_decode_controller_(image_decode_controller) {}
66 64
67 void ImageHijackCanvas::onDrawPicture(const SkPicture* picture, 65 void ImageHijackCanvas::onDrawPicture(const SkPicture* picture,
68 const SkMatrix* matrix, 66 const SkMatrix* matrix,
69 const SkPaint* paint) { 67 const SkPaint* paint) {
70 // Ensure that pictures are unpacked by this canvas, instead of being 68 // Ensure that pictures are unpacked by this canvas, instead of being
71 // forwarded to the raster canvas. 69 // forwarded to the raster canvas.
72 SkCanvas::onDrawPicture(picture, matrix, paint); 70 SkCanvas::onDrawPicture(picture, matrix, paint);
73 } 71 }
74 72
75 void ImageHijackCanvas::onDrawImage(const SkImage* image, 73 void ImageHijackCanvas::onDrawImage(const SkImage* image,
76 SkScalar x, 74 SkScalar x,
77 SkScalar y, 75 SkScalar y,
78 const SkPaint* paint) { 76 const SkPaint* paint) {
79 if (!image->isLazyGenerated()) { 77 if (!image->isLazyGenerated()) {
80 SkNWayCanvas::onDrawImage(image, x, y, paint); 78 SkNWayCanvas::onDrawImage(image, x, y, paint);
81 return; 79 return;
82 } 80 }
83 81
84 SkMatrix ctm = getTotalMatrix(); 82 SkMatrix ctm = getTotalMatrix();
85 83
86 ScopedDecodedImageLock scoped_lock( 84 ScopedDecodedImageLock scoped_lock(
87 image_decode_controller_, sk_ref_sp(image), 85 image_decode_cache_, sk_ref_sp(image),
88 SkRect::MakeIWH(image->width(), image->height()), ctm, paint); 86 SkRect::MakeIWH(image->width(), image->height()), ctm, paint);
89 const DecodedDrawImage& decoded_image = scoped_lock.decoded_image(); 87 const DecodedDrawImage& decoded_image = scoped_lock.decoded_image();
90 if (!decoded_image.image()) 88 if (!decoded_image.image())
91 return; 89 return;
92 90
93 DCHECK_EQ(0, static_cast<int>(decoded_image.src_rect_offset().width())); 91 DCHECK_EQ(0, static_cast<int>(decoded_image.src_rect_offset().width()));
94 DCHECK_EQ(0, static_cast<int>(decoded_image.src_rect_offset().height())); 92 DCHECK_EQ(0, static_cast<int>(decoded_image.src_rect_offset().height()));
95 const SkPaint* decoded_paint = scoped_lock.decoded_paint(); 93 const SkPaint* decoded_paint = scoped_lock.decoded_paint();
96 94
97 bool need_scale = !decoded_image.is_scale_adjustment_identity(); 95 bool need_scale = !decoded_image.is_scale_adjustment_identity();
(...skipping 19 matching lines...) Expand all
117 115
118 SkRect src_storage; 116 SkRect src_storage;
119 if (!src) { 117 if (!src) {
120 src_storage = SkRect::MakeIWH(image->width(), image->height()); 118 src_storage = SkRect::MakeIWH(image->width(), image->height());
121 src = &src_storage; 119 src = &src_storage;
122 } 120 }
123 SkMatrix matrix; 121 SkMatrix matrix;
124 matrix.setRectToRect(*src, dst, SkMatrix::kFill_ScaleToFit); 122 matrix.setRectToRect(*src, dst, SkMatrix::kFill_ScaleToFit);
125 matrix.postConcat(getTotalMatrix()); 123 matrix.postConcat(getTotalMatrix());
126 124
127 ScopedDecodedImageLock scoped_lock(image_decode_controller_, sk_ref_sp(image), 125 ScopedDecodedImageLock scoped_lock(image_decode_cache_, sk_ref_sp(image),
128 *src, matrix, paint); 126 *src, matrix, paint);
129 const DecodedDrawImage& decoded_image = scoped_lock.decoded_image(); 127 const DecodedDrawImage& decoded_image = scoped_lock.decoded_image();
130 if (!decoded_image.image()) 128 if (!decoded_image.image())
131 return; 129 return;
132 130
133 const SkPaint* decoded_paint = scoped_lock.decoded_paint(); 131 const SkPaint* decoded_paint = scoped_lock.decoded_paint();
134 132
135 SkRect adjusted_src = 133 SkRect adjusted_src =
136 src->makeOffset(decoded_image.src_rect_offset().width(), 134 src->makeOffset(decoded_image.src_rect_offset().width(),
137 decoded_image.src_rect_offset().height()); 135 decoded_image.src_rect_offset().height());
(...skipping 10 matching lines...) Expand all
148 146
149 void ImageHijackCanvas::onDrawImageNine(const SkImage* image, 147 void ImageHijackCanvas::onDrawImageNine(const SkImage* image,
150 const SkIRect& center, 148 const SkIRect& center,
151 const SkRect& dst, 149 const SkRect& dst,
152 const SkPaint* paint) { 150 const SkPaint* paint) {
153 // No cc embedder issues image nine calls. 151 // No cc embedder issues image nine calls.
154 NOTREACHED(); 152 NOTREACHED();
155 } 153 }
156 154
157 } // namespace cc 155 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/image_hijack_canvas.h ('k') | cc/playback/raster_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698