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

Side by Side Diff: Source/platform/graphics/skia/NativeImageSkia.cpp

Issue 868743002: Use SkXfermode::Mode in code related to Image. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase to ToT Created 5 years, 11 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 | « Source/platform/graphics/skia/NativeImageSkia.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "third_party/skia/include/core/SkRect.h" 47 #include "third_party/skia/include/core/SkRect.h"
48 #include "third_party/skia/include/core/SkScalar.h" 48 #include "third_party/skia/include/core/SkScalar.h"
49 #include "third_party/skia/include/core/SkShader.h" 49 #include "third_party/skia/include/core/SkShader.h"
50 50
51 namespace blink { 51 namespace blink {
52 52
53 void NativeImageSkia::draw( 53 void NativeImageSkia::draw(
54 GraphicsContext* context, 54 GraphicsContext* context,
55 const SkRect& srcRect, 55 const SkRect& srcRect,
56 const SkRect& destRect, 56 const SkRect& destRect,
57 CompositeOperator compositeOp, 57 SkXfermode::Mode op) const
58 WebBlendMode blendMode) const
59 { 58 {
60 TRACE_EVENT0("skia", "NativeImageSkia::draw"); 59 TRACE_EVENT0("skia", "NativeImageSkia::draw");
61 60
62 bool isLazyDecoded = DeferredImageDecoder::isLazyDecoded(bitmap()); 61 bool isLazyDecoded = DeferredImageDecoder::isLazyDecoded(bitmap());
63 bool isOpaque = bitmap().isOpaque(); 62 bool isOpaque = bitmap().isOpaque();
64 63
65 { 64 {
66 SkPaint paint; 65 SkPaint paint;
67 int initialSaveCount = context->preparePaintForDrawRectToRect(&paint, sr cRect, destRect, compositeOp, blendMode, !isOpaque, isLazyDecoded, isDataComplet e()); 66 int initialSaveCount = context->preparePaintForDrawRectToRect(&paint, sr cRect, destRect, op, !isOpaque, isLazyDecoded, isDataComplete());
68 // We want to filter it if we decided to do interpolation above, or if 67 // We want to filter it if we decided to do interpolation above, or if
69 // there is something interesting going on with the matrix (like a rotat ion). 68 // there is something interesting going on with the matrix (like a rotat ion).
70 // Note: for serialization, we will want to subset the bitmap first so w e 69 // Note: for serialization, we will want to subset the bitmap first so w e
71 // don't send extra pixels. 70 // don't send extra pixels.
72 context->drawBitmapRect(bitmap(), &srcRect, destRect, &paint); 71 context->drawBitmapRect(bitmap(), &srcRect, destRect, &paint);
73 context->canvas()->restoreToCount(initialSaveCount); 72 context->canvas()->restoreToCount(initialSaveCount);
74 } 73 }
75 74
76 if (isLazyDecoded) 75 if (isLazyDecoded)
77 PlatformInstrumentation::didDrawLazyPixelRef(bitmap().getGenerationID()) ; 76 PlatformInstrumentation::didDrawLazyPixelRef(bitmap().getGenerationID()) ;
(...skipping 10 matching lines...) Expand all
88 bitmap.copyPixelsTo(reinterpret_cast<uint8_t*>(result.getPixels()), result.r owBytes() * result.height(), result.rowBytes()); 87 bitmap.copyPixelsTo(reinterpret_cast<uint8_t*>(result.getPixels()), result.r owBytes() * result.height(), result.rowBytes());
89 88
90 return result; 89 return result;
91 } 90 }
92 91
93 void NativeImageSkia::drawPattern( 92 void NativeImageSkia::drawPattern(
94 GraphicsContext* context, 93 GraphicsContext* context,
95 const FloatRect& floatSrcRect, 94 const FloatRect& floatSrcRect,
96 const FloatSize& scale, 95 const FloatSize& scale,
97 const FloatPoint& phase, 96 const FloatPoint& phase,
98 CompositeOperator compositeOp, 97 SkXfermode::Mode compositeOp,
99 const FloatRect& destRect, 98 const FloatRect& destRect,
100 WebBlendMode blendMode,
101 const IntSize& repeatSpacing) const 99 const IntSize& repeatSpacing) const
102 { 100 {
103 FloatRect normSrcRect = floatSrcRect; 101 FloatRect normSrcRect = floatSrcRect;
104 normSrcRect.intersect(FloatRect(0, 0, bitmap().width(), bitmap().height())); 102 normSrcRect.intersect(FloatRect(0, 0, bitmap().width(), bitmap().height()));
105 if (destRect.isEmpty() || normSrcRect.isEmpty()) 103 if (destRect.isEmpty() || normSrcRect.isEmpty())
106 return; // nothing to draw 104 return; // nothing to draw
107 105
108 SkMatrix totalMatrix = context->getTotalMatrix(); 106 SkMatrix totalMatrix = context->getTotalMatrix();
109 totalMatrix.preScale(scale.width(), scale.height()); 107 totalMatrix.preScale(scale.width(), scale.height());
110 108
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 155
158 bitmapToPaint = createBitmapWithSpace( 156 bitmapToPaint = createBitmapWithSpace(
159 bitmapToPaint, 157 bitmapToPaint,
160 repeatSpacing.width() * ctmScaleX / scale.width(), 158 repeatSpacing.width() * ctmScaleX / scale.width(),
161 repeatSpacing.height() * ctmScaleY / scale.height()); 159 repeatSpacing.height() * ctmScaleY / scale.height());
162 } 160 }
163 RefPtr<SkShader> shader = adoptRef(SkShader::CreateBitmapShader(bitmapToPain t, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &localMatrix)); 161 RefPtr<SkShader> shader = adoptRef(SkShader::CreateBitmapShader(bitmapToPain t, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &localMatrix));
164 162
165 SkPaint paint; 163 SkPaint paint;
166 paint.setShader(shader.get()); 164 paint.setShader(shader.get());
167 paint.setXfermodeMode(WebCoreCompositeToSkiaComposite(compositeOp, blendMode )); 165 paint.setXfermodeMode(compositeOp);
168 paint.setColorFilter(context->colorFilter()); 166 paint.setColorFilter(context->colorFilter());
169 paint.setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); 167 paint.setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling));
170 168
171 if (isLazyDecoded) 169 if (isLazyDecoded)
172 PlatformInstrumentation::didDrawLazyPixelRef(bitmap().getGenerationID()) ; 170 PlatformInstrumentation::didDrawLazyPixelRef(bitmap().getGenerationID()) ;
173 171
174 context->drawRect(destRect, paint); 172 context->drawRect(destRect, paint);
175 } 173 }
176 174
177 } // namespace blink 175 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/skia/NativeImageSkia.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698