OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkDevice.h" | 8 #include "SkDevice.h" |
9 #include "SkDeviceProperties.h" | 9 #include "SkDeviceProperties.h" |
10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
11 #include "SkMetaData.h" | 11 #include "SkMetaData.h" |
12 #include "SkPatchUtils.h" | 12 #include "SkPatchUtils.h" |
13 #include "SkShader.h" | 13 #include "SkShader.h" |
14 #include "SkTextBlob.h" | 14 #include "SkTextBlob.h" |
| 15 #include "SkImage_Base.h" |
15 | 16 |
16 SkBaseDevice::SkBaseDevice() | 17 SkBaseDevice::SkBaseDevice() |
17 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::kLega
cyLCD_InitType))) | 18 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::kLega
cyLCD_InitType))) |
| 19 , fSurfaceBase(NULL) |
18 #ifdef SK_DEBUG | 20 #ifdef SK_DEBUG |
19 , fAttachedToCanvas(false) | 21 , fAttachedToCanvas(false) |
20 #endif | 22 #endif |
21 { | 23 { |
22 fOrigin.setZero(); | 24 fOrigin.setZero(); |
23 fMetaData = NULL; | 25 fMetaData = NULL; |
24 } | 26 } |
25 | 27 |
26 SkBaseDevice::SkBaseDevice(const SkDeviceProperties& dp) | 28 SkBaseDevice::SkBaseDevice(const SkDeviceProperties& dp) |
27 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (dp))) | 29 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (dp))) |
| 30 , fSurfaceBase(NULL) |
28 #ifdef SK_DEBUG | 31 #ifdef SK_DEBUG |
29 , fAttachedToCanvas(false) | 32 , fAttachedToCanvas(false) |
30 #endif | 33 #endif |
31 { | 34 { |
32 fOrigin.setZero(); | 35 fOrigin.setZero(); |
33 fMetaData = NULL; | 36 fMetaData = NULL; |
34 } | 37 } |
35 | 38 |
36 SkBaseDevice::~SkBaseDevice() { | 39 SkBaseDevice::~SkBaseDevice() { |
37 SkDELETE(fLeakyProperties); | 40 SkDELETE(fLeakyProperties); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 SkPath path; | 98 SkPath path; |
96 path.addRRect(outer); | 99 path.addRRect(outer); |
97 path.addRRect(inner); | 100 path.addRRect(inner); |
98 path.setFillType(SkPath::kEvenOdd_FillType); | 101 path.setFillType(SkPath::kEvenOdd_FillType); |
99 | 102 |
100 const SkMatrix* preMatrix = NULL; | 103 const SkMatrix* preMatrix = NULL; |
101 const bool pathIsMutable = true; | 104 const bool pathIsMutable = true; |
102 this->drawPath(draw, path, paint, preMatrix, pathIsMutable); | 105 this->drawPath(draw, path, paint, preMatrix, pathIsMutable); |
103 } | 106 } |
104 | 107 |
| 108 void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage& image, |
| 109 int x, int y, const SkPaint& paint) { |
| 110 SkBitmap bitmap; |
| 111 if (!as_IB(&image)->getROPixels(&bitmap)) { |
| 112 return; |
| 113 } |
| 114 this->drawSprite(draw, bitmap, x, y, paint); |
| 115 } |
| 116 |
| 117 |
105 void SkBaseDevice::drawPatch(const SkDraw& draw, const SkPoint cubics[12], const
SkColor colors[4], | 118 void SkBaseDevice::drawPatch(const SkDraw& draw, const SkPoint cubics[12], const
SkColor colors[4], |
106 const SkPoint texCoords[4], SkXfermode* xmode, cons
t SkPaint& paint) { | 119 const SkPoint texCoords[4], SkXfermode* xmode, cons
t SkPaint& paint) { |
107 SkPatchUtils::VertexData data; | 120 SkPatchUtils::VertexData data; |
108 | 121 |
109 SkISize lod = SkPatchUtils::GetLevelOfDetail(cubics, draw.fMatrix); | 122 SkISize lod = SkPatchUtils::GetLevelOfDetail(cubics, draw.fMatrix); |
110 | 123 |
111 // It automatically adjusts lodX and lodY in case it exceeds the number of i
ndices. | 124 // It automatically adjusts lodX and lodY in case it exceeds the number of i
ndices. |
112 // If it fails to generate the vertices, then we do not draw. | 125 // If it fails to generate the vertices, then we do not draw. |
113 if (SkPatchUtils::getVertexData(&data, cubics, colors, texCoords, lod.width(
), lod.height())) { | 126 if (SkPatchUtils::getVertexData(&data, cubics, colors, texCoords, lod.width(
), lod.height())) { |
114 this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCo
unt, data.fPoints, | 127 this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCo
unt, data.fPoints, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry() | 235 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry() |
223 || this->onShouldDisableLCD(paint)) { | 236 || this->onShouldDisableLCD(paint)) { |
224 | 237 |
225 flags &= ~SkPaint::kLCDRenderText_Flag; | 238 flags &= ~SkPaint::kLCDRenderText_Flag; |
226 flags |= SkPaint::kGenA8FromLCD_Flag; | 239 flags |= SkPaint::kGenA8FromLCD_Flag; |
227 } | 240 } |
228 | 241 |
229 return flags; | 242 return flags; |
230 } | 243 } |
231 | 244 |
OLD | NEW |