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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/PlaceholderImage.cpp

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: DrawingDisplayItem Created 3 years, 10 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
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 "platform/graphics/PlaceholderImage.h" 5 #include "platform/graphics/PlaceholderImage.h"
6 6
7 #include "platform/geometry/FloatRect.h" 7 #include "platform/geometry/FloatRect.h"
8 #include "platform/graphics/Color.h" 8 #include "platform/graphics/Color.h"
9 #include "platform/graphics/GraphicsContext.h" 9 #include "platform/graphics/GraphicsContext.h"
10 #include "platform/graphics/ImageObserver.h" 10 #include "platform/graphics/ImageObserver.h"
11 #include "platform/graphics/paint/PaintRecord.h"
11 #include "platform/graphics/paint/SkPictureBuilder.h" 12 #include "platform/graphics/paint/SkPictureBuilder.h"
12 #include "third_party/skia/include/core/SkCanvas.h"
13 #include "third_party/skia/include/core/SkColor.h" 13 #include "third_party/skia/include/core/SkColor.h"
14 #include "third_party/skia/include/core/SkPaint.h"
15 #include "third_party/skia/include/core/SkPicture.h"
16 #include "third_party/skia/include/core/SkRect.h" 14 #include "third_party/skia/include/core/SkRect.h"
17 #include "third_party/skia/include/core/SkSize.h" 15 #include "third_party/skia/include/core/SkSize.h"
18 16
19 namespace blink { 17 namespace blink {
20 18
21 namespace { 19 namespace {
22 20
23 // Gray with 40% opacity. 21 // Gray with 40% opacity.
24 const RGBA32 kFillColor = 0x66808080; 22 const RGBA32 kFillColor = 0x66808080;
25 23
(...skipping 11 matching lines...) Expand all
37 const FloatRect destRect(0.0f, 0.0f, static_cast<float>(m_size.width()), 35 const FloatRect destRect(0.0f, 0.0f, static_cast<float>(m_size.width()),
38 static_cast<float>(m_size.height())); 36 static_cast<float>(m_size.height()));
39 SkPictureBuilder builder(destRect); 37 SkPictureBuilder builder(destRect);
40 GraphicsContext& context = builder.context(); 38 GraphicsContext& context = builder.context();
41 context.beginRecording(destRect); 39 context.beginRecording(destRect);
42 40
43 context.setFillColor(kFillColor); 41 context.setFillColor(kFillColor);
44 context.fillRect(destRect); 42 context.fillRect(destRect);
45 43
46 m_imageForCurrentFrame = SkImage::MakeFromPicture( 44 m_imageForCurrentFrame = SkImage::MakeFromPicture(
47 builder.endRecording(), SkISize::Make(m_size.width(), m_size.height()), 45 ToSkPicture(builder.endRecording()),
48 nullptr, nullptr); 46 SkISize::Make(m_size.width(), m_size.height()), nullptr, nullptr);
49 47
50 return m_imageForCurrentFrame; 48 return m_imageForCurrentFrame;
51 } 49 }
52 50
53 void PlaceholderImage::draw(SkCanvas* canvas, 51 void PlaceholderImage::draw(PaintCanvas* canvas,
54 const SkPaint& basePaint, 52 const PaintFlags& basePaint,
55 const FloatRect& destRect, 53 const FloatRect& destRect,
56 const FloatRect& srcRect, 54 const FloatRect& srcRect,
57 RespectImageOrientationEnum, 55 RespectImageOrientationEnum,
58 ImageClampingMode, 56 ImageClampingMode,
59 const ColorBehavior& colorBehavior) { 57 const ColorBehavior& colorBehavior) {
60 // TODO(ccameron): This function should not ignore |colorBehavior|. 58 // TODO(ccameron): This function should not ignore |colorBehavior|.
61 // https://crbug.com/672306 59 // https://crbug.com/672306
62 if (!srcRect.intersects(FloatRect(0.0f, 0.0f, 60 if (!srcRect.intersects(FloatRect(0.0f, 0.0f,
63 static_cast<float>(m_size.width()), 61 static_cast<float>(m_size.width()),
64 static_cast<float>(m_size.height())))) { 62 static_cast<float>(m_size.height())))) {
65 return; 63 return;
66 } 64 }
67 65
68 SkPaint paint(basePaint); 66 PaintFlags paint(basePaint);
69 paint.setStyle(SkPaint::kFill_Style); 67 paint.setStyle(PaintFlags::kFill_Style);
70 paint.setColor(kFillColor); 68 paint.setColor(kFillColor);
71 canvas->drawRect(destRect, paint); 69 canvas->drawRect(destRect, paint);
72 } 70 }
73 71
74 void PlaceholderImage::destroyDecodedData() { 72 void PlaceholderImage::destroyDecodedData() {
75 m_imageForCurrentFrame.reset(); 73 m_imageForCurrentFrame.reset();
76 } 74 }
77 75
78 } // namespace blink 76 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698