Remove GrStyledShape.h from GrSmallPathShapeData.h
This refactoring was requested during an earlier code review.
Change-Id: I93184e2bc936b3c8c69f84e475be2c234845ee81
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309120
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 2fdc783..056e68e 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -413,6 +413,7 @@
"$_src/gpu/ops/GrSmallPathAtlasMgr.h",
"$_src/gpu/ops/GrSmallPathRenderer.cpp",
"$_src/gpu/ops/GrSmallPathRenderer.h",
+ "$_src/gpu/ops/GrSmallPathShapeData.cpp",
"$_src/gpu/ops/GrSmallPathShapeData.h",
"$_src/gpu/ops/GrStrokeRectOp.cpp",
"$_src/gpu/ops/GrStrokeRectOp.h",
diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp
index 4779b20..a9cc28f 100644
--- a/src/gpu/ops/GrSmallPathRenderer.cpp
+++ b/src/gpu/ops/GrSmallPathRenderer.cpp
@@ -26,6 +26,7 @@
#include "src/gpu/effects/GrBitmapTextGeoProc.h"
#include "src/gpu/effects/GrDistanceFieldGeoProc.h"
#include "src/gpu/geometry/GrQuad.h"
+#include "src/gpu/geometry/GrStyledShape.h"
#include "src/gpu/ops/GrMeshDrawOp.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelperWithStencil.h"
#include "src/gpu/ops/GrSmallPathAtlasMgr.h"
diff --git a/src/gpu/ops/GrSmallPathShapeData.cpp b/src/gpu/ops/GrSmallPathShapeData.cpp
new file mode 100644
index 0000000..2f9ce79
--- /dev/null
+++ b/src/gpu/ops/GrSmallPathShapeData.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "src/gpu/ops/GrSmallPathShapeData.h"
+
+#include "src/gpu/geometry/GrStyledShape.h"
+
+void GrSmallPathShapeDataKey::set(const GrStyledShape& shape, uint32_t dim) {
+ // Shapes' keys are for their pre-style geometry, but by now we shouldn't have any
+ // relevant styling information.
+ SkASSERT(shape.style().isSimpleFill());
+ SkASSERT(shape.hasUnstyledKey());
+ int shapeKeySize = shape.unstyledKeySize();
+ fKey.reset(1 + shapeKeySize);
+ fKey[0] = dim;
+ shape.writeUnstyledKey(&fKey[1]);
+}
+
+void GrSmallPathShapeDataKey::set(const GrStyledShape& shape, const SkMatrix& ctm) {
+ // Shapes' keys are for their pre-style geometry, but by now we shouldn't have any
+ // relevant styling information.
+ SkASSERT(shape.style().isSimpleFill());
+ SkASSERT(shape.hasUnstyledKey());
+ // We require the upper left 2x2 of the matrix to match exactly for a cache hit.
+ SkScalar sx = ctm.get(SkMatrix::kMScaleX);
+ SkScalar sy = ctm.get(SkMatrix::kMScaleY);
+ SkScalar kx = ctm.get(SkMatrix::kMSkewX);
+ SkScalar ky = ctm.get(SkMatrix::kMSkewY);
+ SkScalar tx = ctm.get(SkMatrix::kMTransX);
+ SkScalar ty = ctm.get(SkMatrix::kMTransY);
+ // Allow 8 bits each in x and y of subpixel positioning.
+ tx -= SkScalarFloorToScalar(tx);
+ ty -= SkScalarFloorToScalar(ty);
+ SkFixed fracX = SkScalarToFixed(tx) & 0x0000FF00;
+ SkFixed fracY = SkScalarToFixed(ty) & 0x0000FF00;
+ int shapeKeySize = shape.unstyledKeySize();
+ fKey.reset(5 + shapeKeySize);
+ fKey[0] = SkFloat2Bits(sx);
+ fKey[1] = SkFloat2Bits(sy);
+ fKey[2] = SkFloat2Bits(kx);
+ fKey[3] = SkFloat2Bits(ky);
+ fKey[4] = fracX | (fracY >> 8);
+ shape.writeUnstyledKey(&fKey[5]);
+}
diff --git a/src/gpu/ops/GrSmallPathShapeData.h b/src/gpu/ops/GrSmallPathShapeData.h
index c5ddbf1..d21dbf1 100644
--- a/src/gpu/ops/GrSmallPathShapeData.h
+++ b/src/gpu/ops/GrSmallPathShapeData.h
@@ -5,11 +5,14 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#ifndef GrSmallPathShapeData_DEFINED
#define GrSmallPathShapeData_DEFINED
#include "src/core/SkOpts.h"
-#include "src/gpu/geometry/GrStyledShape.h"
+#include "src/gpu/GrDrawOpAtlas.h"
+
+class GrStyledShape;
class GrSmallPathShapeDataKey {
public:
@@ -27,44 +30,10 @@
}
// for SDF paths
- void set(const GrStyledShape& shape, uint32_t dim) {
- // Shapes' keys are for their pre-style geometry, but by now we shouldn't have any
- // relevant styling information.
- SkASSERT(shape.style().isSimpleFill());
- SkASSERT(shape.hasUnstyledKey());
- int shapeKeySize = shape.unstyledKeySize();
- fKey.reset(1 + shapeKeySize);
- fKey[0] = dim;
- shape.writeUnstyledKey(&fKey[1]);
- }
+ void set(const GrStyledShape&, uint32_t dim);
// for bitmap paths
- void set(const GrStyledShape& shape, const SkMatrix& ctm) {
- // Shapes' keys are for their pre-style geometry, but by now we shouldn't have any
- // relevant styling information.
- SkASSERT(shape.style().isSimpleFill());
- SkASSERT(shape.hasUnstyledKey());
- // We require the upper left 2x2 of the matrix to match exactly for a cache hit.
- SkScalar sx = ctm.get(SkMatrix::kMScaleX);
- SkScalar sy = ctm.get(SkMatrix::kMScaleY);
- SkScalar kx = ctm.get(SkMatrix::kMSkewX);
- SkScalar ky = ctm.get(SkMatrix::kMSkewY);
- SkScalar tx = ctm.get(SkMatrix::kMTransX);
- SkScalar ty = ctm.get(SkMatrix::kMTransY);
- // Allow 8 bits each in x and y of subpixel positioning.
- tx -= SkScalarFloorToScalar(tx);
- ty -= SkScalarFloorToScalar(ty);
- SkFixed fracX = SkScalarToFixed(tx) & 0x0000FF00;
- SkFixed fracY = SkScalarToFixed(ty) & 0x0000FF00;
- int shapeKeySize = shape.unstyledKeySize();
- fKey.reset(5 + shapeKeySize);
- fKey[0] = SkFloat2Bits(sx);
- fKey[1] = SkFloat2Bits(sy);
- fKey[2] = SkFloat2Bits(kx);
- fKey[3] = SkFloat2Bits(ky);
- fKey[4] = fracX | (fracY >> 8);
- shape.writeUnstyledKey(&fKey[5]);
- }
+ void set(const GrStyledShape&, const SkMatrix& ctm);
bool operator==(const GrSmallPathShapeDataKey & that) const {
return fKey.count() == that.fKey.count() &&